xserver: Branch 'refs/remotes/origin/glucose-2' - 28 commits

Alan Hourihane alanh at kemper.freedesktop.org
Thu Sep 27 06:55:38 PDT 2007


 Makefile.am                                |    7 
 Xext/mbufbf.c                              |    9 
 afb/Makefile.am                            |    2 
 afb/afb.h                                  |   15 
 afb/afbpntwin.c                            |  126 ----
 afb/afbscrinit.c                           |    9 
 afb/afbwindow.c                            |  163 ------
 cfb/Makefile.am.inc                        |    2 
 cfb/cfb.h                                  |   37 -
 cfb/cfballpriv.c                           |   18 
 cfb/cfbmap.h                               |    6 
 cfb/cfbpntwin.c                            |  768 -----------------------------
 cfb/cfbscrinit.c                           |    4 
 cfb/cfbtile32.c                            |    2 
 cfb/cfbunmap.h                             |    3 
 cfb/cfbwindow.c                            |  185 ------
 composite/compext.c                        |    6 
 composite/compinit.c                       |    4 
 composite/compint.h                        |    4 
 composite/compwindow.c                     |   17 
 configure.ac                               |   33 -
 dix/window.c                               |    2 
 exa/exa.c                                  |    8 
 exa/exa_accel.c                            |   54 --
 exa/exa_migration.c                        |    8 
 exa/exa_priv.h                             |    8 
 exa/exa_unaccel.c                          |   26 
 fb/fb.h                                    |    4 
 fb/fboverlay.c                             |   11 
 fb/fboverlay.h                             |    4 
 fb/fbpseudocolor.c                         |   68 --
 fb/fbscreen.c                              |    2 
 fb/fbwindow.c                              |   55 --
 fb/wfbrename.h                             |    2 
 glucose/Makefile.am                        |   25 
 glucose/glucose.c                          |    6 
 glucose/glucose_context.c                  |    1 
 glucose/glucose_drawable.c                 |    1 
 glucose/symlink-xgl.sh                     |  166 ------
 hw/darwin/Makefile.am                      |   74 +-
 hw/darwin/darwin.c                         |    4 
 hw/darwin/iokit/xfIOKit.c                  |    4 
 hw/darwin/iokit/xfIOKitCursor.c            |    5 
 hw/darwin/iokit/xfIOKitStartup.c           |    5 
 hw/darwin/quartz/Preferences.m             |    6 
 hw/darwin/quartz/XServer.m                 |    6 
 hw/darwin/quartz/applewm.c                 |    6 
 hw/darwin/quartz/cr/XView.m                |    7 
 hw/darwin/quartz/cr/crAppleWM.m            |    6 
 hw/darwin/quartz/cr/crFrame.m              |    7 
 hw/darwin/quartz/cr/crScreen.m             |    6 
 hw/darwin/quartz/fullscreen/fullscreen.c   |    6 
 hw/darwin/quartz/fullscreen/quartzCursor.c |    6 
 hw/darwin/quartz/pseudoramiX.c             |    6 
 hw/darwin/quartz/quartz.c                  |    8 
 hw/darwin/quartz/quartzAudio.c             |    6 
 hw/darwin/quartz/quartzCocoa.m             |    4 
 hw/darwin/quartz/quartzCursor.c            |    5 
 hw/darwin/quartz/quartzKeyboard.c          |    6 
 hw/darwin/quartz/quartzPasteboard.c        |    6 
 hw/darwin/quartz/xpr/appledri.c            |    5 
 hw/darwin/quartz/xpr/dri.c                 |    5 
 hw/darwin/quartz/xpr/x-hash.c              |    6 
 hw/darwin/quartz/xpr/x-hook.c              |    6 
 hw/darwin/quartz/xpr/x-list.c              |    6 
 hw/darwin/quartz/xpr/xprAppleWM.c          |    6 
 hw/darwin/quartz/xpr/xprCursor.c           |    6 
 hw/darwin/quartz/xpr/xprFrame.c            |    6 
 hw/darwin/quartz/xpr/xprScreen.c           |    9 
 hw/dmx/dmx.h                               |    2 
 hw/dmx/dmxscrinit.c                        |    5 
 hw/dmx/dmxwindow.c                         |   51 -
 hw/dmx/dmxwindow.h                         |    4 
 hw/kdrive/igs/igsdraw.c                    |   72 --
 hw/kdrive/savage/s3.h                      |    1 
 hw/kdrive/savage/s3draw.c                  |  118 ----
 hw/kdrive/sis530/sisdraw.c                 |   73 --
 hw/kdrive/src/kaa.c                        |   48 -
 hw/kdrive/src/kasync.c                     |   10 
 hw/kdrive/src/kdrive.h                     |    3 
 hw/vfb/InitOutput.c                        |   16 
 hw/xfree86/rac/xf86RAC.c                   |   40 -
 hw/xfree86/shadowfb/shadow.c               |   42 -
 hw/xfree86/xaa/Makefile.am                 |    2 
 hw/xfree86/xaa/xaa.h                       |    2 
 hw/xfree86/xaa/xaaInit.c                   |   10 
 hw/xfree86/xaa/xaaOverlay.c                |  179 ------
 hw/xfree86/xaa/xaaOverlayDF.c              |   53 --
 hw/xfree86/xaa/xaaPaintWin.c               |  200 -------
 hw/xfree86/xaa/xaaStateChange.c            |   24 
 hw/xfree86/xaa/xaaWrapper.c                |   35 -
 hw/xfree86/xaa/xaalocal.h                  |   10 
 hw/xfree86/xf1bpp/Makefile.am              |    1 
 hw/xfree86/xf1bpp/mfbmap.h                 |    1 
 hw/xfree86/xf1bpp/mfbunmap.h               |    1 
 hw/xfree86/xf4bpp/Makefile.am              |    1 
 hw/xfree86/xf4bpp/ppcGC.c                  |    9 
 hw/xfree86/xf4bpp/ppcIO.c                  |    4 
 hw/xfree86/xf4bpp/ppcPntWin.c              |  216 --------
 hw/xfree86/xf4bpp/ppcWindow.c              |    8 
 hw/xfree86/xf4bpp/xf4bpp.h                 |    7 
 hw/xfree86/xf8_32bpp/cfb8_32.h             |   16 
 hw/xfree86/xf8_32bpp/cfbpntwin.c           |  129 ----
 hw/xfree86/xf8_32bpp/cfbscrinit.c          |    8 
 hw/xfree86/xf8_32bpp/cfbwindow.c           |    5 
 hw/xfree86/xf8_32bpp/xf86overlay.c         |   65 --
 hw/xgl/Makefile.am                         |   44 -
 hw/xgl/glx/Makefile.am                     |    1 
 hw/xgl/glx/module/Makefile.am              |    1 
 hw/xgl/glx/xglx.c                          |    2 
 hw/xgl/glxext/Makefile.am                  |    1 
 hw/xgl/glxext/module/Makefile.am           |    1 
 hw/xgl/glxext/xglglxext.c                  |    2 
 hw/xgl/xglscreen.c                         |    2 
 hw/xgl/xglwindow.c                         |  341 ------------
 hw/xnest/Init.c                            |   16 
 hw/xnest/Screen.c                          |    2 
 hw/xnest/Window.c                          |   24 
 hw/xnest/XNWindow.h                        |    2 
 hw/xprint/pcl/Pcl.h                        |    4 
 hw/xprint/pcl/PclInit.c                    |    2 
 hw/xprint/pcl/PclWindow.c                  |  226 --------
 hw/xprint/pcl/Pclmap.h                     |    1 
 hw/xprint/ps/Ps.h                          |    1 
 hw/xprint/ps/PsInit.c                      |    2 
 hw/xprint/ps/PsWindow.c                    |  224 --------
 hw/xwin/Makefile.am                        |    1 
 hw/xwin/win.h                              |   13 
 hw/xwin/winpntwin.c                        |   47 -
 hw/xwin/winscrinit.c                       |    2 
 include/scrnintstr.h                       |    4 
 mfb/Makefile.am                            |    2 
 mfb/mfb.h                                  |   20 
 mfb/mfbpntwin.c                            |  126 ----
 mfb/mfbscrinit.c                           |   19 
 mfb/mfbwindow.c                            |  176 ------
 mi/mibank.c                                |   71 --
 mi/miexpose.c                              |  165 ++----
 mi/mioverlay.c                             |   20 
 mi/miscrinit.c                             |    2 
 mi/miwindow.c                              |    6 
 miext/cw/cw.c                              |  147 -----
 miext/cw/cw.h                              |    2 
 miext/damage/damage.c                      |   33 -
 miext/damage/damagestr.h                   |    2 
 miext/rootless/rootlessCommon.h            |    2 
 miext/rootless/rootlessScreen.c            |    2 
 miext/rootless/rootlessWindow.c            |   98 ---
 miext/rootless/rootlessWindow.h            |    4 
 miext/rootless/safeAlpha/Makefile.am       |    3 
 miext/rootless/safeAlpha/safeAlpha.h       |    2 
 miext/rootless/safeAlpha/safeAlphaWindow.c |  177 ------
 os/utils.c                                 |    2 
 randr/rroutput.c                           |    1 
 xgl/Makefile.am                            |   42 +
 xgl/xgl.h                                  |   12 
 xgl/xglwindow.c                            |  166 ++++++
 157 files changed, 527 insertions(+), 5327 deletions(-)

New commits:
diff-tree ac41255d56f82999e1cb5f9bd450bec3de95f3da (from 051d68415635282a246ec7e5f5d6b0f9c4de71aa)
Author: José Fonseca <jfonseca at titan.(none)>
Date:   Wed Sep 26 16:43:56 2007 +0000

    Factor-out glucose symlinked code from xgl into a common library.

diff --git a/Makefile.am b/Makefile.am
index b1daa05..5362442 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,7 +30,12 @@ if DBE
 DBE_DIR=dbe
 endif
 
+if XGL
+XGL_DIR=xgl
+endif
+
 if GLUCOSE
+XGL_DIR=xgl
 GLUCOSE_DIR=glucose
 endif
 
@@ -60,6 +65,7 @@ SUBDIRS = \
 	$(GLX_DIR) \
 	exa \
 	config \
+	$(XGL_DIR) \
 	$(GLUCOSE_DIR) \
 	hw
 
@@ -107,6 +113,7 @@ DIST_SUBDIRS = \
 	GL \
 	exa \
 	config \
+	xgl \
 	glucose \
 	hw
 
diff --git a/configure.ac b/configure.ac
index a20b745..f986dd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -789,13 +789,10 @@ if test "x$GLX" = xyes && ! test "x$MESA
 	test -d GL || mkdir GL
 	case $host_os in
 	  solaris*) 	
-		SYMLINK_MESA="/usr/bin/bash $srcdir/GL/symlink-mesa.sh"
-		SYMLINK_GLUCOSE="/usr/bin/bash $srcdir/glucose/symlink-xgl.sh"	;;
-	  *)	SYMLINK_MESA=$srcdir/GL/symlink-mesa.sh
-	  	SYMLINK_GLUCOSE=$srcdir/glucose/symlink-xgl.sh ;;
+		SYMLINK_MESA="/usr/bin/bash $srcdir/GL/symlink-mesa.sh"	;;
+	  *)	SYMLINK_MESA=$srcdir/GL/symlink-mesa.sh ;;
 	esac
 	$SYMLINK_MESA $MESA_SOURCE GL/
-	$SYMLINK_GLUCOSE $srcdir/hw/xgl glucose/
 	if test $? -ne 0; then
 		AC_MSG_ERROR([Failed to link Mesa source tree.  Please specify a proper path to Mesa sources, or disable GLX.])
 	fi
@@ -1263,10 +1260,13 @@ fi
 AC_MSG_RESULT([$XGL])
 AM_CONDITIONAL(XGL, [test "x$XGL" = xyes])
 
-if test "x$XGL" = xyes; then
+if test "x$XGL" = xyes -o "x$GLUCOSE" = xyes; then
 	XGL_LIBS="$FB_LIB $COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $MIEXT_LAYER_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB $CWRAP_LIB"
-	XGL_SYS_LIBS="$XGLMODULES_LIBS $GLX_SYS_LIBS $DLOPEN_LIBS"
 	AC_SUBST([XGL_LIBS])
+fi
+
+if test "x$XGL" = xyes; then
+	XGL_SYS_LIBS="$XGLMODULES_LIBS $GLX_SYS_LIBS $DLOPEN_LIBS"
 	AC_SUBST([XGL_SYS_LIBS])
 	AC_DEFINE(XGL_MODULAR, 1, [Use loadable XGL modules])
 	AC_DEFINE(XGLServer, 1, [Building XGL server])
@@ -2063,6 +2063,7 @@ Xext/Makefile
 Xi/Makefile
 xfixes/Makefile
 exa/Makefile
+xgl/Makefile
 glucose/Makefile
 hw/Makefile
 hw/xfree86/Makefile
diff --git a/glucose/Makefile.am b/glucose/Makefile.am
index 1686d38..943a3c7 100644
--- a/glucose/Makefile.am
+++ b/glucose/Makefile.am
@@ -4,6 +4,7 @@ INCLUDES = -I at MESA_SOURCE@/include \
            -I$(top_srcdir)/GL/mesa/glapi \
            -I$(top_srcdir)/GL/glx \
            -I$(top_srcdir)/GL/include \
+           -I$(top_srcdir)/xgl \
            -I$(top_srcdir)/hw/xfree86/os-support \
            -I$(top_srcdir)/hw/xfree86/os-support/bus \
            -I$(top_srcdir)/hw/xfree86/common
@@ -27,27 +28,3 @@ libglucose_la_SOURCES = \
 	glucose_info.c
 
 libglucose_la_LIBADD = $(GLUCOSE_LIBS)
-
-
-nodist_libglucose_la_SOURCES = \
-xgl.h \
-xglarea.c \
-xglcmap.c \
-xglcompose.c \
-xglcopy.c \
-xglfill.c \
-xglgc.c \
-xglgeometry.c \
-xglget.c \
-xglglyph.c \
-xglpict.c \
-xglpixmap.c \
-xglshm.c \
-xglsolid.c \
-xglsync.c \
-xgltile.c \
-xgltrap.c \
-xglwindow.c \
-xglxv.c
-
-EXTRA_DIST = symlink_xgl.sh
diff --git a/glucose/symlink-xgl.sh b/glucose/symlink-xgl.sh
deleted file mode 100755
index 32da110..0000000
--- a/glucose/symlink-xgl.sh
+++ /dev/null
@@ -1,166 +0,0 @@
-#!/bin/sh
-
-#
-# A script that symlinks source files from xgl to glucose
-#
-# Author: Soren Sandmann (sandmann at redhat.com) (original)
-# adapted for glucose by Alan Hourihane <alanh at tungstengraphics.com>
-
-#
-# Things we would like to do
-#
-#	- Check that all the relevant files exist
-#		- AUTHORS, autogen.sh, configure.ac, ...
-#	- Check that we have actually linked everything
-#		- if a file doesn't need to be linked, then it needs
-#		  to be listed as "not-linked"
-#	- Compute diffs between all the files (shouldn't be necessary)
-#	- possibly check that files are listet in Makefile.am's
-#	- Clean target directory of irrelevant files
-#
-
-check_destinations () {
-    # don't do anything - we are relying on the side
-    # effect of dst_dir
-    true
-}
-
-check_exist() {
-    # Check whether $1 exists
-
-    if [ ! -e $1 ] ; then
-	error "$1 not found"
-    fi
-}
-
-delete_existing() {
-    # Delete $2
-
-    rm -f $2
-}
-
-link_files() {
-    # Link $1 to $2
-
-    if [ ! -e $2 ] ; then
-	ln -s $1 $2
-    fi
-}
-
-main() {
-    check_args $1 $2
-
-    run check_destinations "Creating destination directories"
-    run check_exist "Checking that the source files exist"
-    run delete_existing "Deleting existing files"
-    run link_files "Linking files"
-}
-
-## actual symlinking
-
-symlink_xgl() {
-    src_dir .
-    dst_dir .
-
-    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
-        action `basename $src`
-    done
-}
-
-#########
-#
-#    Helper functions
-#
-#########
-
-error() {
-	echo
-	echo \ \ \ error:\ \ \ $1
-	exit 1
-}
-
-# printing out what's going on
-run_module() {
-    # $1 module
-    # $2 explanation
-    echo -n $EXPLANATION for $1 module ...\ 
-    symlink_$1
-    echo DONE
-}
-
-run() {
-    # $1 what to do
-    # $2 explanation
-
-    ACTION=$1 EXPLANATION=$2 run_module xgl
-}
-
-src_dir() {
-    REAL_SRC_DIR=$SRC_DIR/$1
-    if [ ! -d $REAL_SRC_DIR ] ; then
-	error "Source directory $REAL_SRC_DIR does not exist"
-    fi
-}
-
-dst_dir() {
-    REAL_DST_DIR=$DST_DIR/$1
-    if [ ! -d $REAL_DST_DIR ] ; then
-	mkdir -p $REAL_DST_DIR
-    fi
-}
-
-action() {
-    if [ -z $2 ] ; then
-	$ACTION	$REAL_SRC_DIR/$1	$REAL_DST_DIR/$1
-    else
-	$ACTION	$REAL_SRC_DIR/$1	$REAL_DST_DIR/$2
-    fi
-}
-
-usage() {
-    echo symlink-xgl.sh src-dir dst-dir
-    echo src-dir: the xgl source directory
-    echo dst-dir: the glucose directory
-}
-
-# Check commandline args
-check_args() {
-    if [ -z $1 ] ; then
-	echo Missing source dir
-	usage
-	exit 1
-    fi
-
-    if [ -z $2 ] ; then
-	echo Missing destination dir
-	usage
-	exit 1
-    fi
-     
-    if [ ! -d $1 ] ; then
-	echo $1 is not a dir
-	usage
-	exit 1
-    fi
-
-    if [ ! -d $2 ] ; then
-	echo $2 is not a dir
-	usage
-	exit 1
-    fi
-
-    if [ $1 = $2 ] ; then
-	echo source and destination can\'t be the same
-	usage
-	exit 1
-    fi
-
-    D=`dirname "$relpath"`
-    B=`basename "$relpath"`
-    abspath="`cd \"$D\" 2>/dev/null && pwd || echo \"$D\"`/$B"
-
-    SRC_DIR=`( cd $1 ; pwd )`
-    DST_DIR=`(cd $2 ; pwd )`
-}
-
-main $1 $2
diff --git a/hw/xgl/Makefile.am b/hw/xgl/Makefile.am
index 6c72ea6..080a4fd 100644
--- a/hw/xgl/Makefile.am
+++ b/hw/xgl/Makefile.am
@@ -28,53 +28,31 @@ AM_CFLAGS = \
 	-I$(top_srcdir)/GL/include		\
 	-I at MESA_SOURCE@/include \
 	-I at MESA_SOURCE@/src/mesa/glapi \
+	-I$(top_srcdir)/xgl \
 	$(XGLMODULES_CFLAGS)
 
-noinst_LIBRARIES = libxgl.a
-
-libxgl_a_SOURCES =     \
-	xgl.h	       \
-	xglmodule.h    \
-	xglglx.h       \
-	xglinput.c     \
-	xgloutput.c    \
-	xglcmap.c      \
-	xglparse.c     \
-	xglscreen.c    \
-	xglarea.c      \
-	xglgeometry.c  \
-	xglpixmap.c    \
-	xglsync.c      \
-	xglsolid.c     \
-	xgltile.c      \
-	xglcopy.c      \
-	xglfill.c      \
-	xglwindow.c    \
-	xglget.c       \
-	xglgc.c	       \
-	xglshm.c       \
-	xglcompose.c   \
-	xglpict.c      \
-	xglglyph.c     \
-	xgltrap.c      \
-	xglloader.c    \
-	xglhash.c      \
-	xglglx.c       \
-	xglxv.c
-
 EXTRA_DIST = \
 	xglmodule.h
 
 Xgl_LDFLAGS = -export-dynamic
 Xgl_SOURCES = \
 	xglinit.c \
+	xglmodule.h \
+	xglglx.h \
+	xglinput.c \
+	xgloutput.c \
+	xglparse.c \
+	xglscreen.c \
+	xglloader.c \
+	xglhash.c \
+	xglglx.c \
 	$(top_srcdir)/mi/miinitext.c \
 	$(top_srcdir)/Xext/dpmsstubs.c \
 	$(top_srcdir)/Xi/stubs.c \
 	$(top_srcdir)/fb/fbcmap.c
 
 XGL_LIBS = \
-	libxgl.a \
+	$(top_srcdir)/xgl/libxgl.la \
 	@XGL_LIBS@ \
 	$(XSERVER_LIBS)
 
diff --git a/hw/xgl/glx/Makefile.am b/hw/xgl/glx/Makefile.am
index 314c02e..76c4d2d 100644
--- a/hw/xgl/glx/Makefile.am
+++ b/hw/xgl/glx/Makefile.am
@@ -15,6 +15,7 @@ AM_CFLAGS = \
 	-I$(top_srcdir)/GL/include \
 	-I at MESA_SOURCE@/include \
 	-I at MESA_SOURCE@/src/mesa/glapi \
+	-I$(top_srcdir)/xgl \
 	 $(DIX_CFLAGS) \
 	-DHAVE_XGL_CONFIG_H \
 	-DHAVE_DIX_CONFIG_H \
diff --git a/hw/xgl/glx/module/Makefile.am b/hw/xgl/glx/module/Makefile.am
index 103b041..ad132ae 100644
--- a/hw/xgl/glx/module/Makefile.am
+++ b/hw/xgl/glx/module/Makefile.am
@@ -6,6 +6,7 @@ AM_CFLAGS = \
 	@DIX_CFLAGS@ \
 	@LIBDRM_CFLAGS@ \
 	@DRIPROTO_CFLAGS@ \
+	-I$(top_srcdir)/xgl \
 	-I$(srcdir)/.. \
 	-I$(srcdir)/../.. \
 	$(XGLXMODULES_CFLAGS)
diff --git a/hw/xgl/glxext/Makefile.am b/hw/xgl/glxext/Makefile.am
index 830b2d1..4518cfb 100644
--- a/hw/xgl/glxext/Makefile.am
+++ b/hw/xgl/glxext/Makefile.am
@@ -9,6 +9,7 @@ AM_CFLAGS =		 \
 	$(XGLMODULES_CFLAGS) \
 	-I$(top_srcdir)/GL/glx \
 	-I$(top_srcdir)/GL/include \
+	-I$(top_srcdir)/xgl \
 	-I$(top_srcdir)/hw/xgl \
 	-I at MESA_SOURCE@/include \
 	-I at MESA_SOURCE@/src/mesa/glapi
diff --git a/hw/xgl/glxext/module/Makefile.am b/hw/xgl/glxext/module/Makefile.am
index 66ea80a..9fb36c7 100644
--- a/hw/xgl/glxext/module/Makefile.am
+++ b/hw/xgl/glxext/module/Makefile.am
@@ -3,6 +3,7 @@ AM_CFLAGS = \
 	-DHAVE_XGL_CONFIG_H \
 	-DHAVE_DIX_CONFIG_H \
 	$(XGLMODULES_CFLAGS) \
+	-I$(top_srcdir)/xgl \
 	-I$(top_srcdir)/hw/xgl 
 
 libglxext_la_LDFLAGS = -avoid-version
diff --git a/hw/xgl/xgl.h b/hw/xgl/xgl.h
deleted file mode 100644
index 62bbee0..0000000
--- a/hw/xgl/xgl.h
+++ /dev/null
@@ -1,1504 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-
-#ifndef _XGL_H_
-#define _XGL_H_
-
-#include <xgl-config.h>
-
-#include <X11/X.h>
-#define NEED_EVENTS
-#include <X11/Xproto.h>
-#include <X11/Xos.h>
-#include <glitz.h>
-
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#include "mi.h"
-#include "dix.h"
-#include "damage.h"
-#include "gc.h"
-#include "micmap.h"
-/* I'd like gc.h to provide this */
-typedef struct _GCFuncs *GCFuncsPtr;
-
-#ifdef RENDER
-#include "mipict.h"
-#else
-#ifdef XV
-#undef XV /* Xv implementation require RENDER */
-#endif
-#endif
-
-#ifdef XV
-#define XGL_XV_FORMAT_YUY2 0
-#define XGL_XV_FORMAT_YV12 1
-#define XGL_XV_FORMAT_RGB  2
-#define XGL_XV_FORMAT_NUM  3
-#endif
-
-/* For the modules.  We should decide what the actual version numbering should
- * be.
- */
-#define VERSION "0.0.1"
-
-extern WindowPtr *WindowTable;
-
-#define XGL_DEFAULT_PBO_MASK 0
-
-typedef struct _xglSizeConstraint {
-    int minWidth;
-    int minHeight;
-    int aboveWidth;
-    int aboveHeight;
-} xglSizeConstraintRec, *xglSizeConstraintPtr;
-
-typedef struct _xglAccelInfo {
-    Bool		 enabled;
-    Bool		 pbuffer;
-    xglSizeConstraintRec size;
-} xglAccelInfoRec, *xglAccelInfoPtr;
-
-typedef struct _xglScreenAccelInfo {
-    xglAccelInfoRec pixmap;
-    xglAccelInfoRec window;
-    xglAccelInfoRec glx;
-    xglAccelInfoRec xv;
-} xglScreenAccelInfoRec, *xglScreenAccelInfoPtr;
-
-typedef struct _xglScreenInfo {
-    glitz_drawable_t	  *drawable;
-    unsigned int	  depth;
-    unsigned int	  width;
-    unsigned int	  height;
-    unsigned int	  widthMm;
-    unsigned int	  heightMm;
-    int			  geometryDataType;
-    int			  geometryUsage;
-    Bool		  yInverted;
-    int			  pboMask;
-    Bool		  lines;
-    Bool		  noYuv;
-    char		  *xvFilter;
-    xglScreenAccelInfoRec accel;
-} xglScreenInfoRec, *xglScreenInfoPtr;
-
-extern xglScreenInfoRec xglScreenInfo;
-
-typedef struct _xglPixelFormat {
-    CARD8		depth, bitsPerRGB;
-    glitz_pixel_masks_t masks;
-} xglPixelFormatRec, *xglPixelFormatPtr;
-
-typedef struct _xglVisual {
-    struct _xglVisual *next;
-    VisualID	      vid;
-    xglPixelFormatPtr pPixel;
-    Bool	      pbuffer;
-    struct {
-	glitz_drawable_format_t *drawable;
-	glitz_format_t	        *surface;
-    } format;
-} xglVisualRec, *xglVisualPtr;
-
-extern xglVisualPtr xglVisuals;
-extern xglPixelFormatRec xglPixelFormats[];
-
-#define xglAreaAvailable 0
-#define xglAreaDivided   1
-#define xglAreaOccupied  2
-
-typedef struct _xglRootArea *xglRootAreaPtr;
-
-typedef struct _xglArea {
-    int		    state;
-    int		    level;
-    int		    x, y;
-    int		    width, height;
-    struct _xglArea *pArea[4];
-    xglRootAreaPtr  pRoot;
-    pointer	    closure;
-    DevUnion	    devPrivate;
-} xglAreaRec, *xglAreaPtr;
-
-typedef struct _xglAreaFuncs {
-    Bool (*Create)	(xglAreaPtr pArea);
-
-    Bool (*MoveIn)      (xglAreaPtr pArea,
-			 pointer    closure);
-
-    void (*MoveOut)     (xglAreaPtr pArea,
-			 pointer    closure);
-
-    int (*CompareScore) (xglAreaPtr pArea,
-			 pointer    closure1,
-			 pointer    closure2);
-
-} xglAreaFuncsRec, *xglAreaFuncsPtr;
-
-typedef struct _xglRootArea {
-    int		    maxLevel;
-    int		    width, height;
-    xglAreaPtr	    pArea;
-    xglAreaFuncsPtr funcs;
-    int		    devPrivateSize;
-    pointer	    closure;
-} xglRootAreaRec;
-
-typedef struct xglGeometry {
-    glitz_buffer_t          *buffer;
-    pointer	            *data;
-    Bool		    broken;
-    glitz_fixed16_16_t	    xOff, yOff;
-    int			    dataType;
-    int			    usage;
-    int			    size, endOffset;
-    glitz_geometry_type_t   type;
-    glitz_geometry_format_t f;
-    int			    first, width, count;
-    glitz_multi_array_t     *array;
-} xglGeometryRec, *xglGeometryPtr;
-
-#ifdef RENDER
-typedef struct _xglFBox {
-    glitz_float_t x1, y1, x2, y2;
-} xglFBoxRec;
-
-typedef union _xglBox {
-    BoxRec     sBox;
-    xglFBoxRec fBox;
-} xglBoxRec, *xglBoxPtr;
-
-typedef struct _xglRange {
-    int		 first;
-    unsigned int count;
-} xglRangeRec, *xglRangePtr;
-
-typedef struct _xglGlyphTexture {
-    PicturePtr		    pMask;
-    glitz_pixel_format_t    pixel;
-    glitz_geometry_format_t format;
-    int			    geometryDataType;
-} xglGlyphTextureRec, *xglGlyphTexturePtr;
-
-typedef struct _xglGlyphArea {
-    unsigned long serial;
-    union {
-	xglBoxRec   box;
-	xglRangeRec range;
-    } u;
-} xglGlyphAreaRec, *xglGlyphAreaPtr;
-
-typedef struct _xglGlyphCache {
-    ScreenPtr		    pScreen;
-    int			    depth;
-    xglRootAreaRec	    rootArea;
-    union {
-	xglGlyphTextureRec texture;
-	xglGeometryRec	   geometry;
-    } u;
-} xglGlyphCacheRec, *xglGlyphCachePtr;
-
-typedef struct _xglGlyph {
-    xglAreaPtr pArea;
-} xglGlyphRec, *xglGlyphPtr;
-
-extern int xglGlyphPrivateIndex;
-
-#define XGL_GET_GLYPH_PRIV(pScreen, pGlyph) ((xglGlyphPtr)		     \
-    (GetGlyphPrivatesForScreen (pGlyph, pScreen))[xglGlyphPrivateIndex].ptr)
-
-#define XGL_GLYPH_PRIV(pScreen, pGlyph)				  \
-    xglGlyphPtr pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pGlyph)
-
-#endif
-
-typedef struct _xglScreen {
-    xglVisualPtr		  pVisual;
-
-#ifdef GLXEXT
-    xglVisualPtr		  pGlxVisual;
-#endif
-
-#ifdef XV
-    xglVisualRec		  pXvVisual[XGL_XV_FORMAT_NUM];
-#endif
-
-    xglVisualPtr		  rootVisual;
-    glitz_drawable_t		  *drawable;
-    glitz_surface_t		  *surface;
-    PixmapPtr			  pScreenPixmap;
-    unsigned long		  features;
-    int				  geometryUsage;
-    int				  geometryDataType;
-    Bool			  yInverted;
-    int				  pboMask;
-    Bool			  lines;
-    Bool			  noYuv;
-    char			  *xvFilter;
-    xglGeometryRec		  scratchGeometry;
-    xglScreenAccelInfoRec	  accel;
-
-#ifdef RENDER
-    xglGlyphCacheRec		  glyphCache[33];
-    PicturePtr			  pSolidAlpha;
-    struct _trapInfo {
-	PicturePtr		  pMask;
-	glitz_geometry_format_t	  format;
-    } trapInfo;
-#endif
-
-    GetImageProcPtr		  GetImage;
-    GetSpansProcPtr		  GetSpans;
-    CreateWindowProcPtr		  CreateWindow;
-    DestroyWindowProcPtr	  DestroyWindow;
-    ChangeWindowAttributesProcPtr ChangeWindowAttributes;
-    CopyWindowProcPtr		  CopyWindow;
-    CreateGCProcPtr		  CreateGC;
-    CloseScreenProcPtr		  CloseScreen;
-    SetWindowPixmapProcPtr	  SetWindowPixmap;
-    BitmapToRegionProcPtr	  BitmapToRegion;
-
-#ifdef RENDER
-    CompositeProcPtr		  Composite;
-    GlyphsProcPtr		  Glyphs;
-    TrapezoidsProcPtr		  Trapezoids;
-    AddTrapsProcPtr		  AddTraps;
-    AddTrianglesProcPtr		  AddTriangles;
-    ChangePictureProcPtr	  ChangePicture;
-    ChangePictureTransformProcPtr ChangePictureTransform;
-    ChangePictureFilterProcPtr	  ChangePictureFilter;
-
-    RealizeGlyphProcPtr		  RealizeGlyph;
-    UnrealizeGlyphProcPtr	  UnrealizeGlyph;
-#endif
-} xglScreenRec, *xglScreenPtr;
-
-extern int xglScreenPrivateIndex;
-
-#define XGL_GET_SCREEN_PRIV(pScreen)				       \
-    ((xglScreenPtr) (pScreen)->devPrivates[xglScreenPrivateIndex].ptr)
-
-#define XGL_SET_SCREEN_PRIV(pScreen, v)				      \
-    ((pScreen)->devPrivates[xglScreenPrivateIndex].ptr = (pointer) v)
-
-#define XGL_SCREEN_PRIV(pScreen)			     \
-    xglScreenPtr pScreenPriv = XGL_GET_SCREEN_PRIV (pScreen)
-
-#define XGL_SCREEN_WRAP(field, wrapper)	 \
-    pScreenPriv->field = pScreen->field; \
-    pScreen->field     = wrapper
-
-#define XGL_SCREEN_UNWRAP(field)	\
-    pScreen->field = pScreenPriv->field
-
-#ifdef RENDER
-#define XGL_PICTURE_SCREEN_WRAP(field, wrapper)	   \
-    pScreenPriv->field    = pPictureScreen->field; \
-    pPictureScreen->field = wrapper
-
-#define XGL_PICTURE_SCREEN_UNWRAP(field)       \
-    pPictureScreen->field = pScreenPriv->field
-#endif
-
-#define xglGCSoftwareDrawableFlag (1L << 0)
-#define xglGCBadFunctionFlag	  (1L << 1)
-#define xglGCPlaneMaskFlag	  (1L << 2)
-
-typedef struct _xglGC {
-    glitz_surface_t   *fg;
-    glitz_surface_t   *bg;
-    glitz_format_id_t id;
-    glitz_operator_t  op;
-    unsigned long     flags;
-    GCFuncsPtr	      funcs;
-    GCOpsPtr	      ops;
-} xglGCRec, *xglGCPtr;
-
-extern int xglGCPrivateIndex;
-
-#define XGL_GET_GC_PRIV(pGC)				   \
-    ((xglGCPtr) (pGC)->devPrivates[xglGCPrivateIndex].ptr)
-
-#define XGL_GC_PRIV(pGC)		     \
-    xglGCPtr pGCPriv = XGL_GET_GC_PRIV (pGC)
-
-#define XGL_GC_WRAP(field, wrapper) \
-    pGCPriv->field = pGC->field;    \
-    pGC->field     = wrapper
-
-#define XGL_GC_UNWRAP(field)    \
-    pGC->field = pGCPriv->field
-
-
-#define xglPCFillMask		(1L << 0)
-#define xglPCFilterMask		(1L << 1)
-#define xglPCTransformMask	(1L << 2)
-#define xglPCComponentAlphaMask (1L << 3)
-#define xglPCDitherMask		(1L << 4)
-
-#define xglPFFilterMask		(1L << 8)
-
-#define xglPixmapTargetNo  0
-#define xglPixmapTargetOut 1
-#define xglPixmapTargetIn  2
-
-#ifdef XV
-
-typedef struct _xglXvPort {
-    PixmapPtr  pPixmap;
-    PicturePtr pSrc;
-    PicturePtr pDst;
-    PicturePtr pTmp;
-} xglXvPortRec, *xglXvPortPtr;
-
-#endif
-
-typedef struct _xglPixmap {
-    xglVisualPtr     pVisual;
-    glitz_surface_t  *surface;
-    glitz_drawable_t *drawable;
-    glitz_buffer_t   *buffer;
-    int		     target;
-    Bool	     acceleratedTile;
-    pointer	     bits;
-    int		     stride;
-    DamagePtr	     pDamage;
-    BoxRec	     damageBox;
-    RegionRec	     bitRegion;
-    Bool	     allBits;
-    unsigned long    pictureMask;
-    xglGeometryPtr   pGeometry;
-
-#ifdef XV
-    xglXvPortPtr     pPortPriv;
-#endif
-
-} xglPixmapRec, *xglPixmapPtr;
-
-extern int xglPixmapPrivateIndex;
-
-#define XGL_GET_PIXMAP_PRIV(pPixmap)				       \
-    ((xglPixmapPtr) (pPixmap)->devPrivates[xglPixmapPrivateIndex].ptr)
-
-#define XGL_PIXMAP_PRIV(pPixmap)			     \
-    xglPixmapPtr pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap)
-
-#define XGL_PICTURE_CHANGES(pictureMask)  (pictureMask & 0x0000ffff)
-#define XGL_PICTURE_FAILURES(pictureMask) (pictureMask & 0xffff0000)
-
-typedef struct _xglWin {
-    PixmapPtr    pPixmap;
-} xglWinRec, *xglWinPtr;
-
-extern int xglWinPrivateIndex;
-
-#define XGL_GET_WINDOW_PRIV(pWin)			      \
-    ((xglWinPtr) (pWin)->devPrivates[xglWinPrivateIndex].ptr)
-
-#define XGL_WINDOW_PRIV(pWin)			    \
-    xglWinPtr pWinPriv = XGL_GET_WINDOW_PRIV (pWin)
-
-#define XGL_GET_WINDOW_PIXMAP(pWin)		       \
-    (XGL_GET_WINDOW_PRIV((WindowPtr) (pWin))->pPixmap)
-
-
-#define XGL_GET_DRAWABLE_PIXMAP(pDrawable)   \
-    (((pDrawable)->type == DRAWABLE_WINDOW)? \
-     XGL_GET_WINDOW_PIXMAP (pDrawable):	     \
-     (PixmapPtr) (pDrawable))
-
-#define XGL_DRAWABLE_PIXMAP(pDrawable)			    \
-    PixmapPtr pPixmap = XGL_GET_DRAWABLE_PIXMAP (pDrawable)
-
-#define XGL_GET_DRAWABLE_PIXMAP_PRIV(pDrawable)		      \
-    XGL_GET_PIXMAP_PRIV (XGL_GET_DRAWABLE_PIXMAP (pDrawable))
-
-#define XGL_DRAWABLE_PIXMAP_PRIV(pDrawable)			        \
-    xglPixmapPtr pPixmapPriv = XGL_GET_DRAWABLE_PIXMAP_PRIV (pDrawable)
-
-#ifdef COMPOSITE
-#define __XGL_OFF_X_WIN(pPix) (-(pPix)->screen_x)
-#define __XGL_OFF_Y_WIN(pPix) (-(pPix)->screen_y)
-#else
-#define __XGL_OFF_X_WIN(pPix) (0)
-#define __XGL_OFF_Y_WIN(pPix) (0)
-#endif
-
-#define XGL_GET_DRAWABLE(pDrawable, pSurface, xOff, yOff)  \
-    {							   \
-	PixmapPtr _pPix;				   \
-	if ((pDrawable)->type != DRAWABLE_PIXMAP) {	   \
-	    _pPix = XGL_GET_WINDOW_PIXMAP (pDrawable);	   \
-	    (xOff) = __XGL_OFF_X_WIN (_pPix);		   \
-	    (yOff) = __XGL_OFF_Y_WIN (_pPix);		   \
-	} else {					   \
-	    _pPix = (PixmapPtr) (pDrawable);		   \
-	    (yOff) = (xOff) = 0;			   \
-	}						   \
-	(pSurface) = XGL_GET_PIXMAP_PRIV (_pPix)->surface; \
-    }
-
-#define XGL_DEFAULT_DPI 96
-
-#define XGL_SW_FAILURE_STRING "software fall-back failure"
-
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-
-#define POWER_OF_TWO(v) ((v & (v - 1)) == 0)
-
-#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
-
-#define FIXED_TO_FLOAT(f) (((glitz_float_t) (f)) / 65536)
-#define FLOAT_TO_FIXED(f) ((int) ((f) * 65536))
-
-#define BOX_NOTEMPTY(pBox)	      \
-    (((pBox)->x2 - (pBox)->x1) > 0 && \
-     ((pBox)->y2 - (pBox)->y1) > 0)
-
-
-/* xglinput.c */
-
-int
-xglMouseProc (DeviceIntPtr pDevice,
-	      int	   onoff);
-
-int
-xglKeybdProc (DeviceIntPtr pDevice,
-	      int	   onoff);
-
-void
-xglBell (int	      volume,
-	 DeviceIntPtr pDev,
-	 pointer      ctrl,
-	 int	      something);
-
-void
-xglKbdCtrl (DeviceIntPtr pDevice,
-	    KeybdCtrl	 *ctrl);
-
-void
-xglInitInput (int argc, char **argv);
-
-#ifdef XEVDEV
-
-extern Bool useEvdev;
-extern char *kbdEvdevFile;
-extern char *ptrEvdevFile;
-
-void
-xglEvdevReadInput (void);
-
-void
-xglWakeupHandler (pointer blockData,
-		  int	  result,
-		  pointer pReadMask);
-
-#endif
-
-/* xgloutput.c */
-
-void
-xglSetPixmapFormats (ScreenInfo *pScreenInfo);
-
-void
-xglSetRootClip (ScreenPtr pScreen,
-		Bool	  enable);
-
-
-/* xglcmap.c */
-
-void
-xglSetVisualTypes (int depth,
-		   int visuals,
-		   int redSize,
-		   int greenSize,
-		   int blueSize);
-
-Bool
-xglHasVisualTypes (xglVisualPtr pVisual,
-		   int		depth);
-
-glitz_format_t *
-xglFindBestSurfaceFormat (ScreenPtr         pScreen,
-			  xglPixelFormatPtr pPixel);
-
-void
-xglInitVisuals (ScreenPtr pScreen);
-
-xglVisualPtr
-xglFindVisualWithDepth (ScreenPtr pScreen,
-			int       depth);
-
-xglVisualPtr
-xglFindVisualWithId (ScreenPtr pScreen,
-		     int       vid);
-
-void
-xglClearVisualTypes (void);
-
-int
-xglNumPixelFormats (void);
-
-
-/* xglparse.c */
-
-char *
-xglParseFindNext (char *cur,
-		  char *delim,
-		  char *save,
-		  char *last);
-
-void
-xglParseScreen (char *arg);
-
-void
-xglUseMsg (void);
-
-int
-xglProcessArgument (int	 argc,
-		    char **argv,
-		    int	 i);
-
-
-/* xglscreen.c */
-
-Bool
-xglScreenInit (ScreenPtr pScreen);
-
-Bool
-xglFinishScreenInit (ScreenPtr pScreen);
-
-Bool
-xglCloseScreen (int	  index,
-		ScreenPtr pScreen);
-
-void
-xglCreateSolidAlphaPicture (ScreenPtr pScreen);
-
-
-/* xglarea.c */
-
-Bool
-xglRootAreaInit (xglRootAreaPtr	    pRoot,
-		 int		    maxLevel,
-		 int		    width,
-		 int		    height,
-		 int		    devPrivateSize,
-		 xglAreaFuncsPtr    funcs,
-		 pointer	    closure);
-
-void
-xglRootAreaFini (xglRootAreaPtr pRoot);
-
-void
-xglLeaveArea (xglAreaPtr pArea);
-
-void
-xglWithdrawArea (xglAreaPtr pArea);
-
-Bool
-xglFindArea (xglAreaPtr pArea,
-	     int	width,
-	     int	height,
-	     Bool	kickOut,
-	     pointer	closure);
-
-
-/* xglgeometry.c */
-
-#define GEOMETRY_DATA_TYPE_SHORT 0
-#define GEOMETRY_DATA_TYPE_FLOAT 1
-
-typedef struct _xglDataTypeInfo {
-    glitz_data_type_t type;
-    int		      size;
-} xglDataTypeInfoRec, *xglDataTypeInfoPtr;
-
-extern xglDataTypeInfoRec xglGeometryDataTypes[2];
-
-#define DEFAULT_GEOMETRY_DATA_TYPE GEOMETRY_DATA_TYPE_FLOAT
-
-#define GEOMETRY_USAGE_STREAM  0
-#define GEOMETRY_USAGE_STATIC  1
-#define GEOMETRY_USAGE_DYNAMIC 2
-#define GEOMETRY_USAGE_SYSMEM  3
-
-#define DEFAULT_GEOMETRY_USAGE GEOMETRY_USAGE_SYSMEM
-
-#define GEOMETRY_INIT(pScreen, pGeometry, _type, _usage, _size)		  \
-    {									  \
-	(pGeometry)->type      = _type;					  \
-	(pGeometry)->usage     = _usage;				  \
-	(pGeometry)->dataType  = DEFAULT_GEOMETRY_DATA_TYPE;		  \
-	(pGeometry)->usage     = _usage;				  \
-	(pGeometry)->size      = 0;					  \
-	(pGeometry)->endOffset = 0;					  \
-	(pGeometry)->data      = (pointer) 0;				  \
-	(pGeometry)->buffer    = NULL;					  \
-	(pGeometry)->broken    = FALSE;					  \
-	(pGeometry)->xOff      = 0;					  \
-	(pGeometry)->yOff      = 0;					  \
-	(pGeometry)->array     = NULL;					  \
-	(pGeometry)->first     = 0;					  \
-	(pGeometry)->count     = 0;					  \
-	if (_type == GLITZ_GEOMETRY_TYPE_VERTEX)			  \
-	{								  \
-	    (pGeometry)->width = 2;					  \
-	    (pGeometry)->f.vertex.type =				  \
-		xglGeometryDataTypes[(pGeometry)->dataType].type;	  \
-	    (pGeometry)->f.vertex.bytes_per_vertex = (pGeometry)->width * \
-		xglGeometryDataTypes[(pGeometry)->dataType].size;	  \
-	    (pGeometry)->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS;	  \
-	    (pGeometry)->f.vertex.attributes = 0;			  \
-	    (pGeometry)->f.vertex.src.type = GLITZ_DATA_TYPE_FLOAT;	  \
-	    (pGeometry)->f.vertex.src.size = GLITZ_COORDINATE_SIZE_X;	  \
-	    (pGeometry)->f.vertex.src.offset = 0;			  \
-	    (pGeometry)->f.vertex.mask.type = GLITZ_DATA_TYPE_FLOAT;	  \
-	    (pGeometry)->f.vertex.mask.size = GLITZ_COORDINATE_SIZE_X;	  \
-	    (pGeometry)->f.vertex.mask.offset = 0;			  \
-	}								  \
-	else								  \
-	{								  \
-	    (pGeometry)->width = 0;					  \
-	    (pGeometry)->f.bitmap.scanline_order =			  \
-		GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;			  \
-	    (pGeometry)->f.bitmap.bytes_per_line = 0;			  \
-	    (pGeometry)->f.bitmap.pad = GLYPHPADBYTES;			  \
-	}								  \
-	if (_size)							  \
-	    xglGeometryResize (pScreen, pGeometry, _size);		  \
-    }
-
-#define GEOMETRY_UNINIT(pGeometry)			    \
-    {							    \
-	if ((pGeometry)->array)				    \
-	    glitz_multi_array_destroy ((pGeometry)->array); \
-	if ((pGeometry)->buffer)			    \
-	    glitz_buffer_destroy ((pGeometry)->buffer);     \
-	if ((pGeometry)->data)				    \
-	    xfree ((pGeometry)->data);			    \
-    }
-
-#define GEOMETRY_SET_BUFFER(pGeometry, _buffer)		\
-    {							\
-	glitz_buffer_reference (_buffer);		\
-	if ((pGeometry)->buffer)			\
-	    glitz_buffer_destroy ((pGeometry)->buffer); \
-	(pGeometry)->buffer = _buffer;			\
-    }
-
-#define GEOMETRY_SET_MULTI_ARRAY(pGeometry, _array)	    \
-    {							    \
-	glitz_multi_array_reference (_array);		    \
-	if ((pGeometry)->array)				    \
-	    glitz_multi_array_destroy ((pGeometry)->array); \
-	(pGeometry)->array = _array;			    \
-    }
-
-#define GEOMETRY_RESIZE(pScreen, pGeometry, size) \
-    xglGeometryResize (pScreen, pGeometry, size)
-
-#define GEOMETRY_SET_TRANSLATE(pGeometry, _x, _y) \
-    {						  \
-	(pGeometry)->xOff = (_x) << 16;		  \
-	(pGeometry)->yOff = (_y) << 16;		  \
-    }
-
-#define GEOMETRY_TRANSLATE(pGeometry, tx, ty) \
-    {				              \
-	(pGeometry)->xOff += (tx) << 16;      \
-	(pGeometry)->yOff += (ty) << 16;      \
-    }
-
-#define GEOMETRY_TRANSLATE_FIXED(pGeometry, ftx, fty) \
-    {						      \
-	(pGeometry)->xOff += (ftx);		      \
-	(pGeometry)->yOff += (fty);		      \
-    }
-
-#define GEOMETRY_SET_VERTEX_PRIMITIVE(pGeometry, _primitive) \
-    (pGeometry)->f.vertex.primitive = _primitive
-
-#define GEOMETRY_SET_VERTEX_DATA_TYPE(pGeometry, _type)		       \
-    {								       \
-	(pGeometry)->dataType = _type;				       \
-	(pGeometry)->f.vertex.type = xglGeometryDataTypes[_type].type; \
-	(pGeometry)->f.vertex.bytes_per_vertex = (pGeometry)->width *  \
-	    xglGeometryDataTypes[_type].size;			       \
-    }
-
-#define GEOMETRY_ADD_BOX(pScreen, pGeometry, pBox, nBox) \
-    xglGeometryAddBox (pScreen, pGeometry, pBox, nBox,	 \
-		       (pGeometry)->endOffset)
-
-#define GEOMETRY_ADD_REGION_AT(pScreen, pGeometry, pRegion, offset) \
-     xglGeometryAddBox (pScreen, pGeometry,			    \
-			REGION_RECTS (pRegion),			    \
-			REGION_NUM_RECTS (pRegion),		    \
-			offset)
-
-#define GEOMETRY_ADD_REGION(pScreen, pGeometry, pRegion) \
-    xglGeometryAddBox (pScreen, pGeometry,		 \
-		       REGION_RECTS (pRegion),		 \
-		       REGION_NUM_RECTS (pRegion),	 \
-		       (pGeometry)->endOffset)
-
-#define GEOMETRY_ADD_SPAN(pScreen, pGeometry, ppt, pwidth, n) \
-    xglGeometryAddSpan (pScreen, pGeometry, ppt, pwidth, n,   \
-			(pGeometry)->endOffset)
-
-#define GEOMETRY_ADD_LINE(pScreen, pGeometry, loop, mode, npt, ppt) \
-    xglGeometryAddLine (pScreen, pGeometry, loop, mode, npt, ppt,   \
-			(pGeometry)->endOffset)
-
-#define GEOMETRY_ADD_SEGMENT(pScreen, pGeometry, nsegInit, pSegInit) \
-    xglGeometryAddSegment (pScreen, pGeometry, nsegInit, pSegInit,   \
-			   (pGeometry)->endOffset)
-
-#define GEOMETRY_FOR_GLYPH(pScreen, pGeometry, nGlyph, ppciInit, pglyphBase) \
-    xglGeometryForGlyph (pScreen, pGeometry, nGlyph, ppciInit, pglyphBase);
-
-#define GEOMETRY_ADD_TRAPEZOID(pScreen, pGeometry, pTrap, nTrap) \
-    xglGeometryAddTrapezoid (pScreen, pGeometry, pTrap, nTrap,	 \
-			     (pGeometry)->endOffset)
-
-#define GEOMETRY_ADD_TRAP(pScreen, pGeometry, pTrap, nTrap) \
-    xglGeometryAddTrap (pScreen, pGeometry, pTrap, nTrap,   \
-			(pGeometry)->endOffset)
-
-#define GEOMETRY_GET_FORMAT(pGeometry, format) \
-    xglGeometryGetFormat (pGeometry, format)
-
-#define GEOMETRY_ENABLE(pGeometry, surface) \
-    xglSetGeometry (pGeometry, surface)
-
-#define GEOMETRY_DISABLE(surface)				       \
-    glitz_set_geometry (surface, GLITZ_GEOMETRY_TYPE_NONE, NULL, NULL)
-
-void
-xglGeometryResize (ScreenPtr	  pScreen,
-		   xglGeometryPtr pGeometry,
-		   int		  size);
-
-void
-xglGeometryAddBox (ScreenPtr	  pScreen,
-		   xglGeometryPtr pGeometry,
-		   BoxPtr	  pBox,
-		   int		  nBox,
-		   int		  offset);
-
-void
-xglGeometryAddSpan (ScreenPtr	   pScreen,
-		    xglGeometryPtr pGeometry,
-		    DDXPointPtr	   ppt,
-		    int		   *pwidth,
-		    int		   n,
-		    int		   offset);
-
-void
-xglGeometryAddLine (ScreenPtr	   pScreen,
-		    xglGeometryPtr pGeometry,
-		    int		   loop,
-		    int		   mode,
-		    int		   npt,
-		    DDXPointPtr    ppt,
-		    int		   offset);
-
-void
-xglGeometryAddSegment (ScreenPtr      pScreen,
-		       xglGeometryPtr pGeometry,
-		       int	      nsegInit,
-		       xSegment       *pSegInit,
-		       int	      offset);
-
-void
-xglGeometryForGlyph (ScreenPtr	    pScreen,
-		     xglGeometryPtr pGeometry,
-		     unsigned int   nGlyph,
-		     CharInfoPtr    *ppciInit,
-		     pointer	    pglyphBase);
-
-void
-xglGeometryAddTrapezoid (ScreenPtr	pScreen,
-			 xglGeometryPtr pGeometry,
-			 xTrapezoid	*pTrap,
-			 int		nTrap,
-			 int		offset);
-
-void
-xglGeometryAddTrap (ScreenPtr	   pScreen,
-		    xglGeometryPtr pGeometry,
-		    xTrap	   *pTrap,
-		    int		   nTrap,
-		    int		   offset);
-
-xglGeometryPtr
-xglGetScratchGeometryWithSize (ScreenPtr pScreen,
-			       int	 size);
-
-xglGeometryPtr
-xglGetScratchVertexGeometryWithType (ScreenPtr pScreen,
-				     int       type,
-				     int       count);
-
-xglGeometryPtr
-xglGetScratchVertexGeometry (ScreenPtr pScreen,
-			     int       count);
-
-Bool
-xglSetGeometry (xglGeometryPtr	pGeometry,
-		glitz_surface_t *surface);
-
-
-/* xglpixmap.c */
-
-#define XGL_PIXMAP_USAGE_HINT_STREAM_DRAW  1
-#define XGL_PIXMAP_USAGE_HINT_STREAM_READ  2
-#define XGL_PIXMAP_USAGE_HINT_STREAM_COPY  3
-#define XGL_PIXMAP_USAGE_HINT_STATIC_DRAW  4
-#define XGL_PIXMAP_USAGE_HINT_STATIC_READ  5
-#define XGL_PIXMAP_USAGE_HINT_STATIC_COPY  6
-#define XGL_PIXMAP_USAGE_HINT_DYNAMIC_DRAW 7
-#define XGL_PIXMAP_USAGE_HINT_DYNAMIC_READ 8
-#define XGL_PIXMAP_USAGE_HINT_DYNAMIC_COPY 9
-
-#define XGL_PIXMAP_USAGE_HINT_DEFAULT XGL_PIXMAP_USAGE_HINT_STREAM_DRAW
-
-PixmapPtr
-xglCreatePixmap (ScreenPtr  pScreen,
-		 int	    width,
-		 int	    height,
-		 int	    depth);
-
-void
-xglFiniPixmap (PixmapPtr pPixmap);
-
-Bool
-xglDestroyPixmap (PixmapPtr pPixmap);
-
-Bool
-xglModifyPixmapHeader (PixmapPtr pPixmap,
-		       int	 width,
-		       int	 height,
-		       int	 depth,
-		       int	 bitsPerPixel,
-		       int	 devKind,
-		       pointer	 pPixData);
-
-void
-xglSetPixmapVisual (PixmapPtr    pPixmap,
-		    xglVisualPtr pVisual);
-
-RegionPtr
-xglPixmapToRegion (PixmapPtr pPixmap);
-
-xglGeometryPtr
-xglPixmapToGeometry (PixmapPtr pPixmap,
-		     int       xOff,
-		     int       yOff);
-
-Bool
-xglCreatePixmapSurface (PixmapPtr pPixmap);
-
-Bool
-xglAllocatePixmapBits (PixmapPtr pPixmap, int hint);
-
-Bool
-xglMapPixmapBits (PixmapPtr pPixmap);
-
-Bool
-xglUnmapPixmapBits (PixmapPtr pPixmap);
-
-Bool
-xglCheckPixmapSize (PixmapPtr		 pPixmap,
-		    xglSizeConstraintPtr pSize);
-
-void
-xglEnablePixmapAccel (PixmapPtr	      pPixmap,
-		      xglAccelInfoPtr pAccel);
-
-Bool
-xglPixmapSurfaceInit (PixmapPtr     pPixmap,
-		      unsigned long features,
-		      int           width,
-		      int           height);
-
-Bool
-xglPixmapCreateDamage (PixmapPtr pPixmap);
-
-/* xglsync.c */
-
-Bool
-xglSyncBits (DrawablePtr pDrawable,
-	     BoxPtr	 pExtents);
-
-void
-xglSyncDamageBoxBits (DrawablePtr pDrawable);
-
-Bool
-xglSyncSurface (DrawablePtr pDrawable);
-
-Bool
-xglPrepareTarget (DrawablePtr pDrawable);
-
-void
-xglAddSurfaceDamage (DrawablePtr pDrawable,
-		     RegionPtr   pRegion);
-
-void
-xglAddCurrentSurfaceDamage (DrawablePtr pDrawable);
-
-void
-xglAddBitDamage (DrawablePtr pDrawable,
-		 RegionPtr   pRegion);
-
-void
-xglAddCurrentBitDamage (DrawablePtr pDrawable);
-
-
-/* xglsolid.c */
-
-Bool
-xglSolid (DrawablePtr	   pDrawable,
-	  glitz_operator_t op,
-	  glitz_surface_t  *solid,
-	  xglGeometryPtr   pGeometry,
-	  int		   x,
-	  int		   y,
-	  int		   width,
-	  int		   height,
-	  BoxPtr	   pBox,
-	  int		   nBox);
-
-Bool
-xglSolidGlyph (DrawablePtr  pDrawable,
-	       GCPtr	    pGC,
-	       int	    x,
-	       int	    y,
-	       unsigned int nGlyph,
-	       CharInfoPtr  *ppci,
-	       pointer      pglyphBase);
-
-
-/* xgltile.c */
-
-xglGeometryPtr
-xglTiledBoxGeometry (PixmapPtr pTile,
-		     int       tileX,
-		     int       tileY,
-		     BoxPtr    pBox,
-		     int       nBox);
-
-Bool
-xglTile (DrawablePtr	  pDrawable,
-	 glitz_operator_t op,
-	 PixmapPtr	  pTile,
-	 int		  tileX,
-	 int		  tileY,
-	 xglGeometryPtr	  pGeometry,
-	 int		  x,
-	 int		  y,
-	 int		  width,
-	 int		  height,
-	 BoxPtr		  pBox,
-	 int		  nBox);
-
-
-/* xglcopy.c */
-
-Bool
-xglCopy (DrawablePtr pSrc,
-	 DrawablePtr pDst,
-	 int	     dx,
-	 int	     dy,
-	 BoxPtr	     pBox,
-	 int	     nBox);
-
-void
-xglCopyProc (DrawablePtr pSrc,
-	     DrawablePtr pDst,
-	     GCPtr	 pGC,
-	     BoxPtr	 pBox,
-	     int	 nBox,
-	     int	 dx,
-	     int	 dy,
-	     Bool	 reverse,
-	     Bool	 upsidedown,
-	     Pixel	 bitplane,
-	     void	 *closure);
-
-
-/* xglfill.c */
-
-Bool
-xglFill (DrawablePtr	pDrawable,
-	 GCPtr		pGC,
-	 xglGeometryPtr pGeometry,
-	 int		x,
-	 int		y,
-	 int		width,
-	 int		height,
-	 BoxPtr		pBox,
-	 int		nBox);
-
-void
-xglFillSpan (DrawablePtr pDrawable,
-	     GCPtr	 pGC,
-	     int	 n,
-	     DDXPointPtr ppt,
-	     int	 *pwidth);
-
-void
-xglFillRect (DrawablePtr pDrawable,
-	     GCPtr	 pGC,
-	     int	 nrect,
-	     xRectangle  *prect);
-
-Bool
-xglFillLine (DrawablePtr pDrawable,
-	     GCPtr       pGC,
-	     int	 mode,
-	     int	 npt,
-	     DDXPointPtr ppt);
-
-Bool
-xglFillSegment (DrawablePtr pDrawable,
-		GCPtr	    pGC,
-		int	    nsegInit,
-		xSegment    *pSegInit);
-
-Bool
-xglFillGlyph (DrawablePtr  pDrawable,
-	      GCPtr	   pGC,
-	      int	   x,
-	      int	   y,
-	      unsigned int nglyph,
-	      CharInfoPtr  *ppciInit,
-	      pointer      pglyphBase);
-
-
-/* xglwindow.c */
-
-Bool
-xglCreateWindow (WindowPtr pWin);
-
-Bool
-xglDestroyWindow (WindowPtr pWin);
-
-Bool
-xglChangeWindowAttributes (WindowPtr	 pWin,
-			   unsigned long mask);
-
-void
-xglCopyWindow (WindowPtr   pWin,
-	       DDXPointRec ptOldOrg,
-	       RegionPtr   prgnSrc);
-
-PixmapPtr
-xglGetWindowPixmap (WindowPtr pWin);
-
-void
-xglSetWindowPixmap (WindowPtr pWin,
-		    PixmapPtr pPixmap);
-
-
-/* xglget.c */
-
-void
-xglGetImage (DrawablePtr   pDrawable,
-	     int	   x,
-	     int	   y,
-	     int	   w,
-	     int	   h,
-	     unsigned int  format,
-	     unsigned long planeMask,
-	     char	   *d);
-
-void
-xglGetSpans (DrawablePtr pDrawable,
-	     int	 wMax,
-	     DDXPointPtr ppt,
-	     int	 *pwidth,
-	     int	 nspans,
-	     char	 *pchardstStart);
-
-
-/* xglgc.c */
-
-Bool
-xglCreateGC (GCPtr pGC);
-
-void
-xglDestroyGC (GCPtr pGC);
-
-void
-xglValidateGC (GCPtr	     pGC,
-	       unsigned long changes,
-	       DrawablePtr   pDrawable);
-
-void
-xglFillSpans  (DrawablePtr pDrawable,
-	       GCPtr	   pGC,
-	       int	   nspans,
-	       DDXPointPtr ppt,
-	       int	   *pwidth,
-	       int	   fSorted);
-
-void
-xglSetSpans (DrawablePtr pDrawable,
-	     GCPtr	 pGC,
-	     char	 *psrc,
-	     DDXPointPtr ppt,
-	     int	 *pwidth,
-	     int	 nspans,
-	     int	 fSorted);
-
-void
-xglPutImage (DrawablePtr pDrawable,
-	     GCPtr	 pGC,
-	     int	 depth,
-	     int	 x,
-	     int	 y,
-	     int	 w,
-	     int	 h,
-	     int	 leftPad,
-	     int	 format,
-	     char	 *bits);
-
-RegionPtr
-xglCopyArea (DrawablePtr pSrc,
-	     DrawablePtr pDst,
-	     GCPtr	 pGC,
-	     int	 srcX,
-	     int	 srcY,
-	     int	 w,
-	     int	 h,
-	     int	 dstX,
-	     int	 dstY);
-
-RegionPtr
-xglCopyPlane (DrawablePtr   pSrc,
-	      DrawablePtr   pDst,
-	      GCPtr	    pGC,
-	      int	    srcX,
-	      int	    srcY,
-	      int	    w,
-	      int	    h,
-	      int	    dstX,
-	      int	    dstY,
-	      unsigned long bitPlane);
-
-void
-xglPolyPoint (DrawablePtr pDrawable,
-	      GCPtr       pGC,
-	      int	  mode,
-	      int	  npt,
-	      DDXPointPtr pptInit);
-
-void
-xglPolylines (DrawablePtr pDrawable,
-	      GCPtr       pGC,
-	      int	  mode,
-	      int	  npt,
-	      DDXPointPtr ppt);
-
-void
-xglPolySegment (DrawablePtr pDrawable,
-		GCPtr	    pGC,
-		int	    nsegInit,
-		xSegment    *pSegInit);
-
-void
-xglPolyArc (DrawablePtr pDrawable,
-	    GCPtr	pGC,
-	    int		narcs,
-	    xArc	*pArcs);
-
-void
-xglPolyFillRect (DrawablePtr pDrawable,
-		 GCPtr	     pGC,
-		 int	     nrect,
-		 xRectangle  *prect);
-
-void
-xglPolyFillArc (DrawablePtr pDrawable,
-		GCPtr	    pGC,
-		int	    narcs,
-		xArc	    *pArcs);
-
-void
-xglImageGlyphBlt (DrawablePtr  pDrawable,
-		  GCPtr	       pGC,
-		  int	       x,
-		  int	       y,
-		  unsigned int nglyph,
-		  CharInfoPtr  *ppci,
-		  pointer      pglyphBase);
-
-void
-xglPolyGlyphBlt (DrawablePtr  pDrawable,
-		 GCPtr	      pGC,
-		 int	      x,
-		 int	      y,
-		 unsigned int nglyph,
-		 CharInfoPtr  *ppci,
-		 pointer      pglyphBase);
-void
-xglPushPixels (GCPtr	   pGC,
-	       PixmapPtr   pBitmap,
-	       DrawablePtr pDrawable,
-	       int	   w,
-	       int	   h,
-	       int	   x,
-	       int	   y);
-
-
-#ifdef MITSHM
-
-/* xglshm.c */
-
-void
-xglShmPutImage (DrawablePtr  pDrawable,
-		GCPtr	     pGC,
-		int	     depth,
-		unsigned int format,
-		int	     w,
-		int	     h,
-		int	     sx,
-		int	     sy,
-		int	     sw,
-		int	     sh,
-		int	     dx,
-		int	     dy,
-		char	     *data);
-
-#endif
-
-
-#ifdef RENDER
-
-/* xglpict.c */
-
-void
-xglComposite (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
-xglAddTriangles (PicturePtr pDst,
-		 INT16	    xOff,
-		 INT16	    yOff,
-		 int	    ntri,
-		 xTriangle  *tris);
-
-void
-xglChangePicture (PicturePtr pPicture,
-		  Mask	     mask);
-
-int
-xglChangePictureTransform (PicturePtr    pPicture,
-			   PictTransform *transform);
-
-int
-xglChangePictureFilter (PicturePtr pPicture,
-			int	   filter,
-			xFixed	   *params,
-			int	   nparams);
-
-PicturePtr
-xglCreateDevicePicture (pointer data);
-
-Bool
-xglSyncPicture (ScreenPtr  pScreen,
-		PicturePtr pPicture,
-		INT16	   x,
-		INT16	   y,
-		CARD16	   width,
-		CARD16	   height,
-		INT16	   *xOff,
-		INT16	   *yOff);
-
-Bool
-xglPictureInit (ScreenPtr pScreen);
-
-void
-xglPictureClipExtents (PicturePtr pPicture,
-		       BoxPtr     extents);
-
-
-/* xglcompose.c */
-
-Bool
-xglCompositeGeneral (CARD8	     op,
-		     PicturePtr	     pSrc,
-		     PicturePtr	     pMask,
-		     PicturePtr	     pDst,
-		     xglGeometryPtr  pGeometry,
-		     INT16	     xSrc,
-		     INT16	     ySrc,
-		     INT16	     xMask,
-		     INT16	     yMask,
-		     INT16	     xDst,
-		     INT16	     yDst,
-		     CARD16	     width,
-		     CARD16	     height);
-
-
-/* xglglyph.c */
-
-Bool
-xglRealizeGlyph (ScreenPtr pScreen,
-		 GlyphPtr  pGlyph);
-
-void
-xglUnrealizeGlyph (ScreenPtr pScreen,
-		   GlyphPtr  pGlyph);
-
-Bool
-xglInitGlyphCache (xglGlyphCachePtr pCache,
-		   ScreenPtr	    pScreen,
-		   PictFormatPtr    format);
-
-void
-xglFiniGlyphCache (xglGlyphCachePtr pCache);
-
-void
-xglGlyphs (CARD8	 op,
-	   PicturePtr	 pSrc,
-	   PicturePtr	 pDst,
-	   PictFormatPtr maskFormat,
-	   INT16	 xSrc,
-	   INT16	 ySrc,
-	   int		 nlist,
-	   GlyphListPtr	 list,
-	   GlyphPtr	 *glyphs);
-
-
-/* xgltrap.c */
-
-void
-xglTrapezoids (CARD8	     op,
-	       PicturePtr    pSrc,
-	       PicturePtr    pDst,
-	       PictFormatPtr maskFormat,
-	       INT16	     xSrc,
-	       INT16	     ySrc,
-	       int	     nTrap,
-	       xTrapezoid    *traps);
-
-void
-xglAddTraps (PicturePtr pDst,
-	     INT16	xOff,
-	     INT16	yOff,
-	     int	nTrap,
-	     xTrap	*traps);
-
-#endif
-
-#ifdef XGL_MODULAR
-
-/* xglloader.c */
-
-typedef struct _xglSymbol {
-    void       **ptr;
-    const char *name;
-} xglSymbolRec, *xglSymbolPtr;
-
-void *
-xglLoadModule (const char *name,
-	       int	  flag);
-
-void
-xglUnloadModule (void *handle);
-
-Bool
-xglLookupSymbols (void         *handle,
-		  xglSymbolPtr sym,
-		  int	       nSym);
-
-#endif
-
-
-/* xglxv.c */
-
-#ifdef XV
-
-Bool
-xglXvScreenInit (ScreenPtr pScreen);
-
-#endif
-
-
-/* xglhash.c */
-
-typedef struct _xglHashTable *xglHashTablePtr;
-
-Bool
-xglLoadHashFuncs (void *handle);
-
-xglHashTablePtr
-xglNewHashTable (void);
-
-void
-xglDeleteHashTable (xglHashTablePtr pTable);
-
-void *
-xglHashLookup (const xglHashTablePtr pTable,
-	       unsigned int	     key);
-
-void
-xglHashInsert (xglHashTablePtr pTable,
-	       unsigned int    key,
-	       void	       *data);
-
-void
-xglHashRemove (xglHashTablePtr pTable,
-	       unsigned int    key);
-
-unsigned int
-xglHashFirstEntry (xglHashTablePtr pTable);
-
-unsigned int
-xglHashNextEntry (const xglHashTablePtr pTable,
-		  unsigned int		key);
-
-unsigned int
-xglHashFindFreeKeyBlock (xglHashTablePtr pTable,
-			 unsigned int	 numKeys);
-
-#endif /* _XGL_H_ */
diff --git a/hw/xgl/xglarea.c b/hw/xgl/xglarea.c
deleted file mode 100644
index cdf652d..0000000
--- a/hw/xgl/xglarea.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright © 2005 Novell, Inc.
- *
- * 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
- * Novell, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * Novell, Inc. makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL NOVELL, INC. 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-
-static Bool
-xglAreaMoveIn (xglAreaPtr pArea,
-	       pointer	  closure)
-{
-    pArea->closure = closure;
-    pArea->state   = xglAreaOccupied;
-
-    return (*pArea->pRoot->funcs->MoveIn) (pArea, closure);
-}
-
-static void
-xglAreaMoveOut (xglAreaPtr pArea)
-{
-    (*pArea->pRoot->funcs->MoveOut) (pArea, pArea->closure);
-
-    pArea->closure = (pointer) 0;
-    pArea->state   = xglAreaAvailable;
-}
-
-static xglAreaPtr
-xglAreaCreate (xglRootAreaPtr pRoot,
-	       int	      level,
-	       int	      x,
-	       int	      y,
-	       int	      width,
-	       int	      height)
-{
-    xglAreaPtr pArea;
-    int	       n = 4;
-
-    pArea = xalloc (sizeof (xglAreaRec) + pRoot->devPrivateSize);
-    if (!pArea)
-	return NULL;
-
-    pArea->level   = level;
-    pArea->x	   = x;
-    pArea->y	   = y;
-    pArea->width   = width;
-    pArea->height  = height;
-    pArea->pRoot   = pRoot;
-    pArea->closure = (pointer) 0;
-    pArea->state   = xglAreaAvailable;
-
-    while (n--)
-	pArea->pArea[n] = NULL;
-
-    if (pRoot->devPrivateSize)
-	pArea->devPrivate.ptr = pArea + 1;
-    else
-	pArea->devPrivate.ptr = (pointer) 0;
-
-    if (!(*pArea->pRoot->funcs->Create) (pArea))
-    {
-	free (pArea);
-	return NULL;
-    }
-
-    return pArea;
-}
-
-static void
-xglAreaDestroy (xglAreaPtr pArea)
-{
-    if (!pArea)
-	return;
-
-    if (pArea->state == xglAreaOccupied)
-    {
-	xglAreaMoveOut (pArea);
-    }
-    else
-    {
-	int n = 4;
-
-	while (n--)
-	    xglAreaDestroy (pArea->pArea[n]);
-    }
-
-    xfree (pArea);
-}
-
-static xglAreaPtr
-xglAreaGetTopScoredSubArea (xglAreaPtr pArea)
-{
-    if (!pArea)
-	return NULL;
-
-    switch (pArea->state) {
-    case xglAreaOccupied:
-	return pArea;
-    case xglAreaAvailable:
-	break;
-    case xglAreaDivided: {
-	xglAreaPtr tmp, top = NULL;
-	int	   i;
-
-	for (i = 0; i < 4; i++)
-	{
-	    tmp = xglAreaGetTopScoredSubArea (pArea->pArea[i]);
-	    if (tmp && top)
-	    {
-		if ((*pArea->pRoot->funcs->CompareScore) (tmp,
-							  tmp->closure,
-							  top->closure) > 0)
-		    top = tmp;
-	    }
-	    else if (tmp)
-	    {
-		top = tmp;
-	    }
-	}
-	return top;
-    }
-    }
-
-    return NULL;
-}
-
-static Bool
-xglAreaFind (xglAreaPtr pArea,
-	     int	width,
-	     int	height,
-	     Bool	kickOut,
-	     pointer	closure)
-{
-    if (pArea->width < width || pArea->height < height)
-	return FALSE;
-
-    switch (pArea->state) {
-    case xglAreaOccupied:
-	if (kickOut)
-	{
-	    if ((*pArea->pRoot->funcs->CompareScore) (pArea,
-						      pArea->closure,
-						      closure) >= 0)
-		return FALSE;
-
-	    xglAreaMoveOut (pArea);
-	} else
-	    return FALSE;
-
-    /* fall-through */
-    case xglAreaAvailable:
-    {
-	if (pArea->level == pArea->pRoot->maxLevel ||
-	    (pArea->width == width && pArea->height == height))
-	{
-	    if (xglAreaMoveIn (pArea, closure))
-		return TRUE;
-	}
-	else
-	{
-	    int dx[4], dy[4], w[4], h[4], i;
-
-	    dx[0] = dx[2] = dy[0] = dy[1] = 0;
-
-	    w[0] = w[2] = dx[1] = dx[3] = width;
-	    h[0] = h[1] = dy[2] = dy[3] = height;
-
-	    w[1] = w[3] = pArea->width - width;
-	    h[2] = h[3] = pArea->height - height;
-
-	    for (i = 0; i < 2; i++)
-	    {
-		if (w[i])
-		    pArea->pArea[i] =
-			xglAreaCreate (pArea->pRoot,
-				       pArea->level + 1,
-				       pArea->x + dx[i],
-				       pArea->y + dy[i],
-				       w[i], h[i]);
-	    }
-
-	    for (; i < 4; i++)
-	    {
-		if (w[i] && h[i])
-		    pArea->pArea[i] =
-			xglAreaCreate (pArea->pRoot,
-				       pArea->level + 1,
-				       pArea->x + dx[i],
-				       pArea->y + dy[i],
-				       w[i], h[i]);
-	    }
-
-	    pArea->state = xglAreaDivided;
-
-	    if (xglAreaFind (pArea->pArea[0], width, height, kickOut, closure))
-		return TRUE;
-	}
-    } break;
-    case xglAreaDivided:
-    {
-	xglAreaPtr topArea;
-	int	   i, rejected = FALSE;
-
-	for (i = 0; i < 4; i++)
-	{
-	    if (pArea->pArea[i])
-	    {
-		if (pArea->pArea[i]->width >= width &&
-		    pArea->pArea[i]->height >= height)
-		{
-		    if (xglFindArea (pArea->pArea[i], width, height, kickOut,
-				     closure))
-			return TRUE;
-
-		    rejected = TRUE;
-		}
-	    }
-	}
-
-	if (rejected)
-	    return FALSE;
-
-	topArea = xglAreaGetTopScoredSubArea (pArea);
-	if (topArea)
-	{
-	    if (kickOut)
-	    {
-		if ((*pArea->pRoot->funcs->CompareScore) (topArea,
-							  topArea->closure,
-							  closure) >= 0)
-		    return FALSE;
-	    } else
-		return FALSE;
-	}
-
-	for (i = 0; i < 4; i++)
-	{
-	    xglAreaDestroy (pArea->pArea[i]);
-	    pArea->pArea[i] = NULL;
-	}
-
-	pArea->closure = (pointer) 0;
-	pArea->state   = xglAreaAvailable;
-	if (xglFindArea (pArea, width, height, TRUE, closure))
-	    return TRUE;
-
-    } break;
-    }
-
-    return FALSE;
-}
-
-Bool
-xglRootAreaInit (xglRootAreaPtr	    pRoot,
-		 int		    maxLevel,
-		 int		    width,
-		 int		    height,
-		 int		    devPrivateSize,
-		 xglAreaFuncsPtr    funcs,
-		 pointer	    closure)
-{
-    pRoot->maxLevel	  = maxLevel;
-    pRoot->funcs	  = funcs;
-    pRoot->devPrivateSize = devPrivateSize;
-    pRoot->closure	  = closure;
-
-    pRoot->pArea = xglAreaCreate (pRoot, 0, 0, 0, width, height);
-    if (!pRoot->pArea)
-	return FALSE;
-
-    return TRUE;
-}
-
-void
-xglRootAreaFini (xglRootAreaPtr pRoot)
-{
-    xglAreaDestroy (pRoot->pArea);
-}
-
-void
-xglLeaveArea (xglAreaPtr pArea)
-{
-    xglAreaMoveOut (pArea);
-}
-
-void
-xglWithdrawArea (xglAreaPtr pArea)
-{
-    pArea->closure = NULL;
-    pArea->state   = xglAreaAvailable;
-}
-
-Bool
-xglFindArea (xglAreaPtr pArea,
-	     int	width,
-	     int	height,
-	     Bool	kickOut,
-	     pointer	closure)
-{
-    if (width < 1 || height < 0)
-	return FALSE;
-
-    return xglAreaFind (pArea, width, height, kickOut, closure);
-}
diff --git a/hw/xgl/xglcmap.c b/hw/xgl/xglcmap.c
deleted file mode 100644
index 99593eb..0000000
--- a/hw/xgl/xglcmap.c
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-#include "colormapst.h"
-#include "micmap.h"
-#include "fb.h"
-
-xglPixelFormatRec xglPixelFormats[] = {
-    {
-	8, 8,
-	{
-	    8,
-	    0x000000ff,
-	    0x00000000,
-	    0x00000000,
-	    0x00000000
-	}
-    }, {
-	15, 5,
-	{
-	    16,
-	    0x00000000,
-	    0x00007c00,
-	    0x000003e0,
-	    0x0000001f
-	}
-    }, {
-	16, 6,
-	{
-	    16,
-	    0x00000000,
-	    0x0000f800,
-	    0x000007e0,
-	    0x0000001f
-	}
-    }, {
-	24, 8,
-	{
-	    32,
-	    0x00000000,
-	    0x00ff0000,
-	    0x0000ff00,
-	    0x000000ff
-	}
-    }, {
-	32, 8,
-	{
-	    32,
-	    0xff000000,
-	    0x00ff0000,
-	    0x0000ff00,
-	    0x000000ff
-	}
-    }
-};
-
-xglVisualPtr xglVisuals = NULL;
-
-int
-xglNumPixelFormats(void)
-{
-    return (sizeof (xglPixelFormats) / sizeof(xglPixelFormats[0]));
-}
-
-void
-xglSetVisualTypes (int depth,
-		   int visuals,
-		   int redSize,
-		   int greenSize,
-		   int blueSize)
-{
-    xglPixelFormatPtr pBestFormat = 0;
-    int		      i, rs, gs, bs, diff, bestDiff = 0;
-
-    for (i = 0; i < xglNumPixelFormats(); i++)
-    {
-	if (xglPixelFormats[i].depth == depth)
-	{
-	    if (visuals)
-	    {
-		rs = Ones (xglPixelFormats[i].masks.red_mask);
-		gs = Ones (xglPixelFormats[i].masks.green_mask);
-		bs = Ones (xglPixelFormats[i].masks.blue_mask);
-
-		if (redSize   >= rs &&
-		    greenSize >= gs &&
-		    blueSize  >= bs)
-		{
-		    diff = (redSize - rs) + (greenSize - gs) + (blueSize - bs);
-		    if (pBestFormat)
-		    {
-			if (diff < bestDiff)
-			{
-			    pBestFormat = &xglPixelFormats[i];
-			    bestDiff = diff;
-			}
-		    }
-		    else
-		    {
-			pBestFormat = &xglPixelFormats[i];
-			bestDiff = diff;
-		    }
-		}
-	    }
-	    else
-	    {
-		pBestFormat = &xglPixelFormats[i];
-		break;
-	    }
-	}
-    }
-
-    if (pBestFormat)
-    {
-	xglVisualPtr new, *prev, v;
-
-	new = xalloc (sizeof (xglVisualRec));
-	if (!new)
-	    return;
-
-	new->next = 0;
-
-	new->format.surface  = 0;
-	new->format.drawable = 0;
-	new->pPixel	     = pBestFormat;
-	new->vid	     = 0;
-
-	for (prev = &xglVisuals; (v = *prev); prev = &v->next);
-	*prev = new;
-    }
-}
-
-Bool
-xglHasVisualTypes (xglVisualPtr pVisual,
-		   int		depth)
-{
-    xglVisualPtr v;
-
-    for (v = pVisual; v; v = v->next)
-	if (v->pPixel->depth == depth)
-	    return TRUE;
-
-    return FALSE;
-}
-
-glitz_format_t *
-xglFindBestSurfaceFormat (ScreenPtr         pScreen,
-			  xglPixelFormatPtr pPixel)
-{
-    glitz_format_t templ, *format, *best = 0;
-    unsigned int   mask;
-    unsigned short rs, gs, bs, as;
-    int	           i = 0;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    rs = Ones (pPixel->masks.red_mask);
-    gs = Ones (pPixel->masks.green_mask);
-    bs = Ones (pPixel->masks.blue_mask);
-    as = Ones (pPixel->masks.alpha_mask);
-
-    templ.color.fourcc = GLITZ_FOURCC_RGB;
-    mask = GLITZ_FORMAT_FOURCC_MASK;
-
-    do {
-	format = glitz_find_format (pScreenPriv->drawable, mask, &templ, i++);
-	if (format)
-	{
-	    if (format->color.red_size   >= rs &&
-		format->color.green_size >= gs &&
-		format->color.blue_size  >= bs &&
-		format->color.alpha_size >= as)
-	    {
-		if (best)
-		{
-		    if (((format->color.red_size   - rs) +
-			 (format->color.green_size - gs) +
-			 (format->color.blue_size  - bs)) <
-			((best->color.red_size   - rs) +
-			 (best->color.green_size - gs) +
-			 (best->color.blue_size  - bs)))
-			best = format;
-		}
-		else
-		{
-		    best = format;
-		}
-	    }
-	}
-    } while (format);
-
-    return best;
-}
-
-static Bool
-xglInitVisual (ScreenPtr	 pScreen,
-	       xglVisualPtr	 pVisual,
-	       xglPixelFormatPtr pPixel,
-	       VisualID		 vid)
-{
-    glitz_format_t *format;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    format = xglFindBestSurfaceFormat (pScreen, pPixel);
-    if (format)
-    {
-	glitz_drawable_format_t templ;
-	unsigned long	        mask;
-
-	templ.color        = format->color;
-	templ.depth_size   = 0;
-	templ.stencil_size = 0;
-	templ.doublebuffer = 0;
-	templ.samples      = 1;
-
-	mask =
-	    GLITZ_FORMAT_FOURCC_MASK       |
-	    GLITZ_FORMAT_RED_SIZE_MASK     |
-	    GLITZ_FORMAT_GREEN_SIZE_MASK   |
-	    GLITZ_FORMAT_BLUE_SIZE_MASK    |
-	    GLITZ_FORMAT_ALPHA_SIZE_MASK   |
-	    GLITZ_FORMAT_DEPTH_SIZE_MASK   |
-	    GLITZ_FORMAT_STENCIL_SIZE_MASK |
-	    GLITZ_FORMAT_DOUBLEBUFFER_MASK |
-	    GLITZ_FORMAT_SAMPLES_MASK;
-
-	pVisual->next	 = 0;
-	pVisual->vid	 = vid;
-	pVisual->pPixel	 = pPixel;
-	pVisual->pbuffer = FALSE;
-
-	pVisual->format.surface  = format;
-	pVisual->format.drawable =
-	    glitz_find_drawable_format (pScreenPriv->drawable,
-					mask, &templ, 0);
-
-	return TRUE;
-    }
-
-    return FALSE;
-}
-
-static Bool
-xglInitPbufferVisual (ScreenPtr	        pScreen,
-		      xglVisualPtr	pVisual,
-		      xglPixelFormatPtr pPixel,
-		      VisualID		vid)
-{
-    glitz_format_t *format;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    format = xglFindBestSurfaceFormat (pScreen, pPixel);
-    if (format)
-    {
-	glitz_drawable_format_t templ, *screenFormat;
-	unsigned long	        mask;
-
-	/* use same drawable format as screen for pbuffers */
-	screenFormat = glitz_drawable_get_format (pScreenPriv->drawable);
-	templ.id = screenFormat->id;
-
-	templ.color   = format->color;
-	templ.samples = 1;
-
-	mask =
-	    GLITZ_FORMAT_ID_MASK	 |
-	    GLITZ_FORMAT_FOURCC_MASK     |
-	    GLITZ_FORMAT_RED_SIZE_MASK   |
-	    GLITZ_FORMAT_GREEN_SIZE_MASK |
-	    GLITZ_FORMAT_BLUE_SIZE_MASK  |
-	    GLITZ_FORMAT_SAMPLES_MASK;
-
-	pVisual->next	 = 0;
-	pVisual->vid	 = vid;
-	pVisual->pPixel	 = pPixel;
-	pVisual->pbuffer = TRUE;
-
-	pVisual->format.surface  = format;
-	pVisual->format.drawable =
-	    glitz_find_pbuffer_format (pScreenPriv->drawable,
-				       mask, &templ, 0);
-
-	if (pVisual->format.drawable)
-	    return TRUE;
-    }
-
-    return FALSE;
-}
-
-void
-xglInitVisuals (ScreenPtr pScreen)
-{
-    xglVisualPtr pVisual, v, new, *prev;
-    int		 i;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    for (i = 0; i < pScreen->numVisuals; i++)
-    {
-	for (pVisual = xglVisuals; pVisual; pVisual = pVisual->next)
-	    if (pVisual->pPixel->depth == pScreen->visuals[i].nplanes)
-		break;
-
-	if (pVisual)
-	{
-	    new = xalloc (sizeof (xglVisualRec));
-	    if (new)
-	    {
-		if (xglInitVisual (pScreen, new, pVisual->pPixel,
-				   pScreen->visuals[i].vid))
-		{
-		    new->next = 0;
-
-		    prev = &pScreenPriv->pVisual;
-		    while ((v = *prev))
-			prev = &v->next;
-
-		    *prev = new;
-		}
-		else
-		{
-		    xfree (new);
-		}
-	    }
-
-	    new = xalloc (sizeof (xglVisualRec));
-	    if (new)
-	    {
-		if (xglInitPbufferVisual (pScreen, new, pVisual->pPixel,
-					  pScreen->visuals[i].vid))
-		{
-		    new->next = 0;
-
-		    prev = &pScreenPriv->pVisual;
-		    while ((v = *prev))
-			prev = &v->next;
-
-		    *prev = new;
-		}
-		else
-		{
-		    xfree (new);
-		}
-	    }
-	}
-    }
-
-    /* Add additional Xgl visuals for pixmap formats */
-    for (i = 0; i < screenInfo.numPixmapFormats; i++)
-    {
-	if (!xglHasVisualTypes (pScreenPriv->pVisual,
-				screenInfo.formats[i].depth))
-	{
-	    for (v = xglVisuals; v; v = v->next)
-		if (v->pPixel->depth == screenInfo.formats[i].depth)
-		    break;
-
-	    if (v)
-	    {
-		new = xalloc (sizeof (xglVisualRec));
-		if (new)
-		{
-		    if (xglInitVisual (pScreen, new, v->pPixel, 0))
-		    {
-			new->next = 0;
-
-			prev = &pScreenPriv->pVisual;
-			while ((v = *prev))
-			    prev = &v->next;
-
-			*prev = new;
-		    }
-		    else
-		    {
-			xfree (new);
-		    }
-		}
-	    }
-	}
-    }
-}
-
-xglVisualPtr
-xglFindVisualWithDepth (ScreenPtr pScreen,
-			int       depth)
-{
-    xglVisualPtr v;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    for (v = pScreenPriv->pVisual; v; v = v->next)
-    {
-	if (v->pPixel->depth == depth)
-	    return v;
-    }
-
-    return 0;
-}
-
-xglVisualPtr
-xglFindVisualWithId (ScreenPtr pScreen,
-		     int       vid)
-{
-    xglVisualPtr v;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    for (v = pScreenPriv->pVisual; v; v = v->next)
-    {
-	if (v->vid == vid)
-	    return v;
-    }
-
-    return 0;
-}
-
-void
-xglClearVisualTypes (void)
-{
-    xglVisualPtr v;
-
-    while (xglVisuals)
-    {
-	v = xglVisuals;
-	xglVisuals = v->next;
-	xfree (v);
-    }
-
-    miClearVisualTypes ();
-}
diff --git a/hw/xgl/xglcompose.c b/hw/xgl/xglcompose.c
deleted file mode 100644
index f6725ac..0000000
--- a/hw/xgl/xglcompose.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-
-#include "glxserver.h"
-#include "glapi.h"
-#include "glthread.h"
-#include "dispatch.h"
-#include "xgl.h"
-
-#ifdef RENDER
-
-static glitz_operator_t xglOperators[] = {
-    GLITZ_OPERATOR_CLEAR,
-    GLITZ_OPERATOR_SRC,
-    GLITZ_OPERATOR_DST,
-    GLITZ_OPERATOR_OVER,
-    GLITZ_OPERATOR_OVER_REVERSE,
-    GLITZ_OPERATOR_IN,
-    GLITZ_OPERATOR_IN_REVERSE,
-    GLITZ_OPERATOR_OUT,
-    GLITZ_OPERATOR_OUT_REVERSE,
-    GLITZ_OPERATOR_ATOP,
-    GLITZ_OPERATOR_ATOP_REVERSE,
-    GLITZ_OPERATOR_XOR,
-    GLITZ_OPERATOR_ADD
-};
-
-#define NUM_XGL_OPERATORS			       \
-    (sizeof (xglOperators) / sizeof (xglOperators[0]))
-
-#define XGL_OPERATOR(op) (xglOperators[op])
-
-#define XGL_GET_SOURCE_PICTURE(pPicture, outSurface)			   \
-    (outSurface) = ((pPicture)->pDrawable) ?				   \
-	XGL_GET_PIXMAP_PRIV ((PixmapPtr) (pPicture)->pDrawable)->surface : \
-	(glitz_surface_t *) (pPicture)->pSourcePict->source.devPrivate.ptr
-
-Bool
-xglCompositeGeneral (CARD8	     op,
-		     PicturePtr	     pSrc,
-		     PicturePtr	     pMask,
-		     PicturePtr	     pDst,
-		     xglGeometryPtr  pGeometry,
-		     INT16	     xSrc,
-		     INT16	     ySrc,
-		     INT16	     xMask,
-		     INT16	     yMask,
-		     INT16	     xDst,
-		     INT16	     yDst,
-		     CARD16	     width,
-		     CARD16	     height)
-{
-    ScreenPtr	    pScreen = pDst->pDrawable->pScreen;
-    INT16	    xOff, yOff;
-    glitz_surface_t *src, *mask = NULL, *dst;
-    int		    dstXoff, dstYoff;
-    RegionRec	    region;
-    BoxPtr	    pBox, pExt;
-    int		    nBox;
-
-    if (pDst->alphaMap)
-	return FALSE;
-
-    if (op >= NUM_XGL_OPERATORS)
-	return FALSE;
-
-    if (pSrc->pDrawable)
-    {
-	if (pSrc->pDrawable->type != DRAWABLE_PIXMAP)
-	    return FALSE;
-
-	if (pSrc->pDrawable->bitsPerPixel == 1)
-	    return FALSE;
-    }
-
-    if (pMask)
-    {
-       if (pMask->pDrawable)
-       {
-	   if (pMask->pDrawable->type != DRAWABLE_PIXMAP)
-	       return FALSE;
-
-	   if (pSrc->pDrawable == pMask->pDrawable && pSrc != pMask)
-	       return FALSE;
-       }
-    }
-
-    if (!xglPrepareTarget (pDst->pDrawable))
-	return FALSE;
-
-    if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
-				   xSrc, ySrc, xMask, yMask,
-				   xDst, yDst, width, height))
-	return TRUE;
-
-    pBox = REGION_RECTS (&region);
-    nBox = REGION_NUM_RECTS (&region);
-    pExt = REGION_EXTENTS (pScreen, &region);
-
-    XGL_GET_DRAWABLE (pDst->pDrawable, dst, dstXoff, dstYoff);
-
-    if (!xglSyncPicture (pScreen, pSrc,
-			 pExt->x1 + xSrc - xDst,
-			 pExt->y1 + ySrc - yDst,
-			 pExt->x2 - pExt->x1,
-			 pExt->y2 - pExt->y1,
-			 &xOff, &yOff))
-    {
-	REGION_UNINIT (pScreen, &region);
-	return FALSE;
-    }
-
-    xSrc -= xOff;
-    ySrc -= yOff;
-
-    XGL_GET_SOURCE_PICTURE (pSrc, src);
-
-    if (pMask)
-    {
-	/* bitmap as mask */
-	if (pMask->pDrawable && pMask->pDrawable->bitsPerPixel == 1)
-	{
-	    if (pGeometry)
-	    {
-		REGION_UNINIT (pScreen, &region);
-		return FALSE;
-	    }
-
-	    pGeometry = xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable,
-					     xDst - xMask,
-					     yDst - yMask);
-	    if (!pGeometry)
-	    {
-		REGION_UNINIT (pScreen, &region);
-		return FALSE;
-	    }
-	}
-	else
-	{
-	    if (!xglSyncPicture (pScreen, pMask,
-				 pExt->x1 + xMask - xDst,
-				 pExt->y1 + yMask - yDst,
-				 pExt->x2 - pExt->x1,
-				 pExt->y2 - pExt->y1,
-				 &xOff, &yOff))
-	    {
-		REGION_UNINIT (pScreen, &region);
-		return FALSE;
-	    }
-
-	    xMask -= xOff;
-	    yMask -= yOff;
-
-	    XGL_GET_SOURCE_PICTURE (pMask, mask);
-	}
-    }
-
-    if (!pGeometry)
-    {
-	if (pSrc->pDrawable && !pSrc->transform &&
-	    pSrc->filter != PictFilterConvolution)
-	{
-	    if (pSrc->repeatType == RepeatNormal)
-	    {
-		XGL_PIXMAP_PRIV ((PixmapPtr) pSrc->pDrawable);
-
-		/* tile */
-		if (!pPixmapPriv->acceleratedTile)
-		{
-		    pGeometry =
-			xglTiledBoxGeometry ((PixmapPtr) pSrc->pDrawable,
-					     xSrc - xDst, ySrc - yDst,
-					     pBox, nBox);
-		    if (!pGeometry)
-		    {
-			REGION_UNINIT (pScreen, &region);
-			return FALSE;
-		    }
-
-		    pBox = pExt;
-		    nBox = 1;
-		}
-	    }
-	    else
-	    {
-		/* copy */
-		if (op == PictOpSrc && !mask)
-		{
-		    if (xglCopy (pSrc->pDrawable,
-				 pDst->pDrawable,
-				 xSrc - xDst,
-				 ySrc - yDst,
-				 pBox,
-				 nBox))
-		    {
-			REGION_UNINIT (pScreen, &region);
-			return TRUE;
-		    }
-		}
-	    }
-	}
-
-	if (nBox > 1)
-	{
-	    pGeometry = xglGetScratchVertexGeometry (pScreen, 4 * nBox);
-
-	    GEOMETRY_ADD_BOX (pScreen, pGeometry, pBox, nBox);
-
-	    pBox = pExt;
-	}
-
-	xSrc += pBox->x1 - xDst;
-	ySrc += pBox->y1 - yDst;
-
-	if (pMask)
-	{
-	    xMask += pBox->x1 - xDst;
-	    yMask += pBox->y1 - yDst;
-	}
-
-	xDst = pBox->x1;
-	yDst = pBox->y1;
-
-	width  = pBox->x2 - pBox->x1;
-	height = pBox->y2 - pBox->y1;
-    }
-    else
-    {
-	glitz_surface_set_clip_region (dst,
-				       dstXoff, dstYoff,
-				       (glitz_box_t *) pBox, nBox);
-    }
-
-    if (pGeometry)
-    {
-	GEOMETRY_TRANSLATE (pGeometry, dstXoff, dstYoff);
-
-	if (!GEOMETRY_ENABLE (pGeometry, dst))
-	{
-	    REGION_UNINIT (pScreen, &region);
-	    return FALSE;
-	}
-    }
-    else
-	GEOMETRY_DISABLE (dst);
-
-    __glXleaveServer(FALSE);
-    glitz_composite (XGL_OPERATOR (op),
-		     src, mask, dst,
-		     xSrc, ySrc,
-		     xMask, yMask,
-		     xDst + dstXoff, yDst + dstYoff,
-		     width, height);
-    __glXenterServer(FALSE);
-
-    glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
-
-    REGION_UNINIT (pScreen, &region);
-
-    if (glitz_surface_get_status (dst))
-	return FALSE;
-
-    return TRUE;
-}
-
-#endif
diff --git a/hw/xgl/xglcopy.c b/hw/xgl/xglcopy.c
deleted file mode 100644
index b0cf82f..0000000
--- a/hw/xgl/xglcopy.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-#include "glxserver.h"
-#include "glapi.h"
-#include "glthread.h"
-#include "dispatch.h"
-
-
-#include "xgl.h"
-#include "fb.h"
-
-Bool
-xglCopy (DrawablePtr pSrc,
-	 DrawablePtr pDst,
-	 int	     dx,
-	 int	     dy,
-	 BoxPtr	     pBox,
-	 int	     nBox)
-{
-    glitz_surface_t *src, *dst;
-    int		    srcXoff, srcYoff;
-    int		    dstXoff, dstYoff;
-
-    XGL_DRAWABLE_PIXMAP (pDst);
-
-    if (!nBox)
-	return TRUE;
-
-    if (xglPrepareTarget (pDst))
-    {
-	if (!xglSyncSurface (pSrc))
-	    return FALSE;
-    }
-    else
-    {
-	if (!xglPrepareTarget (pSrc))
-	    return FALSE;
-
-	if (!xglSyncSurface (pDst))
-	    return FALSE;
-    }
-
-    XGL_GET_DRAWABLE (pSrc, src, srcXoff, srcYoff);
-    XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff);
-
-    glitz_surface_set_clip_region (dst,
-				   dstXoff, dstYoff,
-				   (glitz_box_t *) pBox, nBox);
-
-    __glXleaveServer(FALSE);
-    glitz_copy_area (src,
-		     dst,
-		     srcXoff + dx,
-		     srcYoff + dy,
-		     pPixmap->drawable.width - dstXoff,
-		     pPixmap->drawable.height - dstYoff,
-		     dstXoff,
-		     dstYoff);
-    __glXenterServer(FALSE);
-
-    glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
-
-    if (glitz_surface_get_status (dst))
-	return FALSE;
-
-    return TRUE;
-}
-
-void
-xglCopyProc (DrawablePtr pSrc,
-	     DrawablePtr pDst,
-	     GCPtr	 pGC,
-	     BoxPtr	 pBox,
-	     int	 nBox,
-	     int	 dx,
-	     int	 dy,
-	     Bool	 reverse,
-	     Bool	 upsidedown,
-	     Pixel	 bitplane,
-	     void	 *closure)
-{
-    BoxPtr pSrcBox = (BoxPtr) closure;
-
-    if (!xglCopy (pSrc, pDst, dx, dy, pBox, nBox))
-    {
-	RegionRec region;
-
-	XGL_DRAWABLE_PIXMAP (pDst);
-	XGL_PIXMAP_PRIV (pPixmap);
-
-	if (!xglSyncBits (pSrc, pSrcBox))
-	    FatalError (XGL_SW_FAILURE_STRING);
-
-	if (!xglMapPixmapBits (pPixmap))
-	    FatalError (XGL_SW_FAILURE_STRING);
-
-	fbCopyNtoN (pSrc, pDst, pGC,
-		    pBox, nBox,
-		    dx, dy,
-		    reverse, upsidedown, bitplane,
-		    (void *) 0);
-
-	pPixmapPriv->damageBox = miEmptyBox;
-
-	while (nBox--)
-	{
-	    REGION_INIT (pDst->pScreen, &region, pBox, 1);
-	    xglAddSurfaceDamage (pDst, &region);
-	    REGION_UNINIT (pDst->pScreen, &region);
-
-	    pBox++;
-	}
-    } else
-	xglAddCurrentBitDamage (pDst);
-}
diff --git a/hw/xgl/xglfill.c b/hw/xgl/xglfill.c
deleted file mode 100644
index a2957b2..0000000
--- a/hw/xgl/xglfill.c
+++ /dev/null
@@ -1,774 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-#include "gcstruct.h"
-#include "fb.h"
-
-Bool
-xglFill (DrawablePtr	pDrawable,
-	 GCPtr		pGC,
-	 xglGeometryPtr pGeometry,
-	 int		x,
-	 int		y,
-	 int		width,
-	 int		height,
-	 BoxPtr		pBox,
-	 int		nBox)
-{
-    XGL_GC_PRIV (pGC);
-
-    switch (pGC->fillStyle) {
-    case FillSolid:
-	if (xglSolid (pDrawable,
-		      pGCPriv->op, pGCPriv->fg,
-		      pGeometry,
-		      x, y,
-		      width, height,
-		      pBox, nBox))
-	    return TRUE;
-	break;
-    case FillStippled:
-    case FillOpaqueStippled:
-	break;
-    case FillTiled:
-	if (xglTile (pDrawable,
-		     pGCPriv->op, pGC->tile.pixmap,
-		     -(pGC->patOrg.x + pDrawable->x),
-		     -(pGC->patOrg.y + pDrawable->y),
-		     pGeometry,
-		     x, y,
-		     width, height,
-		     pBox, nBox))
-	    return TRUE;
-	break;
-    }
-
-    return FALSE;
-}
-
-static void
-xglFillBox (DrawablePtr pDrawable,
-	    GCPtr	pGC,
-	    int		x,
-	    int		y,
-	    int		width,
-	    int		height,
-	    BoxPtr	pBox,
-	    int		nBox)
-{
-    if (!nBox)
-	return;
-
-    if (!xglFill (pDrawable, pGC, NULL, x, y, width, height, pBox, nBox))
-    {
-	RegionRec region;
-
-	XGL_DRAWABLE_PIXMAP (pDrawable);
-	XGL_PIXMAP_PRIV (pPixmap);
-
-	if (!xglMapPixmapBits (pPixmap))
-	    FatalError (XGL_SW_FAILURE_STRING);
-
-	switch (pGC->fillStyle) {
-	case FillSolid:
-	    break;
-	case FillStippled:
-	case FillOpaqueStippled:
-	    if (!xglSyncBits (&pGC->stipple->drawable, NullBox))
-		FatalError (XGL_SW_FAILURE_STRING);
-	    break;
-	case FillTiled:
-	    if (!xglSyncBits (&pGC->tile.pixmap->drawable, NullBox))
-		FatalError (XGL_SW_FAILURE_STRING);
-	    break;
-	}
-
-	pPixmapPriv->damageBox = miEmptyBox;
-
-	while (nBox--)
-	{
-	    fbFill (pDrawable, pGC,
-		    pBox->x1, pBox->y1,
-		    pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
-
-	    REGION_INIT (pDrawable->pScreen, &region, pBox, 1);
-	    xglAddSurfaceDamage (pDrawable, &region);
-	    REGION_UNINIT (pDrawable->pScreen, &region);
-
-	    pBox++;
-	}
-    } else
-	xglAddCurrentBitDamage (pDrawable);
-}
-
-#define N_STACK_BOX 1024
-
-static BoxPtr
-xglMoreBoxes (BoxPtr stackBox,
-	      BoxPtr heapBox,
-	      int    nBoxes)
-{
-    Bool stack = !heapBox;
-
-    heapBox = xrealloc (heapBox, sizeof (BoxRec) * nBoxes);
-    if (!heapBox)
-	return NULL;
-
-    if (stack)
-	memcpy (heapBox, stackBox, sizeof (BoxRec) * N_STACK_BOX);
-
-    return heapBox;
-}
-
-#define ADD_BOX(pBox, nBox, stackBox, heapBox, size, box)	\
-    {								\
-	if ((nBox) == (size))					\
-	{							\
-	    (size) *= 2;					\
-	    (heapBox) = xglMoreBoxes (stackBox, heapBox, size);	\
-	    if (heapBox)					\
-	    {							\
-		(pBox) = (heapBox) + (nBox);			\
-		*(pBox)++ = (box);				\
-		(nBox)++;					\
-	    }							\
-	}							\
-	else							\
-	{							\
-	    *(pBox)++ = (box);					\
-	    (nBox)++;						\
-	}							\
-    }
-
-void
-xglFillRect (DrawablePtr pDrawable,
-	     GCPtr	 pGC,
-	     int	 nrect,
-	     xRectangle  *prect)
-{
-    RegionPtr pClip = pGC->pCompositeClip;
-    BoxPtr    pClipBox;
-    BoxPtr    pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
-    int	      fullX1, fullX2, fullY1, fullY2;
-    BoxRec    part, full;
-    BoxPtr    heapBox = NULL;
-    BoxRec    stackBox[N_STACK_BOX];
-    int       size = N_STACK_BOX;
-    BoxPtr    pBox = stackBox;
-    int	      nClip, nBox = 0;
-
-    while (nrect--)
-    {
-	fullX1 = prect->x + pDrawable->x;
-	fullY1 = prect->y + pDrawable->y;
-	fullX2 = fullX1 + (int) prect->width;
-	fullY2 = fullY1 + (int) prect->height;
-
-	prect++;
-
-	if (fullX1 < pExtent->x1)
-	    fullX1 = pExtent->x1;
-	if (fullY1 < pExtent->y1)
-	    fullY1 = pExtent->y1;
-	if (fullX2 > pExtent->x2)
-	    fullX2 = pExtent->x2;
-	if (fullY2 > pExtent->y2)
-	    fullY2 = pExtent->y2;
-
-	full.x1 = fullX1;
-	full.y1 = fullY1;
-	full.x2 = fullX2;
-	full.y2 = fullY2;
-
-	if (full.x1 >= full.x2 || full.y1 >= full.y2)
-	    continue;
-
-	nClip = REGION_NUM_RECTS (pClip);
-	if (nClip == 1)
-	{
-	    ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
-	}
-	else
-	{
-	    pClipBox = REGION_RECTS (pClip);
-	    while (nClip--)
-	    {
-		part = *pClipBox++;
-
-		if (part.x1 < full.x1)
-		    part.x1 = full.x1;
-		if (part.y1 < full.y1)
-		    part.y1 = full.y1;
-		if (part.x2 > full.x2)
-		    part.x2 = full.x2;
-		if (part.y2 > full.y2)
-		    part.y2 = full.y2;
-
-		if (part.x1 < part.x2 && part.y1 < part.y2)
-		    ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
-	    }
-	}
-    }
-
-    xglFillBox (pDrawable, pGC,
-		pExtent->x1, pExtent->y1,
-		pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
-		(heapBox) ? heapBox : stackBox, nBox);
-
-    if (heapBox)
-	xfree (heapBox);
-}
-
-void
-xglFillSpan (DrawablePtr pDrawable,
-	     GCPtr	 pGC,
-	     int	 n,
-	     DDXPointPtr ppt,
-	     int	 *pwidth)
-{
-    RegionPtr pClip = pGC->pCompositeClip;
-    BoxPtr    pClipBox;
-    BoxPtr    pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
-    int	      fullX1, fullX2, fullY1, fullY2;
-    BoxRec    part, full;
-    BoxPtr    heapBox = NULL;
-    BoxRec    stackBox[N_STACK_BOX];
-    int       size = N_STACK_BOX;
-    BoxPtr    pBox = stackBox;
-    int	      nClip, nBox = 0;
-
-    while (n--)
-    {
-	fullX1 = ppt->x;
-	fullY1 = ppt->y;
-	fullX2 = fullX1 + *pwidth;
-	fullY2 = fullY1 + 1;
-
-	pwidth++;
-	ppt++;
-
-	if (fullX1 < pExtent->x1)
-	    fullX1 = pExtent->x1;
-	if (fullY1 < pExtent->y1)
-	    fullY1 = pExtent->y1;
-	if (fullX2 > pExtent->x2)
-	    fullX2 = pExtent->x2;
-	if (fullY2 > pExtent->y2)
-	    fullY2 = pExtent->y2;
-
-	full.x1 = fullX1;
-	full.y1 = fullY1;
-	full.x2 = fullX2;
-	full.y2 = fullY2;
-
-	if (full.x1 >= full.x2 || full.y1 >= full.y2)
-	    continue;
-
-	nClip = REGION_NUM_RECTS (pClip);
-	if (nClip == 1)
-	{
-	    ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
-	}
-	else
-	{
-	    pClipBox = REGION_RECTS (pClip);
-	    while (nClip--)
-	    {
-		part = *pClipBox++;
-
-		if (part.x1 < full.x1)
-		    part.x1 = full.x1;
-		if (part.y1 < full.y1)
-		    part.y1 = full.y1;
-		if (part.x2 > full.x2)
-		    part.x2 = full.x2;
-		if (part.y2 > full.y2)
-		    part.y2 = full.y2;
-
-		if (part.x1 < part.x2 && part.y1 < part.y2)
-		    ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
-	    }
-	}
-    }
-
-    xglFillBox (pDrawable, pGC,
-		pExtent->x1, pExtent->y1,
-		pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
-		(heapBox) ? heapBox : stackBox, nBox);
-
-    if (heapBox)
-	xfree (heapBox);
-}
-
-Bool
-xglFillLine (DrawablePtr pDrawable,
-	     GCPtr       pGC,
-	     int	 mode,
-	     int	 npt,
-	     DDXPointPtr ppt)
-{
-    RegionPtr	   pClip = pGC->pCompositeClip;
-    BoxPtr	   pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
-    Bool	   coincidentEndpoints = FALSE;
-    Bool	   horizontalAndVertical = TRUE;
-    DDXPointPtr    pptTmp;
-    int		   nptTmp;
-    DDXPointRec    pt;
-    xglGeometryPtr pGeometry;
-
-    XGL_SCREEN_PRIV (pGC->pScreen);
-
-    if (npt < 2)
-	return TRUE;
-
-    pt = *ppt;
-
-    nptTmp = npt - 1;
-    pptTmp = ppt + 1;
-
-    if (mode == CoordModePrevious)
-    {
-	while (nptTmp--)
-	{
-	    if (pptTmp->x && pptTmp->y)
-		horizontalAndVertical = FALSE;
-
-	    pt.x += pptTmp->x;
-	    pt.y += pptTmp->y;
-
-	    pptTmp++;
-	}
-
-	if (pt.x == ppt->x && pt.y == ppt->y)
-	    coincidentEndpoints = TRUE;
-    }
-    else
-    {
-	while (nptTmp--)
-	{
-	    if (pptTmp->x != pt.x && pptTmp->y != pt.y)
-	    {
-		horizontalAndVertical = FALSE;
-		break;
-	    }
-
-	    pt = *pptTmp++;
-	}
-
-	if (ppt[npt - 1].x == ppt->x && ppt[npt - 1].y == ppt->y)
-	    coincidentEndpoints = TRUE;
-    }
-
-    if (horizontalAndVertical)
-    {
-	BoxPtr pClipBox;
-	int    fullX1, fullX2, fullY1, fullY2;
-	BoxRec part, full;
-	BoxPtr heapBox = NULL;
-	BoxRec stackBox[N_STACK_BOX];
-	int    size = N_STACK_BOX;
-	BoxPtr pBox = stackBox;
-	int    nClip, nBox = 0;
-	int    dx, dy;
-
-	pt = *ppt;
-
-	ppt++;
-	npt--;
-
-	while (npt--)
-	{
-	    if (mode == CoordModePrevious)
-	    {
-		dx = ppt->x;
-		dy = ppt->y;
-	    }
-	    else
-	    {
-		dx = ppt->x - pt.x;
-		dy = ppt->y - pt.y;
-	    }
-
-	    if (dx)
-	    {
-		if (dx > 0)
-		{
-		    fullX1 = pt.x + pDrawable->x;
-
-		    if (npt || coincidentEndpoints)
-			fullX2 = fullX1 + dx;
-		    else
-			fullX2 = fullX1 + dx + 1;
-		}
-		else
-		{
-		    fullX2 = pt.x + pDrawable->x + 1;
-
-		    if (npt || coincidentEndpoints)
-			fullX1 = fullX2 + dx;
-		    else
-			fullX1 = fullX2 + dx - 1;
-		}
-
-		fullY1 = pt.y + pDrawable->y;
-		fullY2 = fullY1 + 1;
-	    }
-	    else
-	    {
-		if (dy > 0)
-		{
-		    fullY1 = pt.y + pDrawable->y;
-
-		    if (npt || coincidentEndpoints)
-			fullY2 = fullY1 + dy;
-		    else
-			fullY2 = fullY1 + dy + 1;
-		}
-		else
-		{
-		    fullY2 = pt.y + pDrawable->y + 1;
-
-		    if (npt || coincidentEndpoints)
-			fullY1 = fullY2 + dy;
-		    else
-			fullY1 = fullY2 + dy - 1;
-		}
-
-		fullX1 = pt.x + pDrawable->x;
-		fullX2 = fullX1 + 1;
-	    }
-
-	    pt.x += dx;
-	    pt.y += dy;
-
-	    ppt++;
-
-	    if (fullX1 < pExtent->x1)
-		fullX1 = pExtent->x1;
-	    if (fullY1 < pExtent->y1)
-		fullY1 = pExtent->y1;
-	    if (fullX2 > pExtent->x2)
-		fullX2 = pExtent->x2;
-	    if (fullY2 > pExtent->y2)
-		fullY2 = pExtent->y2;
-
-	    full.x1 = fullX1;
-	    full.y1 = fullY1;
-	    full.x2 = fullX2;
-	    full.y2 = fullY2;
-
-	    if (full.x1 >= full.x2 || full.y1 >= full.y2)
-		continue;
-
-	    nClip = REGION_NUM_RECTS (pClip);
-	    if (nClip == 1)
-	    {
-		ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
-	    }
-	    else
-	    {
-		pClipBox = REGION_RECTS (pClip);
-		while (nClip--)
-		{
-		    part = *pClipBox++;
-
-		    if (part.x1 < full.x1)
-			part.x1 = full.x1;
-		    if (part.y1 < full.y1)
-			part.y1 = full.y1;
-		    if (part.x2 > full.x2)
-			part.x2 = full.x2;
-		    if (part.y2 > full.y2)
-			part.y2 = full.y2;
-
-		    if (part.x1 < part.x2 && part.y1 < part.y2)
-			ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
-		}
-	    }
-	}
-
-	xglFillBox (pDrawable, pGC,
-		    pExtent->x1, pExtent->y1,
-		    pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
-		    (heapBox) ? heapBox : stackBox, nBox);
-
-	if (heapBox)
-	    xfree (heapBox);
-
-	return TRUE;
-    }
-
-    if (!pScreenPriv->lines)
-	return FALSE;
-
-    if (coincidentEndpoints)
-	npt--;
-
-    pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, npt);
-
-    GEOMETRY_ADD_LINE (pGC->pScreen, pGeometry,
-		       coincidentEndpoints, mode, npt, ppt);
-
-    if (coincidentEndpoints)
-	GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINE_LOOP);
-    else
-	GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINE_STRIP);
-
-    /* Lines need a 0.5 translate */
-    GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15);
-
-    GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y);
-
-    pExtent = REGION_EXTENTS (pDrawable->pScreen, pGC->pCompositeClip);
-
-    if (xglFill (pDrawable, pGC, pGeometry,
-		 pExtent->x1, pExtent->y1,
-		 pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
-		 REGION_RECTS (pGC->pCompositeClip),
-		 REGION_NUM_RECTS (pGC->pCompositeClip)))
-    {
-	xglAddCurrentBitDamage (pDrawable);
-	return TRUE;
-    }
-
-    return FALSE;
-}
-
-Bool
-xglFillSegment (DrawablePtr pDrawable,
-		GCPtr	    pGC,
-		int	    nSegInit,
-		xSegment    *pSegInit)
-{
-    RegionPtr	   pClip = pGC->pCompositeClip;
-    BoxPtr	   pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
-    Bool	   horizontalAndVertical = TRUE;
-    xglGeometryPtr pGeometry;
-    xSegment	   *pSeg;
-    int		   nSeg;
-
-    XGL_SCREEN_PRIV (pGC->pScreen);
-
-    if (nSegInit < 1)
-	return TRUE;
-
-    pSeg = pSegInit;
-    nSeg = nSegInit;
-    while (nSeg--)
-    {
-	if (pSeg->x1 != pSeg->x2 && pSeg->y1 != pSeg->y2)
-	    horizontalAndVertical = FALSE;
-
-	pSeg++;
-    }
-
-    if (horizontalAndVertical)
-    {
-	BoxPtr pClipBox;
-	int    fullX1, fullX2, fullY1, fullY2;
-	BoxRec part, full;
-	BoxPtr heapBox = NULL;
-	BoxRec stackBox[N_STACK_BOX];
-	int    size = N_STACK_BOX;
-	BoxPtr pBox = stackBox;
-	int    nClip, nBox = 0;
-
-	while (nSegInit--)
-	{
-	    if (pSegInit->x1 != pSegInit->x2)
-	    {
-		if (pSegInit->x1 < pSegInit->x2)
-		{
-		    fullX1 = pSegInit->x1;
-		    fullX2 = pSegInit->x2;
-		    if (pGC->capStyle != CapNotLast)
-			fullX2++;
-		}
-		else
-		{
-		    fullX1 = pSegInit->x2;
-		    fullX2 = pSegInit->x1 + 1;
-		    if (pGC->capStyle == CapNotLast)
-			fullX1++;
-		}
-
-		fullX1 += pDrawable->x;
-		fullX2 += pDrawable->x;
-		fullY1  = pSegInit->y1 + pDrawable->y;
-		fullY2  = fullY1 + 1;
-	    }
-	    else
-	    {
-		if (pSegInit->y1 < pSegInit->y2)
-		{
-		    fullY1 = pSegInit->y1;
-		    fullY2 = pSegInit->y2;
-		    if (pGC->capStyle != CapNotLast)
-			fullY2++;
-		}
-		else
-		{
-		    fullY1 = pSegInit->y2;
-		    fullY2 = pSegInit->y1 + 1;
-		    if (pGC->capStyle == CapNotLast)
-			fullY1++;
-		}
-
-		fullY1 += pDrawable->y;
-		fullY2 += pDrawable->y;
-		fullX1  = pSegInit->x1 + pDrawable->x;
-		fullX2  = fullX1 + 1;
-	    }
-
-	    pSegInit++;
-
-	    if (fullX1 < pExtent->x1)
-		fullX1 = pExtent->x1;
-	    if (fullY1 < pExtent->y1)
-		fullY1 = pExtent->y1;
-	    if (fullX2 > pExtent->x2)
-		fullX2 = pExtent->x2;
-	    if (fullY2 > pExtent->y2)
-		fullY2 = pExtent->y2;
-
-	    full.x1 = fullX1;
-	    full.y1 = fullY1;
-	    full.x2 = fullX2;
-	    full.y2 = fullY2;
-
-	    if (full.x1 >= full.x2 || full.y1 >= full.y2)
-		continue;
-
-	    nClip = REGION_NUM_RECTS (pClip);
-	    if (nClip == 1)
-	    {
-		ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
-	    }
-	    else
-	    {
-		pClipBox = REGION_RECTS (pClip);
-		while (nClip--)
-		{
-		    part = *pClipBox++;
-
-		    if (part.x1 < full.x1)
-			part.x1 = full.x1;
-		    if (part.y1 < full.y1)
-			part.y1 = full.y1;
-		    if (part.x2 > full.x2)
-			part.x2 = full.x2;
-		    if (part.y2 > full.y2)
-			part.y2 = full.y2;
-
-		    if (part.x1 < part.x2 && part.y1 < part.y2)
-			ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
-		}
-	    }
-	}
-
-	xglFillBox (pDrawable, pGC,
-		    pExtent->x1, pExtent->y1,
-		    pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
-		    (heapBox) ? heapBox : stackBox, nBox);
-
-	if (heapBox)
-	    xfree (heapBox);
-
-	return TRUE;
-    }
-
-    if (!pScreenPriv->lines)
-	return FALSE;
-
-    pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, 2 * nSegInit);
-
-    GEOMETRY_ADD_SEGMENT (pGC->pScreen, pGeometry, nSegInit, pSegInit);
-
-    /* Line segments need 0.5 translate */
-    GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15);
-    GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINES);
-
-    GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y);
-
-    if (xglFill (pDrawable, pGC, pGeometry,
-		 pExtent->x1, pExtent->y1,
-		 pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
-		 REGION_RECTS (pGC->pCompositeClip),
-		 REGION_NUM_RECTS (pGC->pCompositeClip)))
-    {
-	xglAddCurrentBitDamage (pDrawable);
-	return TRUE;
-    }
-
-    return FALSE;
-}
-
-Bool
-xglFillGlyph (DrawablePtr  pDrawable,
-	      GCPtr	   pGC,
-	      int	   x,
-	      int	   y,
-	      unsigned int nGlyph,
-	      CharInfoPtr  *ppci,
-	      pointer      pglyphBase)
-{
-    BoxPtr	   pExtent;
-    xglGeometryRec geometry;
-
-    if (nGlyph < 1)
-	return TRUE;
-
-    pExtent = REGION_EXTENTS (pDrawable->pScreen, pGC->pCompositeClip);
-
-    x += pDrawable->x;
-    y += pDrawable->y;
-
-    GEOMETRY_INIT (pDrawable->pScreen, &geometry,
-		   GLITZ_GEOMETRY_TYPE_BITMAP,
-		   GEOMETRY_USAGE_SYSMEM, 0);
-
-    GEOMETRY_FOR_GLYPH (pDrawable->pScreen,
-			&geometry,
-			nGlyph,
-			ppci,
-			pglyphBase);
-
-    GEOMETRY_TRANSLATE (&geometry, x, y);
-
-    if (xglFill (pDrawable, pGC, &geometry,
-		 pExtent->x1, pExtent->y1,
-		 pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
-		 REGION_RECTS (pGC->pCompositeClip),
-		 REGION_NUM_RECTS (pGC->pCompositeClip)))
-    {
-	GEOMETRY_UNINIT (&geometry);
-	xglAddCurrentBitDamage (pDrawable);
-	return TRUE;
-    }
-
-    GEOMETRY_UNINIT (&geometry);
-    return FALSE;
-}
diff --git a/hw/xgl/xglgc.c b/hw/xgl/xglgc.c
deleted file mode 100644
index deb3982..0000000
--- a/hw/xgl/xglgc.c
+++ /dev/null
@@ -1,648 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-#include "fb.h"
-#include "gcstruct.h"
-#include "migc.h"
-
-#define XGL_GC_OP_FALLBACK_PROLOGUE(pDrawable) \
-    xglSyncDamageBoxBits (pDrawable);	       \
-    XGL_GC_UNWRAP (funcs);		       \
-    XGL_GC_UNWRAP (ops)
-
-#define XGL_GC_OP_FALLBACK_EPILOGUE(pDrawable)	  \
-    XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs); \
-    XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);	  \
-    xglAddCurrentSurfaceDamage (pDrawable)
-
-#define XGL_GC_FILL_OP_FALLBACK_PROLOGUE(pDrawable)		 \
-    switch (pGC->fillStyle) {					 \
-    case FillSolid:						 \
-	break;							 \
-    case FillStippled:						 \
-    case FillOpaqueStippled:					 \
-	if (!xglSyncBits (&pGC->stipple->drawable, NullBox))	 \
-	    FatalError (XGL_SW_FAILURE_STRING);			 \
-	break;							 \
-    case FillTiled:						 \
-	if (!xglSyncBits (&pGC->tile.pixmap->drawable, NullBox)) \
-	    FatalError (XGL_SW_FAILURE_STRING);			 \
-	break;							 \
-    }								 \
-    XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable)
-
-static const GCFuncs xglGCFuncs = {
-    xglValidateGC,
-    miChangeGC,
-    miCopyGC,
-    xglDestroyGC,
-    miChangeClip,
-    miDestroyClip,
-    miCopyClip
-};
-
-static const GCOps xglGCOps = {
-    xglFillSpans,
-    xglSetSpans,
-    xglPutImage,
-    xglCopyArea,
-    xglCopyPlane,
-    xglPolyPoint,
-    xglPolylines,
-    xglPolySegment,
-    miPolyRectangle,
-    xglPolyArc,
-    miFillPolygon,
-    xglPolyFillRect,
-    xglPolyFillArc,
-    miPolyText8,
-    miPolyText16,
-    miImageText8,
-    miImageText16,
-    xglImageGlyphBlt,
-    xglPolyGlyphBlt,
-    xglPushPixels
-#ifdef NEED_LINEHELPER
-    , NULL
-#endif
-};
-
-void
-xglFillSpans (DrawablePtr pDrawable,
-	      GCPtr	  pGC,
-	      int	  nspans,
-	      DDXPointPtr ppt,
-	      int	  *pwidth,
-	      int	  fSorted)
-{
-    XGL_GC_PRIV (pGC);
-
-    if (pGCPriv->flags || pGC->fillStyle == FillStippled)
-    {
-	XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
-	(*pGC->ops->FillSpans) (pDrawable, pGC, nspans, ppt, pwidth, fSorted);
-	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-    }
-    else
-    {
-	/* xglFillSpan handles fall-back */
-	xglFillSpan (pDrawable, pGC, nspans, ppt, pwidth);
-    }
-}
-
-void
-xglSetSpans (DrawablePtr pDrawable,
-	     GCPtr	 pGC,
-	     char	 *psrc,
-	     DDXPointPtr ppt,
-	     int	 *pwidth,
-	     int	 nspans,
-	     int	 fSorted)
-{
-    XGL_GC_PRIV (pGC);
-
-    XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
-    (*pGC->ops->SetSpans) (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
-    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-}
-
-void
-xglPutImage (DrawablePtr pDrawable,
-	     GCPtr	 pGC,
-	     int	 depth,
-	     int	 x,
-	     int	 y,
-	     int	 w,
-	     int	 h,
-	     int	 leftPad,
-	     int	 format,
-	     char	 *bits)
-{
-    XGL_GC_PRIV (pGC);
-
-    if (pGC->alu != GXcopy || (pGCPriv->flags & xglGCPlaneMaskFlag))
-    {
-	XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
-	(*pGC->ops->PutImage) (pDrawable, pGC, depth,
-			       x, y, w, h, leftPad, format, bits);
-	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-    }
-    else
-    {
-	RegionPtr pClip = pGC->pCompositeClip;
-	RegionRec region;
-	BoxRec	  box;
-
-	XGL_DRAWABLE_PIXMAP (pDrawable);
-
-	if (!xglMapPixmapBits (pPixmap))
-	    FatalError (XGL_SW_FAILURE_STRING);
-
-	XGL_GC_UNWRAP (funcs);
-	XGL_GC_UNWRAP (ops);
-
-	(*pGC->ops->PutImage) (pDrawable, pGC, depth,
-			       x, y, w, h, leftPad, format, bits);
-
-	XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
-	XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
-
-	box.x1 = pDrawable->x + x;
-	box.y1 = pDrawable->y + y;
-	box.x2 = box.x1 + w;
-	box.y2 = box.y1 + h;
-
-	REGION_INIT (pDrawable->pScreen, &region, &box, 1);
-	REGION_INTERSECT (pDrawable->pScreen, &region, pClip, &region);
-
-	xglAddSurfaceDamage (pDrawable, &region);
-
-	REGION_UNINIT (pDrawable->pScreen, &region);
-    }
-}
-
-RegionPtr
-xglCopyArea (DrawablePtr pSrc,
-	     DrawablePtr pDst,
-	     GCPtr	 pGC,
-	     int	 srcX,
-	     int	 srcY,
-	     int	 w,
-	     int	 h,
-	     int	 dstX,
-	     int	 dstY)
-{
-    RegionPtr pRegion;
-    BoxRec    box;
-
-    XGL_GC_PRIV (pGC);
-
-    box.x1 = pSrc->x + srcX;
-    box.y1 = pSrc->y + srcY;
-    box.x2 = box.x1 + w;
-    box.y2 = box.y1 + h;
-
-    if (pGC->alu != GXcopy || pGCPriv->flags)
-    {
-	if (!xglSyncBits (pSrc, &box))
-	    FatalError (XGL_SW_FAILURE_STRING);
-
-	XGL_GC_OP_FALLBACK_PROLOGUE (pDst);
-	pRegion = (*pGC->ops->CopyArea) (pSrc, pDst, pGC,
-					 srcX, srcY, w, h, dstX, dstY);
-	XGL_GC_OP_FALLBACK_EPILOGUE (pDst);
-    }
-    else
-    {
-	/* xglCopyProc handles fall-back */
-	pRegion = fbDoCopy (pSrc, pDst, pGC,
-			    srcX, srcY,
-			    w, h,
-			    dstX, dstY,
-			    xglCopyProc, 0,
-			    (void *) &box);
-    }
-
-    return pRegion;
-}
-
-RegionPtr
-xglCopyPlane (DrawablePtr   pSrc,
-	      DrawablePtr   pDst,
-	      GCPtr	    pGC,
-	      int	    srcX,
-	      int	    srcY,
-	      int	    w,
-	      int	    h,
-	      int	    dstX,
-	      int	    dstY,
-	      unsigned long bitPlane)
-{
-    RegionPtr pRegion;
-    BoxRec    box;
-
-    XGL_GC_PRIV (pGC);
-
-    box.x1 = pSrc->x + srcX;
-    box.y1 = pSrc->y + srcY;
-    box.x2 = box.x1 + w;
-    box.y2 = box.y1 + h;
-
-    if (!xglSyncBits (pSrc, &box))
-	FatalError (XGL_SW_FAILURE_STRING);
-
-    XGL_GC_OP_FALLBACK_PROLOGUE (pDst);
-    pRegion = (*pGC->ops->CopyPlane) (pSrc, pDst, pGC,
-				      srcX, srcY, w, h, dstX, dstY,
-				      bitPlane);
-    XGL_GC_OP_FALLBACK_EPILOGUE (pDst);
-
-    return pRegion;
-}
-
-void
-xglPolyPoint (DrawablePtr pDrawable,
-	      GCPtr       pGC,
-	      int	  mode,
-	      int	  npt,
-	      DDXPointPtr pptInit)
-{
-    XGL_GC_PRIV (pGC);
-
-    XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
-    (*pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pptInit);
-    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-}
-
-void
-xglPolylines (DrawablePtr pDrawable,
-	      GCPtr       pGC,
-	      int	  mode,
-	      int	  npt,
-	      DDXPointPtr ppt)
-{
-    if (pGC->lineWidth == 0)
-    {
-	XGL_GC_PRIV (pGC);
-
-	if (!pGCPriv->flags)
-	{
-	    if (pGC->lineStyle == LineSolid)
-	    {
-		if (xglFillLine (pDrawable, pGC, mode, npt, ppt))
-		    return;
-	    }
-	}
-
-	XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
-	(*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, ppt);
-	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-    }
-    else
-    {
-	if (pGC->lineStyle != LineSolid)
-	    miWideDash (pDrawable, pGC, mode, npt, ppt);
-	else
-	    miWideLine (pDrawable, pGC, mode, npt, ppt);
-    }
-}
-
-void
-xglPolySegment (DrawablePtr pDrawable,
-		GCPtr	    pGC,
-		int	    nsegInit,
-		xSegment    *pSegInit)
-{
-    if (pGC->lineWidth == 0)
-    {
-	XGL_GC_PRIV (pGC);
-
-	if (!pGCPriv->flags)
-	{
-	    if (pGC->lineStyle == LineSolid)
-	    {
-		if (xglFillSegment (pDrawable, pGC, nsegInit, pSegInit))
-		    return;
-	    }
-	}
-
-	XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
-	(*pGC->ops->PolySegment) (pDrawable, pGC, nsegInit, pSegInit);
-	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-    } else
-	miPolySegment (pDrawable, pGC, nsegInit, pSegInit);
-}
-
-void
-xglPolyArc (DrawablePtr pDrawable,
-	    GCPtr	pGC,
-	    int		narcs,
-	    xArc	*pArcs)
-{
-    if (pGC->lineWidth == 0)
-    {
-	XGL_GC_PRIV (pGC);
-
-	XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
-	(*pGC->ops->PolyArc) (pDrawable, pGC, narcs, pArcs);
-	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-    } else
-	miPolyArc (pDrawable, pGC, narcs, pArcs);
-}
-
-void
-xglPolyFillRect (DrawablePtr pDrawable,
-		 GCPtr	     pGC,
-		 int	     nrect,
-		 xRectangle  *prect)
-{
-    XGL_GC_PRIV (pGC);
-
-    if (pGC->fillStyle == FillStippled || pGCPriv->flags)
-    {
-	XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
-	(*pGC->ops->PolyFillRect) (pDrawable, pGC, nrect, prect);
-	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-    }
-    else
-    {
-	/* xglFillRect handles fall-back */
-	xglFillRect (pDrawable, pGC, nrect, prect);
-    }
-}
-
-void
-xglPolyFillArc (DrawablePtr pDrawable,
-		GCPtr	    pGC,
-		int	    narcs,
-		xArc	    *pArcs)
-{
-    XGL_GC_PRIV (pGC);
-
-    XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
-    (*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, pArcs);
-    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-}
-
-void
-xglImageGlyphBlt (DrawablePtr  pDrawable,
-		  GCPtr	       pGC,
-		  int	       x,
-		  int	       y,
-		  unsigned int nglyph,
-		  CharInfoPtr  *ppci,
-		  pointer      pglyphBase)
-{
-    XGL_GC_PRIV (pGC);
-
-    if (!pGCPriv->flags)
-    {
-	if (xglSolidGlyph (pDrawable,
-			   pGC,
-			   x,
-			   y,
-			   nglyph,
-			   ppci,
-			   pglyphBase))
-	    return;
-    }
-
-    XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
-    (*pGC->ops->ImageGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci,
-				pglyphBase);
-    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-}
-
-void
-xglPolyGlyphBlt (DrawablePtr  pDrawable,
-		 GCPtr	      pGC,
-		 int	      x,
-		 int	      y,
-		 unsigned int nglyph,
-		 CharInfoPtr  *ppci,
-		 pointer      pglyphBase)
-{
-    XGL_GC_PRIV (pGC);
-
-    if (!pGCPriv->flags)
-    {
-	if (xglFillGlyph (pDrawable,
-			  pGC,
-			  x,
-			  y,
-			  nglyph,
-			  ppci,
-			  pglyphBase))
-	    return;
-    }
-
-    XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
-    (*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
-    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-}
-
-void
-xglPushPixels (GCPtr	   pGC,
-	       PixmapPtr   pBitmap,
-	       DrawablePtr pDrawable,
-	       int	   w,
-	       int	   h,
-	       int	   x,
-	       int	   y)
-{
-    XGL_GC_PRIV (pGC);
-
-    if (!xglSyncBits (&pBitmap->drawable, NullBox))
-	FatalError (XGL_SW_FAILURE_STRING);
-
-    XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
-    (*pGC->ops->PushPixels) (pGC, pBitmap, pDrawable, w, h, x, y);
-    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
-}
-
-Bool
-xglCreateGC (GCPtr pGC)
-{
-    ScreenPtr pScreen = pGC->pScreen;
-    Bool      ret;
-
-    XGL_SCREEN_PRIV (pScreen);
-    XGL_GC_PRIV (pGC);
-
-    XGL_SCREEN_UNWRAP (CreateGC);
-    ret = (*pScreen->CreateGC) (pGC);
-    XGL_SCREEN_WRAP (CreateGC, xglCreateGC);
-
-    XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
-    XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
-
-    pGCPriv->flags = 0;
-    pGCPriv->op = GLITZ_OPERATOR_SRC;
-
-    pGCPriv->fg = NULL;
-    pGCPriv->bg = NULL;
-    pGCPriv->id = ~0;
-
-    return ret;
-}
-
-void
-xglDestroyGC (GCPtr pGC)
-{
-    XGL_GC_PRIV (pGC);
-
-    if (pGCPriv->fg)
-	glitz_surface_destroy (pGCPriv->fg);
-
-    if (pGCPriv->bg)
-	glitz_surface_destroy (pGCPriv->bg);
-
-    XGL_GC_UNWRAP (funcs);
-    XGL_GC_UNWRAP (ops);
-    (*pGC->funcs->DestroyGC) (pGC);
-    XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
-    XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
-}
-
-void
-xglValidateGC (GCPtr	     pGC,
-	       unsigned long changes,
-	       DrawablePtr   pDrawable)
-{
-    XGL_GC_PRIV (pGC);
-
-    if (changes & GCTile)
-    {
-	if (!pGC->tileIsPixel &&
-	    FbEvenTile (pGC->tile.pixmap->drawable.width *
-			pDrawable->bitsPerPixel))
-	    xglSyncBits (&pGC->tile.pixmap->drawable, NULL);
-    }
-
-    if (changes & GCStipple)
-    {
-	if (pGC->stipple)
-	    xglSyncBits (&pGC->stipple->drawable, NULL);
-    }
-
-    XGL_GC_UNWRAP (funcs);
-    XGL_GC_UNWRAP (ops);
-    (*pGC->funcs->ValidateGC) (pGC, changes, pDrawable);
-    XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
-    XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
-
-    if (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
-    {
-	XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
-
-	if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
-	{
-	    glitz_format_t *format;
-
-	    format = pPixmapPriv->pVisual->format.surface;
-	    if (format->id != pGCPriv->id)
-	    {
-		XGL_SCREEN_PRIV (pDrawable->pScreen);
-
-		pGCPriv->flags |= xglGCSoftwareDrawableFlag;
-
-		if (pGCPriv->fg)
-		    glitz_surface_destroy (pGCPriv->fg);
-
-		pGCPriv->fg = glitz_surface_create (pScreenPriv->drawable,
-						    format, 1, 1, 0, NULL);
-		if (pGCPriv->fg)
-		    glitz_surface_set_fill (pGCPriv->fg, GLITZ_FILL_REPEAT);
-
-		if (pGCPriv->bg)
-		    glitz_surface_destroy (pGCPriv->bg);
-
-		pGCPriv->bg = glitz_surface_create (pScreenPriv->drawable,
-						    format, 1, 1, 0, NULL);
-		if (pGCPriv->bg)
-		    glitz_surface_set_fill (pGCPriv->bg, GLITZ_FILL_REPEAT);
-
-		pGCPriv->id = format->id;
-
-		if (pGCPriv->fg && pGCPriv->bg)
-		{
-		    changes |= (GCForeground | GCBackground);
-		    pGCPriv->flags &= ~xglGCSoftwareDrawableFlag;
-		}
-	    }
-	}
-	else
-	    pGCPriv->flags |= xglGCSoftwareDrawableFlag;
-    }
-
-    if (changes & GCFunction)
-    {
-	switch (pGC->alu) {
-	case GXclear:
-	    pGCPriv->op = GLITZ_OPERATOR_CLEAR;
-	    pGCPriv->flags &= ~xglGCBadFunctionFlag;
-	    break;
-	case GXcopy:
-	    pGCPriv->op = GLITZ_OPERATOR_SRC;
-	    pGCPriv->flags &= ~xglGCBadFunctionFlag;
-	    break;
-	case GXnoop:
-	    pGCPriv->op = GLITZ_OPERATOR_DST;
-	    pGCPriv->flags &= ~xglGCBadFunctionFlag;
-	    break;
-	default:
-	    pGCPriv->flags |= xglGCBadFunctionFlag;
-	    break;
-	}
-    }
-
-    if (changes & GCPlaneMask)
-    {
-	FbBits mask;
-
-	mask = FbFullMask (pDrawable->depth);
-
-	if ((pGC->planemask & mask) != mask)
-	    pGCPriv->flags |= xglGCPlaneMaskFlag;
-	else
-	    pGCPriv->flags &= ~xglGCPlaneMaskFlag;
-    }
-
-    if (!(pGCPriv->flags & xglGCSoftwareDrawableFlag))
-    {
-	if (changes & (GCForeground | GCBackground))
-	{
-	    glitz_pixel_format_t format;
-	    glitz_buffer_t	 *buffer;
-	    CARD32		 pixel;
-
-	    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
-
-	    format.fourcc	  = GLITZ_FOURCC_RGB;
-	    format.masks	  = pPixmapPriv->pVisual->pPixel->masks;
-	    format.xoffset	  = 0;
-	    format.skip_lines     = 0;
-	    format.bytes_per_line = sizeof (CARD32);
-	    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
-
-	    buffer = glitz_buffer_create_for_data (&pixel);
-
-	    if (changes & GCForeground)
-	    {
-		pixel = pGC->fgPixel;
-		glitz_set_pixels (pGCPriv->fg, 0, 0, 1, 1, &format, buffer);
-	    }
-
-	    if (changes & GCBackground)
-	    {
-		pixel = pGC->bgPixel;
-		glitz_set_pixels (pGCPriv->bg, 0, 0, 1, 1, &format, buffer);
-	    }
-
-	    glitz_buffer_destroy (buffer);
-	}
-    }
-}
diff --git a/hw/xgl/xglgeometry.c b/hw/xgl/xglgeometry.c
deleted file mode 100644
index 7ab1ba4..0000000
--- a/hw/xgl/xglgeometry.c
+++ /dev/null
@@ -1,724 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-#include <X11/fonts/fontstruct.h>
-#include "dixfontstr.h"
-
-xglDataTypeInfoRec xglGeometryDataTypes[2] = {
-    { GLITZ_DATA_TYPE_SHORT, sizeof (glitz_short_t) },
-    { GLITZ_DATA_TYPE_FLOAT, sizeof (glitz_float_t) }
-};
-
-glitz_buffer_hint_t usageTypes[] = {
-    GLITZ_BUFFER_HINT_STREAM_DRAW,
-    GLITZ_BUFFER_HINT_STATIC_DRAW,
-    GLITZ_BUFFER_HINT_DYNAMIC_DRAW
-};
-
-void
-xglGeometryResize (ScreenPtr	  pScreen,
-		   xglGeometryPtr pGeometry,
-		   int		  size)
-{
-    XGL_SCREEN_PRIV (pScreen);
-
-    if (size == pGeometry->size)
-	return;
-
-    if (pGeometry->broken)
-	return;
-
-    if (pGeometry->usage == GEOMETRY_USAGE_SYSMEM)
-    {
-	pGeometry->data = xrealloc (pGeometry->data, size);
-
-	if (pGeometry->buffer)
-	    glitz_buffer_destroy (pGeometry->buffer);
-
-	pGeometry->buffer = NULL;
-
-	if (pGeometry->data)
-	{
-	    pGeometry->buffer = glitz_buffer_create_for_data (pGeometry->data);
-	    if (!pGeometry->buffer)
-	    {
-		pGeometry->broken = TRUE;
-		return;
-	    }
-	}
-	else if (size)
-	{
-	    pGeometry->broken = TRUE;
-	    return;
-	}
-    }
-    else
-    {
-	glitz_buffer_t *newBuffer;
-
-	if (size)
-	{
-	    newBuffer =
-		glitz_vertex_buffer_create (pScreenPriv->drawable, NULL, size,
-					    usageTypes[pGeometry->usage]);
-	    if (!newBuffer)
-	    {
-		pGeometry->broken = TRUE;
-		return;
-	    }
-	} else
-	    newBuffer = NULL;
-
-	if (pGeometry->buffer && newBuffer)
-	{
-	    void *oldData, *newData;
-
-	    oldData = glitz_buffer_map (pGeometry->buffer,
-					GLITZ_BUFFER_ACCESS_READ_ONLY);
-	    newData = glitz_buffer_map (newBuffer,
-					GLITZ_BUFFER_ACCESS_WRITE_ONLY);
-
-	    if (oldData && newData)
-		memcpy (newData, oldData, MIN (size, pGeometry->size));
-
-	    glitz_buffer_unmap (pGeometry->buffer);
-	    glitz_buffer_unmap (newBuffer);
-
-	    glitz_buffer_destroy (pGeometry->buffer);
-	}
-	pGeometry->buffer = newBuffer;
-    }
-
-    pGeometry->size = size;
-
-    if (pGeometry->endOffset > size)
-	pGeometry->endOffset = size;
-}
-
-#define MAP_GEOMETRY(pScreen, pGeometry, offset, units, ptr, _size)	  \
-    if ((pGeometry)->broken)						  \
-	return;								  \
-    (_size) = (units) * xglGeometryDataTypes[(pGeometry)->dataType].size; \
-    if (((pGeometry)->size - (offset)) < (_size))			  \
-    {									  \
-	xglGeometryResize (pScreen, pGeometry,				  \
-			   (pGeometry)->endOffset + (_size) + 500);	  \
-	if ((pGeometry)->broken)					  \
-	    return;							  \
-    }									  \
-    (ptr) = glitz_buffer_map ((pGeometry)->buffer,			  \
-			      GLITZ_BUFFER_ACCESS_WRITE_ONLY);		  \
-    if (!(ptr))								  \
-    {									  \
-	(pGeometry)->broken = TRUE;					  \
-	return;								  \
-    }									  \
-    (ptr) += (offset)
-
-#define UNMAP_GEOMETRY(pGeometry, offset, _size)			   \
-    if (glitz_buffer_unmap ((pGeometry)->buffer))			   \
-    {									   \
-	(pGeometry)->broken = TRUE;					   \
-	return;								   \
-    }									   \
-    if (((offset) + (_size)) > (pGeometry)->endOffset)			   \
-    {									   \
-	(pGeometry)->endOffset = (offset) + (_size);			   \
-	(pGeometry)->count = (pGeometry)->endOffset /			   \
-	    (2 * xglGeometryDataTypes[(pGeometry)->dataType].size);	   \
-    }
-
-/*
- * Adds a number of boxes as GL_QUAD primitives
- */
-void
-xglGeometryAddBox (ScreenPtr	  pScreen,
-		   xglGeometryPtr pGeometry,
-		   BoxPtr	  pBox,
-		   int		  nBox,
-		   int		  offset)
-{
-    int  size;
-    char *ptr;
-
-    if (nBox < 1)
-	return;
-
-    MAP_GEOMETRY (pScreen, pGeometry, offset, nBox * 8, ptr, size);
-
-    switch (pGeometry->dataType) {
-    case GEOMETRY_DATA_TYPE_SHORT:
-    {
-	glitz_short_t *data = (glitz_short_t *) ptr;
-
-	while (nBox--)
-	{
-	    *data++ = (glitz_short_t) pBox->x1;
-	    *data++ = (glitz_short_t) pBox->y1;
-	    *data++ = (glitz_short_t) pBox->x2;
-	    *data++ = (glitz_short_t) pBox->y1;
-	    *data++ = (glitz_short_t) pBox->x2;
-	    *data++ = (glitz_short_t) pBox->y2;
-	    *data++ = (glitz_short_t) pBox->x1;
-	    *data++ = (glitz_short_t) pBox->y2;
-
-	    pBox++;
-	}
-    } break;
-    case GEOMETRY_DATA_TYPE_FLOAT:
-    {
-	glitz_float_t *data = (glitz_float_t *) ptr;
-
-	while (nBox--)
-	{
-	    *data++ = (glitz_float_t) pBox->x1;
-	    *data++ = (glitz_float_t) pBox->y1;
-	    *data++ = (glitz_float_t) pBox->x2;
-	    *data++ = (glitz_float_t) pBox->y1;
-	    *data++ = (glitz_float_t) pBox->x2;
-	    *data++ = (glitz_float_t) pBox->y2;
-	    *data++ = (glitz_float_t) pBox->x1;
-	    *data++ = (glitz_float_t) pBox->y2;
-
-	    pBox++;
-	}
-    } break;
-    }
-
-    UNMAP_GEOMETRY (pGeometry, offset, size);
-}
-
-/*
- * Adds a number of spans as GL_LINE primitives
- */
-void
-xglGeometryAddSpan (ScreenPtr	   pScreen,
-		    xglGeometryPtr pGeometry,
-		    DDXPointPtr	   ppt,
-		    int		   *pwidth,
-		    int		   n,
-		    int		   offset)
-{
-    int  size;
-    char *ptr;
-
-    if (n < 1)
-	return;
-
-    MAP_GEOMETRY (pScreen, pGeometry, offset, n * 4, ptr, size);
-
-    switch (pGeometry->dataType) {
-    case GEOMETRY_DATA_TYPE_SHORT:
-    {
-	glitz_short_t *data = (glitz_short_t *) ptr;
-
-	while (n--)
-	{
-	    *data++ = (glitz_short_t) ppt->x;
-	    *data++ = (glitz_short_t) ppt->y;
-	    *data++ = (glitz_short_t) (ppt->x + *pwidth);
-	    *data++ = (glitz_short_t) ppt->y;
-
-	    ppt++;
-	    pwidth++;
-	}
-    } break;
-    case GEOMETRY_DATA_TYPE_FLOAT:
-    {
-	glitz_float_t *data = (glitz_float_t *) ptr;
-
-	while (n--)
-	{
-	    *data++ = (glitz_float_t) ppt->x;
-	    *data++ = (glitz_float_t) ppt->y;
-	    *data++ = (glitz_float_t) (ppt->x + *pwidth);
-	    *data++ = (glitz_float_t) ppt->y;
-
-	    ppt++;
-	    pwidth++;
-	}
-    } break;
-    }
-
-    UNMAP_GEOMETRY (pGeometry, offset, size);
-}
-
-/*
- * This macro is needed for end pixels to be rasterized correctly using
- * OpenGL as OpenGL line segments are half-opened.
- */
-#define ADJUST_END_POINT(start, end, isPoint) \
-    (((end) > (start)) ? (end) + 1:	      \
-     ((end) < (start)) ? (end) - 1:	      \
-     (isPoint)	       ? (end) + 1:	      \
-     (end))
-
-/*
- * Adds a number of connected lines as GL_LINE_STRIP primitives
- */
-void
-xglGeometryAddLine (ScreenPtr	   pScreen,
-		    xglGeometryPtr pGeometry,
-		    int		   loop,
-		    int		   mode,
-		    int		   npt,
-		    DDXPointPtr    ppt,
-		    int		   offset)
-{
-    DDXPointRec pt;
-    int		size;
-    char	*ptr;
-
-    if (npt < 2)
-	return;
-
-    MAP_GEOMETRY (pScreen, pGeometry, offset, npt * 2, ptr, size);
-
-    pt.x = 0;
-    pt.y = 0;
-
-    switch (pGeometry->dataType) {
-    case GEOMETRY_DATA_TYPE_SHORT:
-    {
-	glitz_short_t *data = (glitz_short_t *) ptr;
-
-	while (npt--)
-	{
-	    if (mode == CoordModePrevious)
-	    {
-		pt.x += ppt->x;
-		pt.y += ppt->y;
-	    }
-	    else
-	    {
-		pt.x = ppt->x;
-		pt.y = ppt->y;
-	    }
-
-	    if (npt || loop)
-	    {
-		*data++ = (glitz_short_t) pt.x;
-		*data++ = (glitz_short_t) pt.y;
-	    }
-	    else
-	    {
-		ppt--;
-		*data++ = (glitz_short_t)
-		    ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
-		*data++ = (glitz_short_t) ADJUST_END_POINT (ppt->y, pt.y, 0);
-	    }
-
-	    ppt++;
-	}
-    } break;
-    case GEOMETRY_DATA_TYPE_FLOAT:
-    {
-	glitz_float_t *data = (glitz_float_t *) ptr;
-
-	while (npt--)
-	{
-	    if (mode == CoordModePrevious)
-	    {
-		pt.x += ppt->x;
-		pt.y += ppt->y;
-	    }
-	    else
-	    {
-		pt.x = ppt->x;
-		pt.y = ppt->y;
-	    }
-
-	    if (npt || loop)
-	    {
-		*data++ = (glitz_float_t) pt.x;
-		*data++ = (glitz_float_t) pt.y;
-	    }
-	    else
-	    {
-		ppt--;
-		*data++ = (glitz_float_t)
-		    ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
-		*data++ = (glitz_float_t) ADJUST_END_POINT (ppt->y, pt.y, 0);
-	    }
-
-	    ppt++;
-	}
-    } break;
-    }
-
-    UNMAP_GEOMETRY (pGeometry, offset, size);
-}
-
-/*
- * Adds a number of line segments as GL_LINE primitives
- */
-void
-xglGeometryAddSegment (ScreenPtr      pScreen,
-		       xglGeometryPtr pGeometry,
-		       int	      nsegInit,
-		       xSegment       *pSegInit,
-		       int	      offset)
-{
-    int  size;
-    char *ptr;
-
-    if (nsegInit < 1)
-	return;
-
-    MAP_GEOMETRY (pScreen, pGeometry, offset, nsegInit * 4, ptr, size);
-
-    switch (pGeometry->dataType) {
-    case GEOMETRY_DATA_TYPE_SHORT:
-    {
-	glitz_short_t *data = (glitz_short_t *) ptr;
-
-	while (nsegInit--)
-	{
-	    *data++ = (glitz_short_t) pSegInit->x1;
-	    *data++ = (glitz_short_t) pSegInit->y1;
-	    *data++ = (glitz_short_t)
-		ADJUST_END_POINT (pSegInit->x1, pSegInit->x2,
-				  pSegInit->y1 == pSegInit->y2);
-	    *data++ = (glitz_short_t)
-		ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
-
-	    pSegInit++;
-	}
-    } break;
-    case GEOMETRY_DATA_TYPE_FLOAT:
-    {
-	glitz_float_t *data = (glitz_float_t *) ptr;
-
-	while (nsegInit--)
-	{
-	    *data++ = (glitz_float_t) pSegInit->x1;
-	    *data++ = (glitz_float_t) pSegInit->y1;
-	    *data++ = (glitz_float_t)
-		ADJUST_END_POINT (pSegInit->x1, pSegInit->x2,
-				  pSegInit->y1 == pSegInit->y2);
-	    *data++ = (glitz_float_t)
-		ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
-
-	    pSegInit++;
-	}
-    } break;
-    }
-
-    UNMAP_GEOMETRY (pGeometry, offset, size);
-}
-
-void
-xglGeometryForGlyph (ScreenPtr	    pScreen,
-		     xglGeometryPtr pGeometry,
-		     unsigned int   nGlyph,
-		     CharInfoPtr    *ppciInit,
-		     pointer	    pglyphBase)
-{
-    CharInfoPtr		*ppci;
-    CharInfoPtr		pci;
-    unsigned char	*glyphbase = (pointer) ~0;
-    unsigned char	*pglyph;
-    int			x = 0;
-    int			gx, gy;
-    int			gWidth, gHeight;
-    int			n, lastX = 0, lastY = 0;
-    glitz_multi_array_t *array;
-    glitz_buffer_t	*buffer;
-
-    ppci = ppciInit;
-    n = nGlyph;
-
-    while (n--)
-    {
-	pglyph = FONTGLYPHBITS (pglyphBase, *ppci++);
-	if (pglyph < glyphbase)
-	    glyphbase = pglyph;
-    }
-
-    buffer = glitz_buffer_create_for_data (glyphbase);
-    if (!buffer)
-    {
-	pGeometry->broken = TRUE;
-	return;
-    }
-
-    GEOMETRY_SET_BUFFER (pGeometry, buffer);
-
-    array = glitz_multi_array_create (nGlyph);
-    if (!array)
-    {
-	pGeometry->broken = TRUE;
-	return;
-    }
-
-    GEOMETRY_SET_MULTI_ARRAY (pGeometry, array);
-
-    ppci = ppciInit;
-    while (nGlyph--)
-    {
-	pci = *ppci++;
-	pglyph = FONTGLYPHBITS (pglyphBase, pci);
-	gWidth = GLYPHWIDTHPIXELS (pci);
-	gHeight = GLYPHHEIGHTPIXELS (pci);
-
-	if (gWidth && gHeight)
-	{
-	    gx = x + pci->metrics.leftSideBearing;
-	    gy = -pci->metrics.ascent;
-
-	    glitz_multi_array_add (array,
-				   (pglyph - glyphbase) * 8,
-				   gWidth, gHeight,
-				   (gx - lastX) << 16, (gy - lastY) << 16);
-	    lastX = gx;
-	    lastY = gy;
-	}
-	x += pci->metrics.characterWidth;
-    }
-
-    glitz_buffer_destroy (buffer);
-    glitz_multi_array_destroy (array);
-}
-
-#define FIXED_LINE_X_TO_FLOAT(line, v)		  \
-    (((glitz_float_t)				  \
-	((line).p1.x + (xFixed_16_16)		  \
-	 (((xFixed_32_32) ((v) - (line).p1.y) *   \
-	   ((line).p2.x - (line).p1.x)) /	  \
-	  ((line).p2.y - (line).p1.y)))) / 65536)
-
-#define FIXED_LINE_X_CEIL_TO_FLOAT(line, v)	\
-  (((glitz_float_t)				\
-      ((line).p1.x + (xFixed_16_16)		\
-       (((((line).p2.y - (line).p1.y) - 1) +	\
-	 ((xFixed_32_32) ((v) - (line).p1.y) *	\
-	  ((line).p2.x - (line).p1.x))) /	\
-	((line).p2.y - (line).p1.y)))) / 65536)
-
-/*
- * Adds a number of trapezoids as GL_QUAD primitives
- */
-void
-xglGeometryAddTrapezoid (ScreenPtr	pScreen,
-			 xglGeometryPtr pGeometry,
-			 xTrapezoid	*pTrap,
-			 int		nTrap,
-			 int		offset)
-{
-    int  size;
-    char *ptr;
-
-    if (nTrap < 1)
-	return;
-
-    MAP_GEOMETRY (pScreen, pGeometry, offset, nTrap * 8, ptr, size);
-
-    switch (pGeometry->dataType) {
-    case GEOMETRY_DATA_TYPE_SHORT:
-	/* not supported */
-	pGeometry->broken = TRUE;
-	break;
-    case GEOMETRY_DATA_TYPE_FLOAT:
-    {
-	glitz_float_t *data = (glitz_float_t *) ptr;
-	glitz_float_t top, bottom;
-
-	while (nTrap--)
-	{
-	    top    = FIXED_TO_FLOAT (pTrap->top);
-	    bottom = FIXED_TO_FLOAT (pTrap->bottom);
-
-	    *data++ = FIXED_LINE_X_TO_FLOAT (pTrap->left, pTrap->top);
-	    *data++ = top;
-	    *data++ = FIXED_LINE_X_CEIL_TO_FLOAT (pTrap->right, pTrap->top);
-	    *data++ = top;
-	    *data++ = FIXED_LINE_X_CEIL_TO_FLOAT (pTrap->right, pTrap->bottom);
-	    *data++ = bottom;
-	    *data++ = FIXED_LINE_X_TO_FLOAT (pTrap->left, pTrap->bottom);
-	    *data++ = bottom;
-
-	    pTrap++;
-	}
-    } break;
-    }
-
-    UNMAP_GEOMETRY (pGeometry, offset, size);
-}
-
-/*
- * Adds a number of traps as GL_QUAD primitives
- */
-void
-xglGeometryAddTrap (ScreenPtr	   pScreen,
-		    xglGeometryPtr pGeometry,
-		    xTrap	   *pTrap,
-		    int		   nTrap,
-		    int		   offset)
-{
-    int  size;
-    char *ptr;
-
-    if (nTrap < 1)
-	return;
-
-    MAP_GEOMETRY (pScreen, pGeometry, offset, nTrap * 8, ptr, size);
-
-    switch (pGeometry->dataType) {
-    case GEOMETRY_DATA_TYPE_SHORT:
-	/* not supported */
-	pGeometry->broken = TRUE;
-	break;
-    case GEOMETRY_DATA_TYPE_FLOAT:
-    {
-	glitz_float_t *data = (glitz_float_t *) ptr;
-	glitz_float_t top, bottom;
-
-	while (nTrap--)
-	{
-	    top    = FIXED_TO_FLOAT (pTrap->top.y);
-	    bottom = FIXED_TO_FLOAT (pTrap->bot.y);
-
-	    *data++ = FIXED_TO_FLOAT (pTrap->top.l);
-	    *data++ = top;
-	    *data++ = FIXED_TO_FLOAT (pTrap->top.r);
-	    *data++ = top;
-	    *data++ = FIXED_TO_FLOAT (pTrap->bot.r);
-	    *data++ = bottom;
-	    *data++ = FIXED_TO_FLOAT (pTrap->bot.l);
-	    *data++ = bottom;
-
-	    pTrap++;
-	}
-    } break;
-    }
-
-    UNMAP_GEOMETRY (pGeometry, offset, size);
-}
-
-/* XXX: scratch geometry size never shrinks, it just gets larger when
-   required. this is not acceptable. */
-xglGeometryPtr
-xglGetScratchGeometryWithSize (ScreenPtr pScreen,
-			       int	 size)
-{
-    xglGeometryPtr pGeometry;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    pGeometry = &pScreenPriv->scratchGeometry;
-
-    if (pGeometry->broken || pGeometry->size < size)
-    {
-	GEOMETRY_UNINIT (pGeometry);
-	GEOMETRY_INIT (pScreen, pGeometry, pGeometry->type,
-		       pScreenPriv->geometryUsage, size);
-    }
-    else
-    {
-	if (pGeometry->array)
-	{
-	    glitz_multi_array_destroy (pGeometry->array);
-	    pGeometry->array = NULL;
-	}
-	pGeometry->endOffset = 0;
-	pGeometry->xOff      = 0;
-	pGeometry->yOff      = 0;
-	pGeometry->first     = 0;
-	pGeometry->count     = 0;
-	pGeometry->width     = 2;
-    }
-
-    return pGeometry;
-}
-
-xglGeometryPtr
-xglGetScratchVertexGeometryWithType (ScreenPtr pScreen,
-				     int       type,
-				     int       count)
-{
-    xglGeometryPtr pGeometry;
-    int		   stride;
-
-    stride = 2 * xglGeometryDataTypes[type].size;
-
-    pGeometry = xglGetScratchGeometryWithSize (pScreen, count * stride);
-
-    pGeometry->type	= GLITZ_GEOMETRY_TYPE_VERTEX;
-    pGeometry->dataType	= type;
-
-    pGeometry->f.vertex.primitive	 = GLITZ_PRIMITIVE_QUADS;
-    pGeometry->f.vertex.type		 = xglGeometryDataTypes[type].type;
-    pGeometry->f.vertex.bytes_per_vertex = stride;
-    pGeometry->f.vertex.attributes       = 0;
-
-    return pGeometry;
-}
-
-xglGeometryPtr
-xglGetScratchVertexGeometry (ScreenPtr pScreen,
-			     int	 count)
-{
-    xglGeometryPtr pGeometry;
-    int		   type, stride;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    type   = pScreenPriv->geometryDataType;
-    stride = 2 * xglGeometryDataTypes[type].size;
-
-    pGeometry = xglGetScratchGeometryWithSize (pScreen, count * stride);
-
-    pGeometry->type	= GLITZ_GEOMETRY_TYPE_VERTEX;
-    pGeometry->dataType	= type;
-
-    pGeometry->f.vertex.primitive	 = GLITZ_PRIMITIVE_QUADS;
-    pGeometry->f.vertex.type		 = xglGeometryDataTypes[type].type;
-    pGeometry->f.vertex.bytes_per_vertex = stride;
-    pGeometry->f.vertex.attributes       = 0;
-
-    return pGeometry;
-}
-
-Bool
-xglSetGeometry (xglGeometryPtr	pGeometry,
-		glitz_surface_t *surface)
-{
-    if (pGeometry->broken)
-	return FALSE;
-
-    glitz_set_geometry (surface, pGeometry->type, &pGeometry->f,
-			pGeometry->buffer);
-
-    if (pGeometry->array)
-	glitz_set_multi_array (surface, pGeometry->array,
-			       pGeometry->xOff, pGeometry->yOff);
-    else
-	glitz_set_array (surface,
-			 pGeometry->first, pGeometry->width, pGeometry->count,
-			 pGeometry->xOff, pGeometry->yOff);
-
-    return TRUE;
-}
diff --git a/hw/xgl/xglget.c b/hw/xgl/xglget.c
deleted file mode 100644
index 71e32b1..0000000
--- a/hw/xgl/xglget.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-#include "glxserver.h"
-#include "glapi.h"
-#include "glthread.h"
-#include "dispatch.h"
-
-
-#include "xgl.h"
-
-void
-xglGetImage (DrawablePtr   pDrawable,
-	     int	   x,
-	     int	   y,
-	     int	   w,
-	     int	   h,
-	     unsigned int  format,
-	     unsigned long planeMask,
-	     char	   *d)
-{
-    ScreenPtr	    pScreen = pDrawable->pScreen;
-    glitz_surface_t *surface;
-    int             xOff, yOff;
-    BoxRec	    box;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    /* Many apps use GetImage to sync with the visible frame buffer */
-    if (pDrawable->type == DRAWABLE_WINDOW)
-    {
-	if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable))
-	    FatalError (XGL_SW_FAILURE_STRING);
-
-	__glXleaveServer(FALSE);
-	glitz_surface_flush (pScreenPriv->surface);
-	glitz_drawable_finish (pScreenPriv->drawable);
-	__glXenterServer(FALSE);
-    }
-
-    XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
-
-    box.x1 = pDrawable->x + xOff + x;
-    box.y1 = pDrawable->y + yOff + y;
-    box.x2 = box.x1 + w;
-    box.y2 = box.y1 + h;
-
-    if (!xglSyncBits (pDrawable, &box))
-	FatalError (XGL_SW_FAILURE_STRING);
-
-    XGL_SCREEN_UNWRAP (GetImage);
-    (*pScreen->GetImage) (pDrawable, x, y, w, h, format, planeMask, d);
-    XGL_SCREEN_WRAP (GetImage, xglGetImage);
-}
-
-void
-xglGetSpans (DrawablePtr pDrawable,
-	     int	 wMax,
-	     DDXPointPtr ppt,
-	     int	 *pwidth,
-	     int	 nspans,
-	     char	 *pchardstStart)
-{
-    ScreenPtr pScreen = pDrawable->pScreen;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    if (!xglSyncBits (pDrawable, NullBox))
-	FatalError (XGL_SW_FAILURE_STRING);
-
-    XGL_SCREEN_UNWRAP (GetSpans);
-    (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
-    XGL_SCREEN_WRAP (GetSpans, xglGetSpans);
-}
diff --git a/hw/xgl/xglglyph.c b/hw/xgl/xglglyph.c
deleted file mode 100644
index 7a60188..0000000
--- a/hw/xgl/xglglyph.c
+++ /dev/null
@@ -1,1169 +0,0 @@
-/*
- * Copyright © 2005 Novell, Inc.
- *
- * 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
- * Novell, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * Novell, Inc. makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL NOVELL, INC. 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-
-#ifdef RENDER
-#include "gcstruct.h"
-#include "picturestr.h"
-
-#define BITMAP_CACHE_SIZE      256000
-#define BITMAP_CACHE_MAX_LEVEL ~0
-#define BITMAP_CACHE_MAX_SIZE  512
-
-#define TEXTURE_CACHE_SIZE	 512
-#define TEXTURE_CACHE_MAX_LEVEL	 64
-#define TEXTURE_CACHE_MAX_HEIGHT 72
-#define TEXTURE_CACHE_MAX_WIDTH  72
-
-#define NEXT_GLYPH_SERIAL_NUMBER ((++glyphSerialNumber) > MAX_SERIAL_NUM ? \
-	    (glyphSerialNumber = 1): glyphSerialNumber)
-
-#define GLYPH_GET_AREA_PRIV(pArea)		\
-    ((xglGlyphAreaPtr) (pArea)->devPrivate.ptr)
-
-#define GLYPH_AREA_PRIV(pArea)				    \
-    xglGlyphAreaPtr pAreaPriv = GLYPH_GET_AREA_PRIV (pArea)
-
-#define NEEDS_COMPONENT(f) (PICT_FORMAT_A (f) != 0 && PICT_FORMAT_RGB (f) != 0)
-
-#define WRITE_VEC2(ptr, _x, _y) \
-    *(ptr)++ = (_x);		\
-    *(ptr)++ = (_y)
-
-#define WRITE_BOX(ptr, _vx1, _vy1, _vx2, _vy2, box) \
-    WRITE_VEC2 (ptr, _vx1, _vy1);		    \
-    WRITE_VEC2 (ptr, (box).x1, (box).y2);	    \
-    WRITE_VEC2 (ptr, _vx2, _vy1);		    \
-    WRITE_VEC2 (ptr, (box).x2, (box).y2);	    \
-    WRITE_VEC2 (ptr, _vx2, _vy2);		    \
-    WRITE_VEC2 (ptr, (box).x2, (box).y1);	    \
-    WRITE_VEC2 (ptr, _vx1, _vy2);		    \
-    WRITE_VEC2 (ptr, (box).x1, (box).y1)
-
-typedef union _xglGlyphList {
-    glitz_short_t *s;
-    glitz_float_t *f;
-} xglGlyphListRec, *xglGlyphListPtr;
-
-typedef struct _xglGlyphArray {
-    int	lastX, lastY;
-} xglGlyphArrayRec, *xglGlyphArrayPtr;
-
-typedef union _xglGlyphVertexData {
-    xglGlyphArrayRec array;
-    xglGlyphListRec  list;
-} xglGlyphVertexDataRec, *xglGlyphVertexDataPtr;
-
-typedef struct _xglGlyphOp {
-    GlyphListPtr pLists;
-    int		 listLen;
-    GlyphPtr	 *ppGlyphs;
-    int		 nGlyphs;
-    int		 xOff;
-    int		 yOff;
-    Bool	 noCache;
-} xglGlyphOpRec, *xglGlyphOpPtr;
-
-unsigned long glyphSerialNumber = 0;
-
-xglAreaRec zeroSizeArea = {
-    0, 0,
-    0, 0,
-    0, 0,
-    { NULL, NULL, NULL, NULL }, NULL,
-    (pointer) 0,
-    { 0 }
-};
-
-static Bool
-xglGlyphCreate (xglAreaPtr pArea)
-{
-    return TRUE;
-}
-
-static Bool
-xglGlyphMoveIn (xglAreaPtr pArea,
-		pointer    closure)
-{
-    xglGlyphCachePtr pCache = (xglGlyphCachePtr) pArea->pRoot->closure;
-    GlyphPtr	     pGlyph = (GlyphPtr) closure;
-
-    XGL_GLYPH_PRIV (pCache->pScreen, pGlyph);
-
-    pGlyphPriv->pArea = pArea;
-
-    return TRUE;
-}
-
-static void
-xglGlyphMoveOut (xglAreaPtr pArea,
-		 pointer    closure)
-{
-    xglGlyphCachePtr pCache = (xglGlyphCachePtr) pArea->pRoot->closure;
-    GlyphPtr	     pGlyph = (GlyphPtr) closure;
-
-    XGL_GLYPH_PRIV (pCache->pScreen, pGlyph);
-
-    pGlyphPriv->pArea = NULL;
-}
-
-static int
-xglGlyphCompareScore (xglAreaPtr pArea,
-		      pointer	 closure1,
-		      pointer	 closure2)
-{
-    GLYPH_AREA_PRIV (pArea);
-
-    if (pAreaPriv->serial == glyphSerialNumber)
-	return 1;
-
-    return -1;
-}
-
-static const xglAreaFuncsRec xglGlyphAreaFuncs = {
-    xglGlyphCreate,
-    xglGlyphMoveIn,
-    xglGlyphMoveOut,
-    xglGlyphCompareScore
-};
-
-Bool
-xglRealizeGlyph (ScreenPtr pScreen,
-		 GlyphPtr  pGlyph)
-{
-    PictureScreenPtr pPictureScreen = GetPictureScreen (pScreen);
-    Bool	     ret;
-
-    XGL_SCREEN_PRIV (pScreen);
-    XGL_GLYPH_PRIV (pScreen, pGlyph);
-
-    XGL_PICTURE_SCREEN_UNWRAP (RealizeGlyph);
-    ret = (*pPictureScreen->RealizeGlyph) (pScreen, pGlyph);
-    XGL_PICTURE_SCREEN_WRAP (RealizeGlyph, xglRealizeGlyph);
-
-    pGlyphPriv->pArea = NULL;
-
-    return ret;
-}
-
-void
-xglUnrealizeGlyph (ScreenPtr pScreen,
-		   GlyphPtr  pGlyph)
-{
-    PictureScreenPtr pPictureScreen = GetPictureScreen (pScreen);
-
-    XGL_SCREEN_PRIV (pScreen);
-    XGL_GLYPH_PRIV (pScreen, pGlyph);
-
-    XGL_PICTURE_SCREEN_UNWRAP (UnrealizeGlyph);
-    (*pPictureScreen->UnrealizeGlyph) (pScreen, pGlyph);
-    XGL_PICTURE_SCREEN_WRAP (UnrealizeGlyph, xglUnrealizeGlyph);
-
-    if (pGlyphPriv->pArea && pGlyphPriv->pArea->width)
-	xglWithdrawArea (pGlyphPriv->pArea);
-}
-
-Bool
-xglInitGlyphCache (xglGlyphCachePtr pCache,
-		   ScreenPtr	    pScreen,
-		   PictFormatPtr    format)
-{
-    XGL_SCREEN_PRIV (pScreen);
-
-    pCache->depth = format->depth;
-
-    if (!pScreenPriv->pSolidAlpha)
-    {
-	xglCreateSolidAlphaPicture (pScreen);
-	if (!pScreenPriv->pSolidAlpha)
-	    return FALSE;
-    }
-
-    if (pCache->depth == 1)
-    {
-	int stride;
-
-	GEOMETRY_INIT (pScreen, &pCache->u.geometry,
-		       GLITZ_GEOMETRY_TYPE_VERTEX,
-		       GEOMETRY_USAGE_STATIC, BITMAP_CACHE_SIZE);
-	GEOMETRY_SET_VERTEX_DATA_TYPE (&pCache->u.geometry,
-				       pScreenPriv->geometryDataType);
-
-	stride = pCache->u.geometry.f.vertex.bytes_per_vertex;
-	if (!xglRootAreaInit (&pCache->rootArea,
-			      BITMAP_CACHE_MAX_LEVEL,
-			      BITMAP_CACHE_SIZE / (stride * 4),
-			      0, sizeof (xglGlyphAreaRec),
-			      (xglAreaFuncsPtr) &xglGlyphAreaFuncs,
-			      (pointer) pCache))
-	{
-	    GEOMETRY_UNINIT (&pCache->u.geometry);
-	    return FALSE;
-	}
-    }
-    else
-    {
-
-	xglGlyphTexturePtr	   pTexture = &pCache->u.texture;
-	glitz_surface_t		   *mask;
-	glitz_surface_attributes_t attr;
-	glitz_vertex_format_t	   *vertex;
-	xglVisualPtr		   pVisual;
-
-	pVisual = xglFindVisualWithDepth (pScreen, format->depth);
-	if (!pVisual)
-	    return FALSE;
-
-	if (!xglRootAreaInit (&pCache->rootArea,
-			      TEXTURE_CACHE_MAX_LEVEL,
-			      TEXTURE_CACHE_SIZE, TEXTURE_CACHE_SIZE,
-			      sizeof (xglGlyphAreaRec),
-			      (xglAreaFuncsPtr) &xglGlyphAreaFuncs,
-			      (pointer) pCache))
-	    return FALSE;
-
-	if (pScreenPriv->geometryDataType == GEOMETRY_DATA_TYPE_SHORT)
-	{
-	    attr.unnormalized = 1;
-	    mask = glitz_surface_create (pScreenPriv->drawable,
-					 pVisual->format.surface,
-					 TEXTURE_CACHE_SIZE,
-					 TEXTURE_CACHE_SIZE,
-					 GLITZ_SURFACE_UNNORMALIZED_MASK,
-					 &attr);
-	}
-	else
-	    mask = NULL;
-
-	if (!mask)
-	{
-	    mask = glitz_surface_create (pScreenPriv->drawable,
-					 pVisual->format.surface,
-					 TEXTURE_CACHE_SIZE,
-					 TEXTURE_CACHE_SIZE,
-					 0, NULL);
-	    if (!mask)
-		return FALSE;
-
-	    pTexture->geometryDataType = GEOMETRY_DATA_TYPE_FLOAT;
-	}
-	else
-	    pTexture->geometryDataType = GEOMETRY_DATA_TYPE_SHORT;
-
-	if (NEEDS_COMPONENT (format->format))
-	    glitz_surface_set_component_alpha (mask, 1);
-
-	pTexture->pMask = xglCreateDevicePicture (mask);
-	if (!pTexture->pMask)
-	    return FALSE;
-
-	vertex = &pCache->u.texture.format.vertex;
-	vertex->primitive  = GLITZ_PRIMITIVE_QUADS;
-	vertex->mask.size  = GLITZ_COORDINATE_SIZE_XY;
-	vertex->attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK;
-
-	if (pTexture->geometryDataType == GEOMETRY_DATA_TYPE_FLOAT)
-	{
-	    vertex->type	     = GLITZ_DATA_TYPE_FLOAT;
-	    vertex->bytes_per_vertex = sizeof (glitz_float_t) * 4;
-	    vertex->mask.offset	     = sizeof (glitz_float_t) * 2;
-	    vertex->mask.type	     = GLITZ_DATA_TYPE_FLOAT;
-	}
-	else
-	{
-	    vertex->type	     = GLITZ_DATA_TYPE_SHORT;
-	    vertex->bytes_per_vertex = sizeof (glitz_short_t) * 4;
-	    vertex->mask.offset	     = sizeof (glitz_short_t) * 2;
-	    vertex->mask.type	     = GLITZ_DATA_TYPE_SHORT;
-	}
-
-	pTexture->pixel.fourcc	       = GLITZ_FOURCC_RGB;
-	pTexture->pixel.masks	       = pVisual->pPixel->masks;
-	pTexture->pixel.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
-	pTexture->pixel.bytes_per_line = 0;
-	pTexture->pixel.xoffset	       = 0;
-	pTexture->pixel.skip_lines     = 0;
-    }
-
-    pCache->pScreen = pScreen;
-
-    return TRUE;
-}
-
-void
-xglFiniGlyphCache (xglGlyphCachePtr pCache)
-{
-    if (pCache->pScreen)
-    {
-	xglRootAreaFini (&pCache->rootArea);
-
-	if (pCache->depth == 1)
-	{
-	    GEOMETRY_UNINIT (&pCache->u.geometry);
-	}
-	else
-	{
-	    if (pCache->u.texture.pMask)
-		FreePicture ((pointer) pCache->u.texture.pMask, 0);
-	}
-
-	pCache->pScreen = NULL;
-    }
-}
-
-static xglAreaPtr
-xglCacheGlyph (xglGlyphCachePtr pCache,
-	       GlyphPtr		pGlyph)
-{
-    ScreenPtr pScreen = pCache->pScreen;
-
-    XGL_GLYPH_PRIV (pScreen, pGlyph);
-
-    if (pCache->depth == 1)
-    {
-	PixmapPtr pPixmap;
-	RegionPtr pRegion;
-	int	  nBox;
-
-	pPixmap = GetScratchPixmapHeader (pScreen,
-					  pGlyph->info.width,
-					  pGlyph->info.height,
-					  pCache->depth, pCache->depth, 0,
-					  (pointer) (pGlyph + 1));
-	if (!pPixmap)
-	    return NULL;
-
-	(*pScreen->ModifyPixmapHeader) (pPixmap,
-					pGlyph->info.width,
-					pGlyph->info.height,
-					0, 0, -1, (pointer) (pGlyph + 1));
-
-	pRegion = (*pScreen->BitmapToRegion) (pPixmap);
-	FreeScratchPixmapHeader (pPixmap);
-
-	if (!pRegion)
-	    return NULL;
-
-	nBox = REGION_NUM_RECTS (pRegion);
-	if (nBox > BITMAP_CACHE_MAX_SIZE)
-	{
-	    REGION_DESTROY (pScreen, pRegion);
-	    return NULL;
-	}
-
-	if (nBox > 0)
-	{
-	    /* Find available area */
-	    if (!xglFindArea (pCache->rootArea.pArea, nBox, 0,
-			      FALSE, (pointer) pGlyph))
-	    {
-		/* Kicking out area with lower score */
-		xglFindArea (pCache->rootArea.pArea, nBox, 0,
-			     TRUE, (pointer) pGlyph);
-	    }
-
-	    if (pGlyphPriv->pArea)
-	    {
-		int stride;
-
-		GLYPH_AREA_PRIV (pGlyphPriv->pArea);
-
-		pAreaPriv->serial = glyphSerialNumber;
-		pAreaPriv->u.range.first = pGlyphPriv->pArea->x * 4;
-		pAreaPriv->u.range.count = nBox * 4;
-
-		stride = pCache->u.geometry.f.vertex.bytes_per_vertex;
-		GEOMETRY_ADD_REGION_AT (pScreen, &pCache->u.geometry, pRegion,
-					pGlyphPriv->pArea->x * stride * 4);
-	    }
-	} else
-	    pGlyphPriv->pArea = &zeroSizeArea;
-
-	REGION_DESTROY (pScreen, pRegion);
-    }
-    else
-    {
-	xglGlyphTexturePtr pTexture = &pCache->u.texture;
-
-	if (pGlyph->info.width  > TEXTURE_CACHE_MAX_WIDTH ||
-	    pGlyph->info.height > TEXTURE_CACHE_MAX_HEIGHT)
-	    return NULL;
-
-	if (pGlyph->info.width > 0 && pGlyph->info.height > 0)
-	{
-	    glitz_buffer_t *buffer;
-
-	    buffer = glitz_buffer_create_for_data (pGlyph + 1);
-	    if (!buffer)
-		return NULL;
-
-	    /* Find available area */
-	    if (!xglFindArea (pCache->rootArea.pArea,
-			      pGlyph->info.width, pGlyph->info.height,
-			      FALSE, (pointer) pGlyph))
-	    {
-		/* Kicking out area with lower score */
-		xglFindArea (pCache->rootArea.pArea,
-			     pGlyph->info.width, pGlyph->info.height,
-			     TRUE, (pointer) pGlyph);
-	    }
-
-	    if (pGlyphPriv->pArea)
-	    {
-		glitz_surface_t	     *surface;
-		glitz_point_fixed_t  p1, p2;
-		glitz_pixel_format_t pixel;
-
-		GLYPH_AREA_PRIV (pGlyphPriv->pArea);
-
-		pixel = pTexture->pixel;
-		pixel.bytes_per_line =
-		    PixmapBytePad (pGlyph->info.width, pCache->depth);
-
-		surface = pTexture->pMask->pSourcePict->source.devPrivate.ptr;
-
-		glitz_set_pixels (surface,
-				  pGlyphPriv->pArea->x,
-				  pGlyphPriv->pArea->y,
-				  pGlyph->info.width,
-				  pGlyph->info.height,
-				  &pixel,
-				  buffer);
-
-		p1.x = pGlyphPriv->pArea->x << 16;
-		p1.y = pGlyphPriv->pArea->y << 16;
-		p2.x = (pGlyphPriv->pArea->x + pGlyph->info.width)  << 16;
-		p2.y = (pGlyphPriv->pArea->y + pGlyph->info.height) << 16;
-
-		glitz_surface_translate_point (surface, &p1, &p1);
-		glitz_surface_translate_point (surface, &p2, &p2);
-
-		pAreaPriv->serial = glyphSerialNumber;
-		if (pTexture->geometryDataType)
-		{
-		    pAreaPriv->u.box.fBox.x1 = FIXED_TO_FLOAT (p1.x);
-		    pAreaPriv->u.box.fBox.y1 = FIXED_TO_FLOAT (p1.y);
-		    pAreaPriv->u.box.fBox.x2 = FIXED_TO_FLOAT (p2.x);
-		    pAreaPriv->u.box.fBox.y2 = FIXED_TO_FLOAT (p2.y);
-		}
-		else
-		{
-		    pAreaPriv->u.box.sBox.x1 = p1.x >> 16;
-		    pAreaPriv->u.box.sBox.y1 = p1.y >> 16;
-		    pAreaPriv->u.box.sBox.x2 = p2.x >> 16;
-		    pAreaPriv->u.box.sBox.y2 = p2.y >> 16;
-		}
-	    }
-	    glitz_buffer_destroy (buffer);
-	} else
-	    pGlyphPriv->pArea = &zeroSizeArea;
-    }
-
-    return pGlyphPriv->pArea;
-}
-
-static void
-xglUncachedGlyphs (CARD8	 op,
-		   PicturePtr    pSrc,
-		   PicturePtr    pDst,
-		   INT16	 xSrc,
-		   INT16	 ySrc,
-		   xglGlyphOpPtr pOp)
-{
-    ScreenPtr	     pScreen = pDst->pDrawable->pScreen;
-    PicturePtr	     pPicture = NULL;
-    PixmapPtr	     pPixmap = NULL;
-    xglGlyphCachePtr pCache;
-    int		     depth = pOp->pLists->format->depth;
-    GlyphPtr	     glyph;
-    INT16	     xOff, yOff;
-    xglGlyphPtr	     pGlyphPriv;
-    xglAreaPtr	     pArea;
-    Bool	     usingCache = !pOp->noCache;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    pCache = &pScreenPriv->glyphCache[depth];
-    if (usingCache)
-    {
-	if (!pCache->pScreen)
-	{
-	    if (!xglInitGlyphCache (pCache, pScreen, pOp->pLists->format))
-		usingCache = FALSE;
-	}
-    }
-
-    while (pOp->nGlyphs)
-    {
-	glyph = *pOp->ppGlyphs;
-
-	if (!pOp->listLen)
-	{
-	    pOp->pLists++;
-	    pOp->listLen = pOp->pLists->len;
-	    pOp->xOff   += pOp->pLists->xOff;
-	    pOp->yOff   += pOp->pLists->yOff;
-	}
-
-	xOff = pOp->xOff;
-	yOff = pOp->yOff;
-
-	if (usingCache)
-	{
-	    pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, glyph);
-	    pArea = pGlyphPriv->pArea;
-	    if (pSrc)
-	    {
-		if (!pArea)
-		    pArea = xglCacheGlyph (pCache, glyph);
-
-		if (pArea)
-		    break;
-	    }
-	} else
-	    pArea = NULL;
-
-	pOp->listLen--;
-	pOp->nGlyphs--;
-	pOp->ppGlyphs++;
-
-	pOp->xOff += glyph->info.xOff;
-	pOp->yOff += glyph->info.yOff;
-
-	if (pArea)
-	    continue;
-
-	if (!pPicture)
-	{
-	    XID componentAlpha;
-	    int	error;
-
-	    pPixmap = GetScratchPixmapHeader (pScreen,
-					      glyph->info.width,
-					      glyph->info.height,
-					      depth, depth,
-					      0, (pointer) (glyph + 1));
-	    if (!pPixmap)
-		return;
-
-	    componentAlpha = NEEDS_COMPONENT (pOp->pLists->format->format);
-	    pPicture = CreatePicture (0, &pPixmap->drawable,
-				      pOp->pLists->format,
-				      CPComponentAlpha, &componentAlpha,
-				      serverClient, &error);
-	    if (!pPicture)
-	    {
-		FreeScratchPixmapHeader (pPixmap);
-		return;
-	    }
-	}
-
-	(*pScreen->ModifyPixmapHeader) (pPixmap,
-					glyph->info.width, glyph->info.height,
-					0, 0, -1, (pointer) (glyph + 1));
-	pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-
-	if (pSrc)
-	    CompositePicture (op,
-			      pSrc,
-			      pPicture,
-			      pDst,
-			      xSrc + (xOff - glyph->info.x),
-			      ySrc + (yOff - glyph->info.y),
-			      0, 0,
-			      xOff - glyph->info.x,
-			      yOff - glyph->info.y,
-			      glyph->info.width,
-			      glyph->info.height);
-	else
-	    CompositePicture (PictOpAdd,
-			      pPicture,
-			      NULL,
-			      pDst,
-			      0, 0,
-			      0, 0,
-			      xOff - glyph->info.x,
-			      yOff - glyph->info.y,
-			      glyph->info.width,
-			      glyph->info.height);
-    }
-
-    if (pPicture)
-    {
-	FreeScratchPixmapHeader (pPixmap);
-	FreePicture ((pointer) pPicture, 0);
-    }
-}
-
-static Bool
-xglCachedGlyphs (CARD8	       op,
-		 PicturePtr    pSrc,
-		 PicturePtr    pDst,
-		 INT16	       xSrc,
-		 INT16	       ySrc,
-		 xglGlyphOpPtr pOp)
-{
-    ScreenPtr		  pScreen = pDst->pDrawable->pScreen;
-    xglGlyphOpRec	  opSave = *pOp;
-    xglGlyphCachePtr	  pCache;
-    xglGlyphVertexDataRec vData;
-    xglGeometryPtr	  pGeometry;
-    GlyphPtr		  glyph;
-    xglGlyphPtr		  pGlyphPriv;
-    xglAreaPtr		  pArea;
-    xglGlyphAreaPtr	  pGlyphArea;
-    BoxRec		  extents;
-    INT16		  xOff, yOff, x1, x2, y1, y2;
-    int			  depth = pOp->pLists->format->depth;
-    int			  i, remaining = pOp->nGlyphs;
-    int			  nGlyph = 0;
-    PicturePtr		  pMaskPicture = NULL;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    pCache = &pScreenPriv->glyphCache[depth];
-    if (!pCache->pScreen)
-    {
-	if (!xglInitGlyphCache (pCache, pScreen, pOp->pLists->format))
-	{
-	    pOp->noCache = TRUE;
-	    return 1;
-	}
-    }
-
-    /* update serial number for all glyphs already in cache so that
-       we don't accidentally replace one. */
-    for (i = 0; i < pOp->nGlyphs; i++)
-    {
-	pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pOp->ppGlyphs[i]);
-	pArea = pGlyphPriv->pArea;
-	if (pArea && pArea->width)
-	    GLYPH_GET_AREA_PRIV (pArea)->serial = glyphSerialNumber;
-    }
-
-    for (i = 0; i < pOp->nGlyphs; i++)
-    {
-	pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pOp->ppGlyphs[i]);
-	pArea = pGlyphPriv->pArea;
-	if (!pArea)
-	    pArea = xglCacheGlyph (pCache, pOp->ppGlyphs[i]);
-
-	if (pArea)
-	{
-	    if (pArea->width)
-		nGlyph++;
-	}
-	else if (pSrc)
-	    break;
-    }
-
-    if (nGlyph)
-    {
-	if (depth == 1)
-	{
-	    glitz_multi_array_t *multiArray;
-
-	    pGeometry = &pCache->u.geometry;
-	    pGeometry->xOff = pGeometry->yOff = 0;
-
-	    multiArray = glitz_multi_array_create (nGlyph);
-	    if (!multiArray)
-		return 1;
-
-	    GEOMETRY_SET_MULTI_ARRAY (pGeometry, multiArray);
-	    glitz_multi_array_destroy (multiArray);
-
-	    vData.array.lastX = 0;
-	    vData.array.lastY = 0;
-	}
-	else
-	{
-	    i = 4 * pCache->u.texture.format.vertex.bytes_per_vertex * nGlyph;
-	    pGeometry = xglGetScratchGeometryWithSize (pScreen, i);
-
-	    pGeometry->f = pCache->u.texture.format;
-	    pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
-	    pMaskPicture = pCache->u.texture.pMask;
-
-	    vData.list.s = glitz_buffer_map (pGeometry->buffer,
-					     GLITZ_BUFFER_ACCESS_WRITE_ONLY);
-	}
-    } else
-	pGeometry = NULL;
-
-    extents.x1 = MAXSHORT;
-    extents.y1 = MAXSHORT;
-    extents.x2 = MINSHORT;
-    extents.y2 = MINSHORT;
-
-    while (pOp->nGlyphs)
-    {
-	glyph = *pOp->ppGlyphs;
-
-	if (!pOp->listLen)
-	{
-	    pOp->pLists++;
-	    pOp->listLen = pOp->pLists->len;
-	    pOp->xOff   += pOp->pLists->xOff;
-	    pOp->yOff   += pOp->pLists->yOff;
-	}
-
-	xOff = pOp->xOff;
-	yOff = pOp->yOff;
-
-	pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, glyph);
-	pArea = pGlyphPriv->pArea;
-	if (!pArea && pSrc)
-	    break;
-
-	pOp->listLen--;
-	pOp->nGlyphs--;
-	pOp->ppGlyphs++;
-
-	pOp->xOff += glyph->info.xOff;
-	pOp->yOff += glyph->info.yOff;
-
-	if (!pArea)
-	    continue;
-
-	x1 = xOff - glyph->info.x;
-	x2 = x1 + glyph->info.width;
-	if (x1 < extents.x1)
-	    extents.x1 = x1;
-	if (x2 > extents.x2)
-	    extents.x2 = x2;
-
-	y1 = yOff - glyph->info.y;
-	y2 = y1 + glyph->info.height;
-	if (y1 < extents.y1)
-	    extents.y1 = y1;
-	if (y2 > extents.y2)
-	    extents.y2 = y2;
-
-	if (pArea->width)
-	{
-	    pGlyphArea = GLYPH_GET_AREA_PRIV (pArea);
-	    if (depth == 1)
-	    {
-		glitz_multi_array_add (pGeometry->array,
-				       pGlyphArea->u.range.first, 2,
-				       pGlyphArea->u.range.count,
-				       (x1 - vData.array.lastX) << 16,
-				       (y1 - vData.array.lastY) << 16);
-		vData.array.lastX = x1;
-		vData.array.lastY = y1;
-	    }
-	    else
-	    {
-		if (pCache->u.texture.geometryDataType)
-		{
-		    WRITE_BOX (vData.list.f, x1, y1, x2, y2,
-			       pGlyphArea->u.box.fBox);
-		}
-		else
-		{
-		    WRITE_BOX (vData.list.s, x1, y1, x2, y2,
-			       pGlyphArea->u.box.sBox);
-		}
-	    }
-	}
-	remaining--;
-    }
-
-    NEXT_GLYPH_SERIAL_NUMBER;
-
-    if (nGlyph)
-    {
-	if (depth != 1)
-	{
-	    glitz_buffer_unmap (pGeometry->buffer);
-	    pGeometry->count = nGlyph * 4;
-	}
-
-	xSrc += extents.x1;
-	ySrc += extents.y1;
-
-	if (!pSrc)
-	{
-	    op = PictOpAdd;
-	    pSrc = pScreenPriv->pSolidAlpha;
-
-	    if (remaining)
-		*pOp = opSave;
-	}
-
-	GEOMETRY_TRANSLATE (pGeometry,
-			    pDst->pDrawable->x,
-			    pDst->pDrawable->y);
-
-	if (xglCompositeGeneral (op,
-				 pSrc,
-				 pMaskPicture,
-				 pDst,
-				 pGeometry,
-				 xSrc, ySrc,
-				 0, 0,
-				 pDst->pDrawable->x + extents.x1,
-				 pDst->pDrawable->y + extents.y1,
-				 extents.x2 - extents.x1,
-				 extents.y2 - extents.y1))
-	{
-	    xglAddCurrentBitDamage (pDst->pDrawable);
-	    return remaining;
-	}
-
-	remaining = ~0;
-	*pOp = opSave;
-	pOp->noCache = TRUE;
-    }
-    else
-    {
-	if (remaining)
-	{
-	    *pOp = opSave;
-	    pOp->noCache = TRUE;
-	}
-    }
-
-    return remaining;
-}
-
-static Bool
-xglGlyphExtents (PicturePtr   pDst,
-		 int	      nlist,
-		 GlyphListPtr list,
-		 GlyphPtr     *glyphs,
-		 BoxPtr	      extents)
-{
-    GlyphPtr glyph;
-    BoxRec   line;
-    int	     x1, x2, y1, y2;
-    int	     n;
-    int	     x;
-    int	     y;
-    Bool     overlap = FALSE;
-
-    x = 0;
-    y = 0;
-
-    extents->x1 = MAXSHORT;
-    extents->x2 = MINSHORT;
-    extents->y1 = MAXSHORT;
-    extents->y2 = MINSHORT;
-
-    while (!list->len)
-    {
-	if (--nlist)
-	{
-	    x += list->xOff;
-	    y += list->yOff;
-	    list++;
-	}
-	else
-	{
-	    return FALSE;
-	}
-    }
-
-    glyph = *glyphs;
-    x1 = (x + list->xOff) - glyph->info.x;
-    if (x1 < MINSHORT)
-	x1 = MINSHORT;
-    y1 = (y  + list->yOff) - glyph->info.y;
-    if (y1 < MINSHORT)
-	y1 = MINSHORT;
-
-    line.x1 = x1;
-    line.x2 = x1;
-    line.y1 = y1;
-    line.y2 = y1;
-
-    while (nlist--)
-    {
-	x += list->xOff;
-	y += list->yOff;
-	n = list->len;
-	list++;
-
-	while (n--)
-	{
-	    glyph = *glyphs++;
-	    x1 = x - glyph->info.x;
-	    if (x1 < MINSHORT)
-		x1 = MINSHORT;
-	    y1 = y - glyph->info.y;
-	    if (y1 < MINSHORT)
-		y1 = MINSHORT;
-	    x2 = x1 + glyph->info.width;
-	    if (x2 > MAXSHORT)
-		x2 = MAXSHORT;
-	    y2 = y1 + glyph->info.height;
-	    if (y2 > MAXSHORT)
-		y2 = MAXSHORT;
-
-	    if (x1 >= line.x2)
-	    {
-		line.x2 = x2;
-		if (y1 < line.y1)
-		    line.y1 = y1;
-		if (y2 > line.y2)
-		    line.y2 = y2;
-	    }
-	    else if (x2 <= line.x1)
-	    {
-		line.x1 = x1;
-		if (y1 < line.y1)
-		    line.y1 = y1;
-		if (y2 > line.y2)
-		    line.y2 = y2;
-	    }
-	    else
-	    {
-		if (line.y1 >= extents->y2)
-		{
-		    extents->y2 = line.y2;
-		    if (line.y1 < extents->y1)
-			extents->y1 = line.y1;
-		}
-		else if (line.y2 <= extents->y1)
-		{
-		    extents->y1 = line.y1;
-		    if (line.y2 > extents->y2)
-			extents->y2 = line.y2;
-		}
-		else
-		{
-		    if (line.y1 < extents->y1)
-			extents->y1 = line.y1;
-		    if (line.y2 > extents->y2)
-			extents->y2 = line.y2;
-
-		    overlap = TRUE;
-		}
-
-		if (line.x1 < extents->x1)
-		    extents->x1 = line.x1;
-		if (line.x2 > extents->x2)
-		    extents->x2 = line.x2;
-
-		line.x1 = x1;
-		line.y1 = y1;
-		line.x2 = x2;
-		line.y2 = y2;
-	    }
-
-	    x += glyph->info.xOff;
-	    y += glyph->info.yOff;
-	}
-    }
-
-    if (line.y1 >= extents->y2)
-    {
-	extents->y2 = line.y2;
-	if (line.y1 < extents->y1)
-	    extents->y1 = line.y1;
-    }
-    else if (line.y2 <= extents->y1)
-    {
-	extents->y1 = line.y1;
-	if (line.y2 > extents->y2)
-	    extents->y2 = line.y2;
-    }
-    else
-    {
-	if (line.y1 < extents->y1)
-	    extents->y1 = line.y1;
-	if (line.y2 > extents->y2)
-	    extents->y2 = line.y2;
-
-	overlap = TRUE;
-    }
-
-    if (line.x1 < extents->x1)
-	extents->x1 = line.x1;
-    if (line.x2 > extents->x2)
-	extents->x2 = line.x2;
-
-    xglPictureClipExtents (pDst, extents);
-
-    return overlap;
-}
-
-/* returns 0 if all glyph lists don't have the same format */
-static CARD32
-xglGlyphListFormatId (GlyphListPtr list,
-		      int	   nlist)
-{
-    CARD32 id = list->format->id;
-
-    nlist--;
-    list++;
-
-    while (nlist--)
-    {
-	if (list->format->id != id)
-	    return 0;
-
-	list++;
-    }
-
-    return id;
-}
-
-void
-xglGlyphs (CARD8	 op,
-	   PicturePtr	 pSrc,
-	   PicturePtr	 pDst,
-	   PictFormatPtr maskFormat,
-	   INT16	 xSrc,
-	   INT16	 ySrc,
-	   int		 nlist,
-	   GlyphListPtr	 list,
-	   GlyphPtr	 *glyphs)
-{
-    ScreenPtr	  pScreen = pDst->pDrawable->pScreen;
-    PicturePtr	  pMask = NULL, pSrcPicture, pDstPicture;
-    BoxRec	  extents;
-    xglGlyphOpRec glyphOp;
-    int		  xDst = list->xOff, yDst = list->yOff;
-    int		  overlap;
-    int		  target;
-
-    overlap = xglGlyphExtents (pDst, nlist, list, glyphs, &extents);
-    if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
-	return;
-
-    target = xglPrepareTarget (pDst->pDrawable);
-
-    if (op != PictOpAdd && maskFormat &&
-	(!target || overlap || op != PictOpOver ||
-	 xglGlyphListFormatId (list, nlist) != maskFormat->id))
-    {
-	PixmapPtr  pPixmap;
-	XID	   componentAlpha;
-	GCPtr	   pGC;
-	xRectangle rect;
-	int	   error;
-
-	rect.x = 0;
-	rect.y = 0;
-	rect.width = extents.x2 - extents.x1;
-	rect.height = extents.y2 - extents.y1;
-
-	pPixmap = (*pScreen->CreatePixmap) (pScreen,
-					    rect.width, rect.height,
-					    maskFormat->depth);
-	if (!pPixmap)
-	    return;
-
-	componentAlpha = NEEDS_COMPONENT (maskFormat->format);
-	pMask = CreatePicture (0, &pPixmap->drawable,
-			       maskFormat, CPComponentAlpha, &componentAlpha,
-			       serverClient, &error);
-	if (!pMask)
-	{
-	    (*pScreen->DestroyPixmap) (pPixmap);
-	    return;
-	}
-
-	if (!target)
-	{
-	    /* make sure we don't do accelerated drawing to mask */
-	    xglSetPixmapVisual (pPixmap, NULL);
-	}
-
-	ValidatePicture (pMask);
-	pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
-	ValidateGC (&pPixmap->drawable, pGC);
-	(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &rect);
-	FreeScratchGC (pGC);
-
-	(*pScreen->DestroyPixmap) (pPixmap);
-
-	target = xglPrepareTarget (pMask->pDrawable);
-
-	glyphOp.xOff = -extents.x1;
-	glyphOp.yOff = -extents.y1;
-	pSrcPicture = NULL;
-	pDstPicture = pMask;
-    }
-    else
-    {
-	glyphOp.xOff = 0;
-	glyphOp.yOff = 0;
-	pSrcPicture = pSrc;
-	pDstPicture = pDst;
-    }
-
-    glyphOp.ppGlyphs = glyphs;
-    glyphOp.noCache  = !target;
-
-    while (nlist--)
-    {
-	glyphOp.xOff   += list->xOff;
-	glyphOp.yOff   += list->yOff;
-	glyphOp.listLen = list->len;
-	glyphOp.nGlyphs = list->len;
-	glyphOp.pLists  = list++;
-
-	for (; nlist; nlist--, list++)
-	{
-	    if (list->format->id != glyphOp.pLists->format->id)
-		break;
-
-	    glyphOp.nGlyphs += list->len;
-	}
-
-	while (glyphOp.nGlyphs)
-	{
-	    if (glyphOp.noCache || xglCachedGlyphs (op,
-						    pSrcPicture,
-						    pDstPicture,
-						    xSrc - xDst, ySrc - yDst,
-						    &glyphOp))
-		xglUncachedGlyphs (op,
-				   pSrcPicture,
-				   pDstPicture,
-				   xSrc - xDst, ySrc - yDst,
-				   &glyphOp);
-	}
-    }
-
-    if (pMask)
-    {
-	CompositePicture (op, pSrc, pMask, pDst,
-			  xSrc + extents.x1 - xDst,
-			  ySrc + extents.y1 - yDst,
-			  0, 0,
-			  extents.x1, extents.y1,
-			  extents.x2 - extents.x1,
-			  extents.y2 - extents.y1);
-
-	FreePicture ((pointer) pMask, (XID) 0);
-    }
-}
-
-#endif
diff --git a/hw/xgl/xglpict.c b/hw/xgl/xglpict.c
deleted file mode 100644
index 36e6603..0000000
--- a/hw/xgl/xglpict.c
+++ /dev/null
@@ -1,787 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-#include "fb.h"
-
-#ifdef RENDER
-
-#include "fbpict.h"
-
-#define XGL_PICTURE_FALLBACK_PROLOGUE(pPicture, func) \
-    xglSyncDamageBoxBits (pPicture->pDrawable);	      \
-    XGL_PICTURE_SCREEN_UNWRAP (func)
-
-#define XGL_PICTURE_FALLBACK_EPILOGUE(pPicture, func, xglfunc) \
-    XGL_PICTURE_SCREEN_WRAP (func, xglfunc);		       \
-    xglAddCurrentSurfaceDamage (pPicture->pDrawable)
-
-void
-xglComposite (CARD8	 op,
-	      PicturePtr pSrc,
-	      PicturePtr pMask,
-	      PicturePtr pDst,
-	      INT16	 xSrc,
-	      INT16	 ySrc,
-	      INT16	 xMask,
-	      INT16	 yMask,
-	      INT16	 xDst,
-	      INT16	 yDst,
-	      CARD16	 width,
-	      CARD16	 height)
-{
-    PictureScreenPtr pPictureScreen;
-    ScreenPtr	     pScreen = pDst->pDrawable->pScreen;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    if (xglCompositeGeneral (op,
-			     pSrc, pMask, pDst, NULL,
-			     xSrc, ySrc,
-			     xMask, yMask,
-			     xDst + pDst->pDrawable->x,
-			     yDst + pDst->pDrawable->y,
-			     width, height))
-    {
-	xglAddCurrentBitDamage (pDst->pDrawable);
-	return;
-    }
-
-    pPictureScreen = GetPictureScreen (pScreen);
-
-    if (pSrc->pDrawable)
-    {
-	if (!xglSyncBits (pSrc->pDrawable, NullBox))
-	    FatalError (XGL_SW_FAILURE_STRING);
-    }
-
-    if (pMask && pMask->pDrawable)
-    {
-	if (!xglSyncBits (pMask->pDrawable, NullBox))
-	    FatalError (XGL_SW_FAILURE_STRING);
-    }
-
-    if (op == PictOpSrc)
-    {
-	XGL_DRAWABLE_PIXMAP (pDst->pDrawable);
-
-	if (!xglMapPixmapBits (pPixmap))
-	    FatalError (XGL_SW_FAILURE_STRING);
-    } else
-	xglSyncDamageBoxBits (pDst->pDrawable);
-
-    XGL_PICTURE_SCREEN_UNWRAP (Composite);
-    (*pPictureScreen->Composite) (op, pSrc, pMask, pDst,
-				  xSrc, ySrc, xMask, yMask, xDst, yDst,
-				  width, height);
-    XGL_PICTURE_SCREEN_WRAP (Composite, xglComposite);
-
-    if (op == PictOpSrc)
-    {
-	RegionRec region;
-
-	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;
-
-	xglAddSurfaceDamage (pDst->pDrawable, &region);
-	REGION_UNINIT (pDst->pDrawable->pScreen, &region);
-    } else
-	xglAddCurrentSurfaceDamage (pDst->pDrawable);
-}
-
-void
-xglAddTriangles (PicturePtr pDst,
-		 INT16	    xOff,
-		 INT16	    yOff,
-		 int	    ntri,
-		 xTriangle  *tris)
-{
-    PictureScreenPtr pPictureScreen;
-    ScreenPtr	     pScreen = pDst->pDrawable->pScreen;
-
-    XGL_SCREEN_PRIV (pScreen);
-    XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
-
-    pPictureScreen = GetPictureScreen (pScreen);
-
-    pPixmapPriv->damageBox.x1 = 0;
-    pPixmapPriv->damageBox.y1 = 0;
-    pPixmapPriv->damageBox.x2 = pDst->pDrawable->width;
-    pPixmapPriv->damageBox.y2 = pDst->pDrawable->height;
-
-    XGL_PICTURE_FALLBACK_PROLOGUE (pDst, AddTriangles);
-    (*pPictureScreen->AddTriangles) (pDst, xOff, yOff, ntri, tris);
-    XGL_PICTURE_FALLBACK_EPILOGUE (pDst, AddTriangles, xglAddTriangles);
-}
-
-
-void
-xglChangePicture (PicturePtr pPicture,
-		  Mask	     mask)
-{
-    PictureScreenPtr pPictureScreen;
-    ScreenPtr	     pScreen = pPicture->pDrawable->pScreen;
-
-    XGL_SCREEN_PRIV (pScreen);
-    XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
-
-    pPictureScreen = GetPictureScreen (pScreen);
-
-    if (pPicture->stateChanges & CPRepeat)
-	pPixmapPriv->pictureMask |= xglPCFillMask;
-
-    if (pPicture->stateChanges & CPComponentAlpha)
-	pPixmapPriv->pictureMask |= xglPCComponentAlphaMask;
-
-    if (pPicture->stateChanges & CPDither)
-	pPixmapPriv->pictureMask |= xglPCDitherMask;
-
-    XGL_PICTURE_SCREEN_UNWRAP (ChangePicture);
-    (*pPictureScreen->ChangePicture) (pPicture, mask);
-    XGL_PICTURE_SCREEN_WRAP (ChangePicture, xglChangePicture);
-}
-
-int
-xglChangePictureTransform (PicturePtr    pPicture,
-			   PictTransform *transform)
-{
-    PictureScreenPtr pPictureScreen;
-    ScreenPtr	     pScreen = pPicture->pDrawable->pScreen;
-    int		     ret;
-
-    XGL_SCREEN_PRIV (pScreen);
-    XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
-
-    pPictureScreen = GetPictureScreen (pScreen);
-
-    if (transform != pPicture->transform ||
-	(transform && memcmp (transform, &pPicture->transform,
-			      sizeof (PictTransform))))
-	pPixmapPriv->pictureMask |= xglPCTransformMask;
-
-    XGL_PICTURE_SCREEN_UNWRAP (ChangePictureTransform);
-    ret = (*pPictureScreen->ChangePictureTransform) (pPicture, transform);
-    XGL_PICTURE_SCREEN_WRAP (ChangePictureTransform,
-			     xglChangePictureTransform);
-
-    return ret;
-}
-
-int
-xglChangePictureFilter (PicturePtr pPicture,
-			int	   filter,
-			xFixed	   *params,
-			int	   nparams)
-{
-    PictureScreenPtr pPictureScreen;
-    ScreenPtr	     pScreen = pPicture->pDrawable->pScreen;
-    int		     ret;
-
-    XGL_SCREEN_PRIV (pScreen);
-    XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
-
-    pPictureScreen = GetPictureScreen (pScreen);
-
-    pPixmapPriv->pictureMask |= xglPCFilterMask;
-
-    XGL_PICTURE_SCREEN_UNWRAP (ChangePictureFilter);
-    ret = (*pPictureScreen->ChangePictureFilter) (pPicture, filter,
-						  params, nparams);
-    XGL_PICTURE_SCREEN_WRAP (ChangePictureFilter, xglChangePictureFilter);
-
-    return ret;
-}
-
-static void
-xglDestroyDevicePicture (PicturePtr pPicture)
-{
-    if (pPicture->pSourcePict->source.devPrivate.ptr)
-	glitz_surface_destroy (pPicture->pSourcePict->source.devPrivate.ptr);
-}
-
-PicturePtr
-xglCreateDevicePicture (pointer data)
-{
-    PicturePtr pPicture;
-    int	       error;
-
-    pPicture = CreateDevicePicture (0, &error);
-    if (!pPicture)
-	return 0;
-
-    pPicture->pSourcePict->source.devPrivate.ptr = data;
-    pPicture->pSourcePict->source.Destroy	 = xglDestroyDevicePicture;
-
-    return pPicture;
-}
-
-static int fillMode[] = {
-    GLITZ_FILL_TRANSPARENT, /* RepeatNone    */
-    GLITZ_FILL_REPEAT,      /* RepeatNormal  */
-    GLITZ_FILL_NEAREST,     /* RepeatPad     */
-    GLITZ_FILL_REFLECT      /* RepeatReflect */
-};
-
-static void
-xglUpdatePicture (PicturePtr pPicture)
-{
-    glitz_surface_t *surface;
-
-    XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
-
-    surface = pPixmapPriv->surface;
-
-    if (pPixmapPriv->pictureMask & xglPCFillMask)
-    {
-	glitz_surface_set_fill (surface, fillMode[pPicture->repeatType]);
-    }
-
-    if (pPixmapPriv->pictureMask & xglPCFilterMask)
-    {
-	switch (pPicture->filter) {
-	case PictFilterNearest:
-	case PictFilterFast:
-	    glitz_surface_set_filter (surface, GLITZ_FILTER_NEAREST, NULL, 0);
-	    break;
-	case PictFilterGood:
-	case PictFilterBest:
-	case PictFilterBilinear:
-	    glitz_surface_set_filter (surface, GLITZ_FILTER_BILINEAR, NULL, 0);
-	    break;
-	case PictFilterConvolution:
-	    glitz_surface_set_filter (surface, GLITZ_FILTER_CONVOLUTION,
-				      (glitz_fixed16_16_t *)
-				      pPicture->filter_params,
-				      pPicture->filter_nparams);
-	    break;
-	}
-    }
-
-    if (pPixmapPriv->pictureMask & xglPCTransformMask)
-    {
-	glitz_surface_set_transform (surface, (glitz_transform_t *)
-				     pPicture->transform);
-    }
-
-    if (pPixmapPriv->pictureMask & xglPCComponentAlphaMask)
-    {
-	glitz_surface_set_component_alpha (surface, pPicture->componentAlpha);
-    }
-
-    if (pPixmapPriv->pictureMask & xglPCDitherMask)
-    {
-	glitz_surface_set_dither (surface, pPicture->dither);
-    }
-
-    pPixmapPriv->pictureMask &= ~XGL_PICTURE_CHANGES (~0);
-}
-
-#define N_STACK_PARAM 256
-
-static int gradientNParam[] = {
-    0, /* SourcePictTypeSolidFill */
-    4, /* SourcePictTypeLinear    */
-    6, /* SourcePictTypeRadial    */
-    4, /* SourcePictTypeConical   */
-};
-
-Bool
-xglSyncPicture (ScreenPtr  pScreen,
-		PicturePtr pPicture,
-		INT16	   x,
-		INT16	   y,
-		CARD16	   width,
-		CARD16	   height,
-		INT16	   *xOff,
-		INT16	   *yOff)
-{
-    xglPixmapPtr pPixmapPriv;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    *xOff = *yOff = 0;
-
-    if (pPicture->pSourcePict)
-    {
-	if (pPicture->pSourcePict->source.devPrivate.ptr)
-	    return TRUE;
-
-	if (pPicture->pDrawable)
-	{
-	    (*pScreen->DestroyPixmap) ((PixmapPtr) pPicture->pDrawable);
-	    pPicture->pDrawable = (DrawablePtr) 0;
-	}
-
-	switch (pPicture->pSourcePict->source.type) {
-	case SourcePictTypeSolidFill:
-	    x = y = 0;
-	    width = height = 1;
-	    break;
-	case SourcePictTypeLinear:
-	case SourcePictTypeRadial: {
-	    glitz_fixed16_16_t		stackParam[N_STACK_PARAM];
-	    glitz_fixed16_16_t		*param;
-	    int				nParam, nStop, size, i;
-	    CARD32			*pixel;
-	    PictGradientStopPtr		pStop;
-	    glitz_buffer_t		*buffer;
-	    glitz_format_t		*format;
-	    glitz_surface_t		*surface;
-	    static glitz_pixel_format_t pixelFormat = {
-		GLITZ_FOURCC_RGB,
-		{
-		    32,
-		    0xff000000,
-		    0x00ff0000,
-		    0x0000ff00,
-		    0x000000ff
-		},
-		0, 0, 0,
-		GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
-	    };
-
-	    if (!(pScreenPriv->features & GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK))
-		break;
-
-	    format = glitz_find_standard_format (pScreenPriv->drawable,
-						 GLITZ_STANDARD_ARGB32);
-	    if (!format)
-		break;
-
-	    nParam = gradientNParam[pPicture->pSourcePict->gradient.type];
-	    pStop  = pPicture->pSourcePict->gradient.stops;
-	    nStop  = pPicture->pSourcePict->gradient.nstops;
-
-	    size = nParam + nStop * 4;
-	    if (size > N_STACK_PARAM)
-	    {
-		param = malloc (sizeof (xFixed) * size);
-		if (!param)
-		    break;
-	    }
-	    else
-	    {
-		param = stackParam;
-	    }
-
-	    pixel = (CARD32 *) (param + nParam + nStop * 3);
-
-	    buffer = glitz_buffer_create_for_data (pixel);
-	    if (!buffer)
-	    {
-		if (size > N_STACK_PARAM)
-		    free (param);
-
-		break;
-	    }
-
-	    surface = glitz_surface_create (pScreenPriv->drawable,
-					    format, nStop, 1, 0, NULL);
-	    if (!surface)
-	    {
-		glitz_buffer_destroy (buffer);
-		if (size > N_STACK_PARAM)
-		    free (param);
-
-		break;
-	    }
-
-	    for (i = 0; i < nStop; i++)
-	    {
-		pixel[i] = pStop[i].color;
-
-		param[nParam + 3 * i + 0] = pStop[i].x;
-		param[nParam + 3 * i + 1] = i << 16;
-		param[nParam + 3 * i + 2] = 0;
-	    }
-
-	    glitz_set_pixels (surface, 0, 0, nStop, 1, &pixelFormat, buffer);
-
-	    glitz_buffer_destroy (buffer);
-
-	    switch (pPicture->pSourcePict->source.type) {
-	    case SourcePictTypeLinear:
-		param[0] = pPicture->pSourcePict->linear.p1.x;
-		param[1] = pPicture->pSourcePict->linear.p1.y;
-		param[2] = pPicture->pSourcePict->linear.p2.x;
-		param[3] = pPicture->pSourcePict->linear.p2.y;
-
-		glitz_surface_set_filter (surface,
-					  GLITZ_FILTER_LINEAR_GRADIENT,
-					  param, nParam + nStop * 3);
-		break;
-	    case SourcePictTypeRadial:
-		param[0] = pPicture->pSourcePict->radial.c1.x;
-		param[1] = pPicture->pSourcePict->radial.c1.y;
-		param[2] = pPicture->pSourcePict->radial.c1.radius;
-		param[3] = pPicture->pSourcePict->radial.c2.x;
-		param[4] = pPicture->pSourcePict->radial.c2.y;
-		param[5] = pPicture->pSourcePict->radial.c2.radius;
-
-		glitz_surface_set_filter (surface,
-					  GLITZ_FILTER_RADIAL_GRADIENT,
-					  param, nParam + nStop * 3);
-		break;
-	    }
-
-	    glitz_surface_set_fill (surface, fillMode[pPicture->repeatType]);
-	    glitz_surface_set_transform (surface, (glitz_transform_t *)
-					 pPicture->transform);
-
-	    pPicture->pSourcePict->gradient.devPrivate.ptr = surface;
-	    pPicture->pSourcePict->gradient.Destroy = xglDestroyDevicePicture;
-
-	    if (size > N_STACK_PARAM)
-		free (param);
-
-	    return TRUE;
-	} break;
-	case SourcePictTypeConical:
-	default:
-	    break;
-	}
-
-	if (!pPicture->pDrawable)
-	{
-	    PictFormatPtr pFormat;
-	    PixmapPtr	  pPixmap;
-	    PicturePtr	  pTmp;
-	    RegionRec	  region;
-	    BoxRec	  box;
-	    int		  error;
-
-	    pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
-	    if (!pFormat)
-		return FALSE;
-
-	    pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
-						pFormat->depth);
-	    if (!pPixmap)
-		return FALSE;
-
-	    pTmp = CreatePicture (0, &pPixmap->drawable, pFormat, 0, NULL,
-				  serverClient, &error);
-	    if (!pTmp)
-	    {
-		(*pScreen->DestroyPixmap) (pPixmap);
-		return FALSE;
-	    }
-
-	    ValidatePicture (pTmp);
-
-	    if (!xglSyncBits (pTmp->pDrawable, NullBox))
-		FatalError (XGL_SW_FAILURE_STRING);
-
-	    fbCompositeGeneral (PictOpSrc,
-				pPicture, 0, pTmp,
-				x, y, 0, 0, 0, 0,
-				width, height);
-
-	    FreePicture ((pointer) pTmp, (XID) 0);
-
-	    box.x1 = 0;
-	    box.y1 = 0;
-	    box.x2 = width;
-	    box.y2 = height;
-
-	    REGION_INIT (pScreen, &region, &box, 1);
-	    xglAddSurfaceDamage (&pPixmap->drawable, &region);
-	    REGION_UNINIT (pDrawable->pScreen, &region);
-
-	    pPicture->pDrawable = &pPixmap->drawable;
-
-	    *xOff = x;
-	    *yOff = y;
-
-	    XGL_GET_PIXMAP_PRIV (pPixmap)->pictureMask &=
-		~(xglPCFillMask | xglPCFilterMask | xglPCTransformMask);
-	}
-    }
-
-#ifdef XV
-    switch (pPicture->format) {
-    case PICT_yuy2:
-	xglSetPixmapVisual ((PixmapPtr) pPicture->pDrawable,
-			    &pScreenPriv->pXvVisual[XGL_XV_FORMAT_YUY2]);
-	break;
-    case PICT_yv12:
-	xglSetPixmapVisual ((PixmapPtr) pPicture->pDrawable,
-			    &pScreenPriv->pXvVisual[XGL_XV_FORMAT_YV12]);
-    default:
-	break;
-    }
-#endif
-
-    if (!xglSyncSurface (pPicture->pDrawable))
-	return FALSE;
-
-    pPixmapPriv = XGL_GET_PIXMAP_PRIV ((PixmapPtr) pPicture->pDrawable);
-    if (XGL_PICTURE_CHANGES (pPixmapPriv->pictureMask))
-	xglUpdatePicture (pPicture);
-
-    return TRUE;
-}
-
-static int
-xglVisualDepth (ScreenPtr pScreen, VisualPtr pVisual)
-{
-    DepthPtr pDepth;
-    int	     d, v;
-
-    for (d = 0; d < pScreen->numDepths; d++)
-    {
-	pDepth = &pScreen->allowedDepths[d];
-	for (v = 0; v < pDepth->numVids; v++)
-	    if (pDepth->vids[v] == pVisual->vid)
-		return pDepth->depth;
-    }
-
-    return 0;
-}
-
-typedef struct _xglformatInit {
-    CARD32 format;
-    CARD8  depth;
-} xglFormatInitRec, *xglFormatInitPtr;
-
-static int
-xglAddFormat (xglFormatInitPtr formats,
-	      int	       nformat,
-	      CARD32	       format,
-	      CARD8	       depth)
-{
-    int	n;
-
-    for (n = 0; n < nformat; n++)
-	if (formats[n].format == format && formats[n].depth == depth)
-	    return nformat;
-
-    formats[nformat].format = format;
-    formats[nformat].depth = depth;
-
-    return ++nformat;
-}
-
-#define Mask(n)	((n) == 32 ? 0xffffffff : ((1 << (n)) - 1))
-
-Bool
-xglPictureInit (ScreenPtr pScreen)
-{
-    int		     f, nformats = 0;
-    PictFormatPtr    pFormats;
-    xglFormatInitRec formats[64];
-    CARD32	     format;
-    CARD8	     depth;
-    VisualPtr	     pVisual;
-    int		     v;
-    int		     bpp;
-    int		     r, g, b;
-    int		     d;
-    DepthPtr	     pDepth;
-
-    /* formats required by protocol */
-    formats[nformats].format = PICT_a1;
-    formats[nformats].depth = 1;
-    nformats++;
-    formats[nformats].format = PICT_a4;
-    formats[nformats].depth = 4;
-    nformats++;
-    formats[nformats].format = PICT_a8;
-    formats[nformats].depth = 8;
-    nformats++;
-    formats[nformats].format = PICT_a8r8g8b8;
-    formats[nformats].depth = 32;
-    nformats++;
-
-    /* now look through the depths and visuals adding other formats */
-    for (v = 0; v < pScreen->numVisuals; v++)
-    {
-	pVisual = &pScreen->visuals[v];
-	depth = xglVisualDepth (pScreen, pVisual);
-	if (!depth)
-	    continue;
-
-	bpp = BitsPerPixel (depth);
-	switch (pVisual->class) {
-	case DirectColor:
-	case TrueColor:
-	    r = Ones (pVisual->redMask);
-	    g = Ones (pVisual->greenMask);
-	    b = Ones (pVisual->blueMask);
-	    if (pVisual->offsetBlue == 0 &&
-		pVisual->offsetGreen == b &&
-		pVisual->offsetRed == b + g)
-	    {
-		format = PICT_FORMAT (bpp, PICT_TYPE_ARGB, 0, r, g, b);
-		nformats = xglAddFormat (formats, nformats, format, depth);
-	    }
-	    break;
-	case StaticColor:
-	case PseudoColor:
-	case StaticGray:
-	case GrayScale:
-	    break;
-	}
-    }
-
-    /* walk supported depths and add missing Direct formats */
-    for (d = 0; d < pScreen->numDepths; d++)
-    {
-	pDepth = &pScreen->allowedDepths[d];
-	bpp = BitsPerPixel (pDepth->depth);
-	format = 0;
-	switch (bpp) {
-	case 16:
-	    if (pDepth->depth == 15)
-		nformats = xglAddFormat (formats, nformats,
-					 PICT_x1r5g5b5, pDepth->depth);
-	    if (pDepth->depth == 16)
-		nformats = xglAddFormat (formats, nformats,
-					 PICT_r5g6b5, pDepth->depth);
-	    break;
-	case 24:
-	    if (pDepth->depth == 24)
-		nformats = xglAddFormat (formats, nformats,
-					 PICT_r8g8b8, pDepth->depth);
-	    break;
-	case 32:
-	    if (pDepth->depth == 24)
-		nformats = xglAddFormat (formats, nformats,
-					 PICT_x8r8g8b8, pDepth->depth);
-	    break;
-	}
-    }
-
-    /* add YUV formats */
-    nformats = xglAddFormat (formats, nformats, PICT_yuy2, 16);
-    nformats = xglAddFormat (formats, nformats, PICT_yv12, 12);
-
-    pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec));
-    if (!pFormats)
-	return 0;
-
-    memset (pFormats, '\0', nformats * sizeof (PictFormatRec));
-    for (f = 0; f < nformats; f++)
-    {
-	pFormats[f].id = FakeClientID (0);
-	pFormats[f].depth = formats[f].depth;
-	format = formats[f].format;
-	pFormats[f].format = format;
-	switch (PICT_FORMAT_TYPE (format)) {
-	case PICT_TYPE_ARGB:
-	    pFormats[f].type = PictTypeDirect;
-	    pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format));
-	    if (pFormats[f].direct.alphaMask)
-		pFormats[f].direct.alpha = (PICT_FORMAT_R (format) +
-					    PICT_FORMAT_G (format) +
-					    PICT_FORMAT_B (format));
-
-	    pFormats[f].direct.redMask = Mask (PICT_FORMAT_R (format));
-	    pFormats[f].direct.red = (PICT_FORMAT_G (format) +
-				      PICT_FORMAT_B (format));
-
-	    pFormats[f].direct.greenMask = Mask (PICT_FORMAT_G (format));
-	    pFormats[f].direct.green = PICT_FORMAT_B (format);
-
-	    pFormats[f].direct.blueMask = Mask (PICT_FORMAT_B (format));
-	    pFormats[f].direct.blue = 0;
-	    break;
-	case PICT_TYPE_A:
-	    pFormats[f].type = PictTypeDirect;
-	    pFormats[f].direct.alpha = 0;
-	    pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format));
-	    break;
-	case PICT_TYPE_COLOR:
-	case PICT_TYPE_GRAY:
-	    pFormats[f].type = PictTypeDirect;
-	    break;
-	case PICT_TYPE_YUY2:
-	case PICT_TYPE_YV12:
-	    pFormats[f].type = PictTypeOther;
-	    break;
-	}
-    }
-
-    if (!fbPictureInit (pScreen, pFormats, nformats))
-	return FALSE;
-
-    return TRUE;
-}
-
-void
-xglPictureClipExtents (PicturePtr pPicture,
-		       BoxPtr     extents)
-{
-    if (pPicture->clientClipType != CT_NONE)
-    {
-	BoxPtr clip = REGION_EXTENTS (pPicture->pDrawable->pScreen,
-				      (RegionPtr) pPicture->clientClip);
-
-	if (extents->x1 < pPicture->clipOrigin.x + clip->x1)
-	    extents->x1 = pPicture->clipOrigin.x + clip->x1;
-
-	if (extents->y1 < pPicture->clipOrigin.y + clip->y1)
-	    extents->y1 = pPicture->clipOrigin.y + clip->y1;
-
-	if (extents->x2 > pPicture->clipOrigin.x + clip->x2)
-	    extents->x2 = pPicture->clipOrigin.x + clip->x2;
-
-	if (extents->y2 > pPicture->clipOrigin.y + clip->y2)
-	    extents->y2 = pPicture->clipOrigin.y + clip->y2;
-    }
-    else
-    {
-	if (extents->x1 < 0)
-	    extents->x1 = 0;
-
-	if (extents->y1 < 0)
-	    extents->y1 = 0;
-
-	if (extents->x2 > pPicture->pDrawable->width)
-	    extents->x2 = pPicture->pDrawable->width;
-
-	if (extents->y2 > pPicture->pDrawable->height)
-	    extents->y2 = pPicture->pDrawable->height;
-    }
-}
-
-#endif
diff --git a/hw/xgl/xglpixmap.c b/hw/xgl/xglpixmap.c
deleted file mode 100644
index 56c7ecd..0000000
--- a/hw/xgl/xglpixmap.c
+++ /dev/null
@@ -1,747 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-#include "fb.h"
-
-static glitz_buffer_hint_t xglPixmapUsageHints[] = {
-    (glitz_buffer_hint_t) 0,	    /* reserved for system memory */
-    GLITZ_BUFFER_HINT_STREAM_DRAW,
-    GLITZ_BUFFER_HINT_STREAM_READ,
-    GLITZ_BUFFER_HINT_STREAM_COPY,
-    GLITZ_BUFFER_HINT_STATIC_DRAW,
-    GLITZ_BUFFER_HINT_STATIC_READ,
-    GLITZ_BUFFER_HINT_STATIC_COPY,
-    GLITZ_BUFFER_HINT_DYNAMIC_DRAW,
-    GLITZ_BUFFER_HINT_DYNAMIC_READ,
-    GLITZ_BUFFER_HINT_DYNAMIC_COPY
-};
-
-#define NUM_XGL_PIXMAP_USAGE_HINTS				     \
-    (sizeof (xglPixmapUsageHints) / sizeof (xglPixmapUsageHints[0]))
-
-#define XGL_PIXMAP_USAGE_HINT(hint) (xglPixmapUsageHints[hint])
-
-static void
-xglPixmapDamageReport (DamagePtr pDamage,
-		       RegionPtr pRegion,
-		       void	 *closure)
-{
-    PixmapPtr pPixmap = (PixmapPtr) closure;
-    BoxPtr    pExt;
-
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    pExt = REGION_EXTENTS (pPixmap->drawable.pScreen, pRegion);
-
-    if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
-    {
-	if (pExt->x1 < pPixmapPriv->damageBox.x1)
-	    pPixmapPriv->damageBox.x1 = pExt->x1;
-
-	if (pExt->y1 < pPixmapPriv->damageBox.y1)
-	    pPixmapPriv->damageBox.y1 = pExt->y1;
-
-	if (pExt->x2 > pPixmapPriv->damageBox.x2)
-	    pPixmapPriv->damageBox.x2 = pExt->x2;
-
-	if (pExt->y2 > pPixmapPriv->damageBox.y2)
-	    pPixmapPriv->damageBox.y2 = pExt->y2;
-    }
-    else
-	pPixmapPriv->damageBox = *pExt;
-}
-
-
-Bool
-xglPixmapCreateDamage (PixmapPtr pPixmap)
-{
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    pPixmapPriv->pDamage =
-	DamageCreate (xglPixmapDamageReport, (DamageDestroyFunc) 0,
-		      DamageReportRawRegion, TRUE,
-		      pPixmap->drawable.pScreen,
-		      (void *) pPixmap);
-    if (!pPixmapPriv->pDamage)
-	return FALSE;
-
-    DamageRegister (&pPixmap->drawable, pPixmapPriv->pDamage);
-
-    return TRUE;
-}
-
-void
-xglSetPixmapVisual (PixmapPtr    pPixmap,
-		    xglVisualPtr pVisual)
-{
-    xglVisualPtr pOldVisual;
-
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    pOldVisual = pPixmapPriv->pVisual;
-    if (pOldVisual && pVisual)
-    {
-	glitz_surface_t *surface;
-
-	if (pOldVisual->vid != pVisual->vid)
-	{
-	    surface = pPixmapPriv->surface;
-	    if (surface)
-	    {
-		glitz_drawable_t *drawable;
-
-		drawable = glitz_surface_get_attached_drawable (surface);
-		if (drawable)
-		{
-		    if (pOldVisual->format.drawable->id !=
-			pVisual->format.drawable->id)
-		    {
-			glitz_surface_detach (pPixmapPriv->surface);
-			pPixmapPriv->target = xglPixmapTargetOut;
-		    }
-		}
-
-		if (pOldVisual->format.surface->id != pVisual->format.surface->id)
-		{
-		    xglSyncBits (&pPixmap->drawable, NULL);
-		    glitz_surface_destroy (pPixmapPriv->surface);
-		    pPixmapPriv->surface = 0;
-		}
-	    }
-	}
-    }
-    else if (pOldVisual)
-    {
-	if (pPixmapPriv->surface)
-	{
-	    xglSyncBits (&pPixmap->drawable, NULL);
-	    glitz_surface_destroy (pPixmapPriv->surface);
-	    pPixmapPriv->surface = 0;
-	}
-	pPixmapPriv->target = xglPixmapTargetNo;
-    }
-
-    pPixmapPriv->pVisual = pVisual;
-
-    if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
-    {
-	if (!pPixmapPriv->pDamage)
-	{
-	    if (!xglPixmapCreateDamage (pPixmap))
-		FatalError (XGL_SW_FAILURE_STRING);
-	}
-    }
-}
-
-Bool
-xglPixmapSurfaceInit (PixmapPtr	    pPixmap,
-		      unsigned long features,
-		      int	    width,
-		      int	    height)
-{
-    BoxRec box;
-
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    pPixmapPriv->surface = NULL;
-    pPixmapPriv->drawable = NULL;
-    pPixmapPriv->acceleratedTile = FALSE;
-    pPixmapPriv->pictureMask = ~0;
-    pPixmapPriv->target = xglPixmapTargetNo;
-
-    box.x1 = 0;
-    box.y1 = 0;
-    box.x2 = width;
-    box.y2 = height;
-
-    REGION_INIT (pScreen, &pPixmapPriv->bitRegion, &box, 1);
-
-    pPixmapPriv->pVisual = xglFindVisualWithDepth (pPixmap->drawable.pScreen,
-						   pPixmap->drawable.depth);
-    if (pPixmapPriv->pVisual)
-    {
-	XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
-
-	/* general pixmap acceleration */
-	if (pPixmapPriv->pVisual->format.drawable &&
-	    pScreenPriv->accel.pixmap.enabled &&
-	    xglCheckPixmapSize (pPixmap, &pScreenPriv->accel.pixmap.size))
-	    pPixmapPriv->target = xglPixmapTargetOut;
-    }
-
-    if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
-    {
-	if (!pPixmapPriv->pDamage)
-	{
-	    if (!xglPixmapCreateDamage (pPixmap))
-		FatalError (XGL_SW_FAILURE_STRING);
-	}
-
-	if (width && height)
-	{
-	    if (width == 1 && height == 1)
-	    {
-		pPixmapPriv->acceleratedTile = TRUE;
-	    }
-	    else if (features & GLITZ_FEATURE_TEXTURE_BORDER_CLAMP_MASK)
-	    {
-		if ((features & GLITZ_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK) ||
-		    (POWER_OF_TWO (width) && POWER_OF_TWO (height)))
-		    pPixmapPriv->acceleratedTile = TRUE;
-	    }
-	}
-    }
-
-    return TRUE;
-}
-
-PixmapPtr
-xglCreatePixmap (ScreenPtr  pScreen,
-		 int	    width,
-		 int	    height,
-		 int	    depth)
-{
-    xglPixmapPtr pPixmapPriv;
-    PixmapPtr	 pPixmap;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    pPixmap = AllocatePixmap (pScreen, 0);
-    if (!pPixmap)
-	return NullPixmap;
-
-    pPixmap->drawable.type = DRAWABLE_PIXMAP;
-    pPixmap->drawable.class = 0;
-    pPixmap->drawable.pScreen = pScreen;
-    pPixmap->drawable.depth = depth;
-    pPixmap->drawable.bitsPerPixel = BitsPerPixel (depth);
-    pPixmap->drawable.id = 0;
-    pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-    pPixmap->drawable.x = 0;
-    pPixmap->drawable.y = 0;
-    pPixmap->drawable.width = width;
-    pPixmap->drawable.height = height;
-
-#ifdef COMPOSITE
-    pPixmap->screen_x = 0;
-    pPixmap->screen_y = 0;
-#endif
-
-    pPixmap->devKind = 0;
-    pPixmap->refcnt = 1;
-    pPixmap->devPrivate.ptr = 0;
-
-    pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
-
-    pPixmapPriv->pVisual = NULL;
-    pPixmapPriv->pDamage = NULL;
-
-    if (!xglPixmapSurfaceInit (pPixmap, pScreenPriv->features, width, height))
-	return NullPixmap;
-
-    pPixmapPriv->buffer = NULL;
-    pPixmapPriv->bits = (pointer) 0;
-    pPixmapPriv->stride = 0;
-    pPixmapPriv->pGeometry = NULL;
-    pPixmapPriv->allBits = TRUE;
-
-    pPixmapPriv->damageBox = miEmptyBox;
-
-    return pPixmap;
-}
-
-void
-xglFiniPixmap (PixmapPtr pPixmap)
-{
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    if (pPixmap->devPrivate.ptr)
-    {
-	if (pPixmapPriv->buffer)
-	    glitz_buffer_unmap (pPixmapPriv->buffer);
-    }
-
-    if (pPixmapPriv->pGeometry)
-	GEOMETRY_UNINIT (pPixmapPriv->pGeometry);
-
-    if (pPixmapPriv->buffer)
-	glitz_buffer_destroy (pPixmapPriv->buffer);
-
-    if (pPixmapPriv->bits)
-	xfree (pPixmapPriv->bits);
-
-    REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
-
-    if (pPixmapPriv->drawable)
-	glitz_drawable_destroy (pPixmapPriv->drawable);
-
-    if (pPixmapPriv->surface) {
-    	/* leaving because texture destruction can occur and flush primitives */
-        __glXleaveServer(FALSE);
-	glitz_surface_destroy (pPixmapPriv->surface);
-        __glXenterServer(FALSE);
-    }
-}
-
-Bool
-xglDestroyPixmap (PixmapPtr pPixmap)
-{
-    if (--pPixmap->refcnt)
-	return TRUE;
-
-    xglFiniPixmap (pPixmap);
-
-    xfree (pPixmap);
-
-    return TRUE;
-}
-
-Bool
-xglModifyPixmapHeader (PixmapPtr pPixmap,
-		       int	 width,
-		       int	 height,
-		       int	 depth,
-		       int	 bitsPerPixel,
-		       int	 devKind,
-		       pointer	 pPixData)
-{
-    xglScreenPtr pScreenPriv;
-    xglPixmapPtr pPixmapPriv;
-    int		 oldWidth, oldHeight;
-
-    if (!pPixmap)
-	return FALSE;
-
-    pScreenPriv = XGL_GET_SCREEN_PRIV (pPixmap->drawable.pScreen);
-    pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
-
-    oldWidth  = pPixmap->drawable.width;
-    oldHeight = pPixmap->drawable.height;
-
-    if ((width > 0) && (height > 0) && (depth > 0) && (bitsPerPixel > 0) &&
-	(devKind > 0) && pPixData)
-    {
-	pPixmap->drawable.depth = depth;
-	pPixmap->drawable.bitsPerPixel = bitsPerPixel;
-	pPixmap->drawable.id = 0;
-	pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-	pPixmap->drawable.x = 0;
-	pPixmap->drawable.y = 0;
-	pPixmap->drawable.width = width;
-	pPixmap->drawable.height = height;
-	pPixmapPriv->stride = devKind;
-	pPixmap->refcnt = 1;
-    }
-    else
-    {
-	if (width > 0)
-	    pPixmap->drawable.width = width;
-
-	if (height > 0)
-	    pPixmap->drawable.height = height;
-
-	if (depth > 0)
-	    pPixmap->drawable.depth = depth;
-
-	if (bitsPerPixel > 0)
-	    pPixmap->drawable.bitsPerPixel = bitsPerPixel;
-	else if ((bitsPerPixel < 0) && (depth > 0))
-	    pPixmap->drawable.bitsPerPixel = BitsPerPixel (depth);
-
-	if (devKind > 0)
-	    pPixmapPriv->stride = devKind;
-	else if ((devKind < 0) && ((width > 0) || (depth > 0)))
-	    pPixmapPriv->stride = PixmapBytePad (pPixmap->drawable.width,
-						 pPixmap->drawable.depth);
-    }
-
-    if (pPixmap->drawable.width  != oldWidth ||
-	pPixmap->drawable.height != oldHeight)
-    {
-	pPixmapPriv->pVisual = NULL;
-	pPixmapPriv->target  = xglPixmapTargetNo;
-
-	if (pPixmapPriv->drawable)
-	    glitz_drawable_destroy (pPixmapPriv->drawable);
-
-	if (pPixmapPriv->surface)
-	    glitz_surface_destroy (pPixmapPriv->surface);
-
-	REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
-
-	if (!xglPixmapSurfaceInit (pPixmap,
-				   pScreenPriv->features,
-				   pPixmap->drawable.width,
-				   pPixmap->drawable.height))
-	    return FALSE;
-    }
-
-    if (pPixData)
-    {
-	BoxRec box;
-
-	if (pPixmap->devPrivate.ptr)
-	{
-	    if (pPixmapPriv->buffer)
-		glitz_buffer_unmap (pPixmapPriv->buffer);
-
-	    pPixmap->devPrivate.ptr = 0;
-	}
-
-	if (pPixmapPriv->pGeometry)
-	{
-	    GEOMETRY_UNINIT (pPixmapPriv->pGeometry);
-	    pPixmapPriv->pGeometry = NULL;
-	}
-
-	if (pPixmapPriv->buffer)
-	    glitz_buffer_destroy (pPixmapPriv->buffer);
-
-	if (pPixmapPriv->bits)
-	    xfree (pPixmapPriv->bits);
-
-	pPixmapPriv->bits = (pointer) 0;
-	pPixmapPriv->buffer = glitz_buffer_create_for_data (pPixData);
-	if (!pPixmapPriv->buffer)
-	    return FALSE;
-
-	pPixmapPriv->allBits = TRUE;
-
-	box.x1 = 0;
-	box.y1 = 0;
-	box.x2 = pPixmap->drawable.width;
-	box.y2 = pPixmap->drawable.height;
-
-	REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
-	REGION_INIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion,
-		     &box, 1);
-
-	if (pPixmapPriv->pDamage)
-	{
-	    RegionPtr pRegion;
-
-	    pRegion = DamageRegion (pPixmapPriv->pDamage);
-
-	    REGION_UNINIT (pPixmap->drawable.pScreen, pRegion);
-	    REGION_INIT (pPixmap->drawable.pScreen, pRegion, NullBox, 0);
-	    REGION_SUBTRACT (pPixmap->drawable.pScreen, pRegion,
-			     &pPixmapPriv->bitRegion, pRegion);
-
-	}
-    }
-
-    /*
-     * Screen pixmap
-     */
-    if (!pScreenPriv->pScreenPixmap || pScreenPriv->pScreenPixmap == pPixmap)
-    {
-	if (!pPixmapPriv->drawable)
-	{
-	    glitz_drawable_reference (pScreenPriv->drawable);
-	    pPixmapPriv->drawable = pScreenPriv->drawable;
-	}
-
-	if (!pPixmapPriv->surface)
-	{
-	    glitz_surface_reference (pScreenPriv->surface);
-	    pPixmapPriv->surface = pScreenPriv->surface;
-	}
-
-	pPixmapPriv->pVisual = pScreenPriv->rootVisual;
-	pPixmapPriv->target  = xglPixmapTargetIn;
-
-	if (!pScreenPriv->pScreenPixmap)
-	    pScreenPriv->pScreenPixmap = pPixmap;
-    }
-
-    return TRUE;
-}
-
-RegionPtr
-xglPixmapToRegion (PixmapPtr pPixmap)
-{
-    ScreenPtr pScreen = pPixmap->drawable.pScreen;
-    RegionPtr pRegion;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    if (!xglSyncBits (&pPixmap->drawable, NullBox))
-	FatalError (XGL_SW_FAILURE_STRING);
-
-    XGL_SCREEN_UNWRAP (BitmapToRegion);
-    pRegion = (*pScreen->BitmapToRegion) (pPixmap);
-    XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion);
-
-    return pRegion;
-}
-
-xglGeometryPtr
-xglPixmapToGeometry (PixmapPtr pPixmap,
-		     int       xOff,
-		     int       yOff)
-{
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    if (pPixmap->devPrivate.ptr)
-	xglUnmapPixmapBits (pPixmap);
-
-    if (!pPixmapPriv->pGeometry)
-    {
-	xglGeometryPtr pGeometry;
-
-	if (!pPixmapPriv->buffer)
-	{
-	    if (!xglAllocatePixmapBits (pPixmap,
-					XGL_PIXMAP_USAGE_HINT_DEFAULT))
-		return NULL;
-	}
-
-	pGeometry = xalloc (sizeof (xglGeometryRec));
-	if (!pGeometry)
-	    return NULL;
-
-	GEOMETRY_INIT (pPixmap->drawable.pScreen, pGeometry,
-		       GLITZ_GEOMETRY_TYPE_BITMAP,
-		       GEOMETRY_USAGE_DYNAMIC, 0);
-
-	GEOMETRY_SET_BUFFER (pGeometry, pPixmapPriv->buffer);
-
-	if (pPixmapPriv->stride < 0)
-	{
-	    pGeometry->f.bitmap.bytes_per_line = -pPixmapPriv->stride;
-	    pGeometry->f.bitmap.scanline_order =
-		GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
-	}
-	else
-	{
-	    pGeometry->f.bitmap.bytes_per_line = pPixmapPriv->stride;
-	    pGeometry->f.bitmap.scanline_order =
-		GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
-	}
-
-	pGeometry->f.bitmap.pad = ((1 + FB_MASK) >> FB_SHIFT) *
-	    sizeof (FbBits);
-	pGeometry->width = pPixmap->drawable.width;
-	pGeometry->count = pPixmap->drawable.height;
-
-	pPixmapPriv->pGeometry = pGeometry;
-    }
-
-    pPixmapPriv->pGeometry->xOff = xOff << 16;
-    pPixmapPriv->pGeometry->yOff = yOff << 16;
-
-    return pPixmapPriv->pGeometry;
-}
-
-Bool
-xglCreatePixmapSurface (PixmapPtr pPixmap)
-{
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    if (!pPixmapPriv->surface)
-    {
-	XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
-
-	if (!pPixmapPriv->pVisual || !pPixmapPriv->pVisual->format.surface)
-	    return FALSE;
-
-	__glXleaveServer(FALSE);
-	pPixmapPriv->surface =
-	    glitz_surface_create (pScreenPriv->drawable,
-				  pPixmapPriv->pVisual->format.surface,
-				  pPixmap->drawable.width,
-				  pPixmap->drawable.height,
-				  0, NULL);
-	__glXenterServer(FALSE);
-	if (!pPixmapPriv->surface)
-	{
-	    pPixmapPriv->pVisual = NULL;
-	    pPixmapPriv->target  = xglPixmapTargetNo;
-
-	    return FALSE;
-	}
-    }
-
-    return TRUE;
-}
-
-Bool
-xglAllocatePixmapBits (PixmapPtr pPixmap, int hint)
-{
-    int width, height, bpp, stride;
-
-    XGL_PIXMAP_PRIV (pPixmap);
-    XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
-
-    width  = pPixmap->drawable.width;
-    height = pPixmap->drawable.height;
-    bpp    = pPixmap->drawable.bitsPerPixel;
-
-    stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * (int) sizeof (FbBits);
-
-    if (stride)
-    {
-	glitz_buffer_t *buffer;
-
-	if ((pScreenPriv->pboMask & bpp) && hint)
-	{
-	    buffer = glitz_pixel_buffer_create (pScreenPriv->drawable,
-						NULL, height * stride,
-						XGL_PIXMAP_USAGE_HINT (hint));
-	}
-	else
-	{
-	    pPixmapPriv->bits = xalloc (height * stride);
-	    if (!pPixmapPriv->bits)
-		return FALSE;
-
-	    buffer = glitz_buffer_create_for_data (pPixmapPriv->bits);
-	}
-
-	if (!buffer)
-	{
-	    if (pPixmapPriv->bits)
-		xfree (pPixmapPriv->bits);
-	    pPixmapPriv->bits = NULL;
-	    return FALSE;
-	}
-	pPixmapPriv->buffer = buffer;
-    }
-
-    if (pScreenPriv->yInverted)
-	pPixmapPriv->stride = stride;
-    else
-	pPixmapPriv->stride = -stride;
-
-    return TRUE;
-}
-
-Bool
-xglMapPixmapBits (PixmapPtr pPixmap)
-{
-    if (!pPixmap->devPrivate.ptr)
-    {
-	CARD8 *bits;
-
-	XGL_PIXMAP_PRIV (pPixmap);
-
-	if (!pPixmapPriv->buffer)
-	    if (!xglAllocatePixmapBits (pPixmap,
-					XGL_PIXMAP_USAGE_HINT_DEFAULT))
-		return FALSE;
-
-	bits = glitz_buffer_map (pPixmapPriv->buffer,
-				 GLITZ_BUFFER_ACCESS_READ_WRITE);
-	if (!bits)
-	    return FALSE;
-
-	pPixmap->devKind = pPixmapPriv->stride;
-	if (pPixmapPriv->stride < 0)
-	{
-	    pPixmap->devPrivate.ptr = bits +
-		(pPixmap->drawable.height - 1) * -pPixmapPriv->stride;
-	}
-	else
-	{
-	    pPixmap->devPrivate.ptr = bits;
-	}
-    }
-
-    return TRUE;
-}
-
-Bool
-xglUnmapPixmapBits (PixmapPtr pPixmap)
-{
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    pPixmap->devKind = 0;
-    pPixmap->devPrivate.ptr = 0;
-
-    if (pPixmapPriv->buffer)
-	if (glitz_buffer_unmap (pPixmapPriv->buffer))
-	    return FALSE;
-
-    return TRUE;
-}
-
-Bool
-xglCheckPixmapSize (PixmapPtr		 pPixmap,
-		    xglSizeConstraintPtr pSize)
-{
-    if (pPixmap->drawable.width  < pSize->minWidth ||
-	pPixmap->drawable.height < pSize->minHeight)
-	return FALSE;
-
-    if (pPixmap->drawable.width  > pSize->aboveWidth ||
-	pPixmap->drawable.height > pSize->aboveHeight)
-	return TRUE;
-
-    return FALSE;
-}
-
-void
-xglEnablePixmapAccel (PixmapPtr	      pPixmap,
-		      xglAccelInfoPtr pAccel)
-{
-    XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    if (pAccel->enabled && xglCheckPixmapSize (pPixmap, &pAccel->size))
-    {
-	xglVisualPtr v;
-
-	if (pAccel->pbuffer)
-	{
-	    for (v = pScreenPriv->pVisual; v; v = v->next)
-	    {
-		if (v->pPixel->depth != pPixmap->drawable.depth)
-		    continue;
-
-		if (v->format.drawable && v->pbuffer)
-		    break;
-	    }
-	}
-	else
-	{
-	    for (v = pScreenPriv->pVisual; v; v = v->next)
-	    {
-		if (v->pPixel->depth != pPixmap->drawable.depth)
-		    continue;
-
-		if (v->format.drawable && !v->pbuffer)
-		    break;
-	    }
-	}
-
-	if (v)
-	{
-	    xglSetPixmapVisual (pPixmap, v);
-	    if (!pPixmapPriv->target)
-		pPixmapPriv->target = xglPixmapTargetOut;
-	}
-    }
-}
diff --git a/hw/xgl/xglshm.c b/hw/xgl/xglshm.c
deleted file mode 100644
index 52a8aab..0000000
--- a/hw/xgl/xglshm.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright © 2005 Novell, Inc.
- *
- * 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
- * Novell, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * Novell, Inc. makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL NOVELL, INC. 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-#include "gcstruct.h"
-
-#ifdef MITSHM
-
-void
-xglShmPutImage (DrawablePtr  pDrawable,
-		GCPtr	     pGC,
-		int	     depth,
-		unsigned int format,
-		int	     w,
-		int	     h,
-		int	     sx,
-		int	     sy,
-		int	     sw,
-		int	     sh,
-		int	     dx,
-		int	     dy,
-		char	     *data)
-{
-    ScreenPtr pScreen = pDrawable->pScreen;
-    PixmapPtr pPixmapHeader = NULL;
-    PixmapPtr pPixmap;
-    int	      saveTarget;
-
-    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
-
-    if ((format == ZPixmap) || (depth == 1))
-    {
-	pPixmap = pPixmapHeader =
-	    GetScratchPixmapHeader (pScreen, w, h, depth,
-				    BitsPerPixel (depth),
-				    PixmapBytePad (w, depth),
-				    (pointer) data);
-
-	/* disable any possible acceleration of this pixmap */
-	if (pPixmap)
-	    xglSetPixmapVisual (pPixmap, 0);
-    }
-    else
-    {
-	pPixmap = (*pScreen->CreatePixmap) (pScreen, sw, sh, depth);
-	if (pPixmap)
-	{
-	    GCPtr pScratchGC;
-
-	    if (!xglAllocatePixmapBits (pPixmap,
-					XGL_PIXMAP_USAGE_HINT_DEFAULT))
-	    {
-		(*pScreen->DestroyPixmap) (pPixmap);
-		return;
-	    }
-
-	    xglSetPixmapVisual (pPixmap, 0);
-
-	    pScratchGC = GetScratchGC (depth, pScreen);
-	    if (!pScratchGC)
-	    {
-		(*pScreen->DestroyPixmap) (pPixmap);
-		return;
-	    }
-
-	    ValidateGC ((DrawablePtr) pPixmap, pScratchGC);
-	    (*pGC->ops->PutImage) ((DrawablePtr) pPixmap, pScratchGC, depth,
-				   -sx, -sy, w, h, 0,
-				   (format == XYPixmap) ? XYPixmap : ZPixmap,
-				   data);
-
-	    FreeScratchGC (pScratchGC);
-
-	    sx = sy = 0;
-	}
-    }
-
-    if (!pPixmap)
-	return;
-
-    /* CopyArea should always be done in software */
-    saveTarget = pPixmapPriv->target;
-    pPixmapPriv->target = xglPixmapTargetNo;
-
-    if (format == XYBitmap)
-	(*pGC->ops->CopyPlane) ((DrawablePtr) pPixmap, pDrawable, pGC,
-				sx, sy, sw, sh, dx, dy, 1L);
-    else
-	(*pGC->ops->CopyArea) ((DrawablePtr) pPixmap, pDrawable, pGC,
-			       sx, sy, sw, sh, dx, dy);
-
-    pPixmapPriv->target = saveTarget;
-
-    if (pPixmapHeader)
-	FreeScratchPixmapHeader (pPixmapHeader);
-    else
-	(*pScreen->DestroyPixmap) (pPixmap);
-}
-
-#endif
diff --git a/hw/xgl/xglsolid.c b/hw/xgl/xglsolid.c
deleted file mode 100644
index a3dc281..0000000
--- a/hw/xgl/xglsolid.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-#include "glxserver.h"
-#include "glapi.h"
-#include "glthread.h"
-#include "dispatch.h"
-
-#include "xgl.h"
-#include "gcstruct.h"
-#include <X11/fonts/fontstruct.h>
-#include "dixfontstr.h"
-
-Bool
-xglSolid (DrawablePtr	   pDrawable,
-	  glitz_operator_t op,
-	  glitz_surface_t  *solid,
-	  xglGeometryPtr   pGeometry,
-	  int		   x,
-	  int		   y,
-	  int		   width,
-	  int		   height,
-	  BoxPtr	   pBox,
-	  int		   nBox)
-{
-    glitz_surface_t *surface;
-    int		    xOff, yOff;
-
-    if (nBox < 1)
-	return TRUE;
-
-    if (!xglPrepareTarget (pDrawable))
-	return FALSE;
-
-    XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
-
-    if (pGeometry)
-    {
-	glitz_surface_set_clip_region (surface, xOff, yOff,
-				       (glitz_box_t *) pBox, nBox);
-    }
-    else
-    {
-	pGeometry = xglGetScratchVertexGeometry (pDrawable->pScreen, 4 * nBox);
-	GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox);
-    }
-
-    GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
-
-    if (!GEOMETRY_ENABLE (pGeometry, surface))
-	return FALSE;
-
-    __glXleaveServer(FALSE);
-    glitz_composite (op,
-		     solid, NULL, surface,
-		     0, 0,
-		     0, 0,
-		     x + xOff,
-		     y + yOff,
-		     width, height);
-    __glXenterServer(FALSE);
-
-    glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
-
-    if (glitz_surface_get_status (surface))
-	return FALSE;
-
-    return TRUE;
-}
-
-Bool
-xglSolidGlyph (DrawablePtr  pDrawable,
-	       GCPtr	    pGC,
-	       int	    x,
-	       int	    y,
-	       unsigned int nGlyph,
-	       CharInfoPtr  *ppci,
-	       pointer      pglyphBase)
-{
-    xglGeometryRec geometry;
-    int		   xBack, widthBack;
-    int		   yBack, heightBack;
-
-    XGL_GC_PRIV (pGC);
-
-    x += pDrawable->x;
-    y += pDrawable->y;
-
-    GEOMETRY_INIT (pDrawable->pScreen, &geometry,
-		   GLITZ_GEOMETRY_TYPE_BITMAP,
-		   GEOMETRY_USAGE_SYSMEM, 0);
-
-    GEOMETRY_FOR_GLYPH (pDrawable->pScreen,
-			&geometry,
-			nGlyph,
-			ppci,
-			pglyphBase);
-
-    GEOMETRY_TRANSLATE (&geometry, x, y);
-
-    widthBack = 0;
-    while (nGlyph--)
-	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 (xglSolid (pDrawable,
-		  pGCPriv->op,
-		  pGCPriv->bg,
-		  NULL,
-		  xBack,
-		  yBack,
-		  widthBack,
-		  heightBack,
-		  REGION_RECTS (pGC->pCompositeClip),
-		  REGION_NUM_RECTS (pGC->pCompositeClip)))
-    {
-	if (xglSolid (pDrawable,
-		      pGCPriv->op,
-		      pGCPriv->fg,
-		      &geometry,
-		      xBack,
-		      yBack,
-		      widthBack,
-		      heightBack,
-		      REGION_RECTS (pGC->pCompositeClip),
-		      REGION_NUM_RECTS (pGC->pCompositeClip)))
-	{
-	    GEOMETRY_UNINIT (&geometry);
-	    xglAddCurrentBitDamage (pDrawable);
-	    return TRUE;
-	}
-    }
-
-    GEOMETRY_UNINIT (&geometry);
-    return FALSE;
-}
diff --git a/hw/xgl/xglsync.c b/hw/xgl/xglsync.c
deleted file mode 100644
index 2daef6e..0000000
--- a/hw/xgl/xglsync.c
+++ /dev/null
@@ -1,497 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-
-Bool
-xglSyncBits (DrawablePtr pDrawable,
-	     BoxPtr	 pExtents)
-{
-    RegionRec region;
-    BoxRec    box;
-
-    XGL_DRAWABLE_PIXMAP (pDrawable);
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    if (pPixmapPriv->allBits)
-	return xglMapPixmapBits (pPixmap);
-
-    if (pPixmapPriv->target == xglPixmapTargetIn && pExtents)
-    {
-	box.x1 = 0;
-	box.y1 = 0;
-	box.x2 = pPixmap->drawable.width;
-	box.y2 = pPixmap->drawable.height;
-	if (pExtents->x1 > box.x1)
-	    box.x1 = pExtents->x1;
-	if (pExtents->y1 > box.y1)
-	    box.y1 = pExtents->y1;
-	if (pExtents->x2 < box.x2)
-	    box.x2 = pExtents->x2;
-	if (pExtents->y2 < box.y2)
-	    box.y2 = pExtents->y2;
-
-	if (box.x2 <= box.x1 || box.y2 <= box.y1)
-	    return xglMapPixmapBits (pPixmap);
-
-	if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
-	{
-	    switch (RECT_IN_REGION (pDrawable->pScreen,
-				    &pPixmapPriv->bitRegion,
-				    &box)) {
-	    case rgnIN:
-		REGION_INIT (pDrawable->pScreen, &region, NullBox, 0);
-		break;
-	    case rgnOUT:
-		REGION_INIT (pDrawable->pScreen, &region, &box, 1);
-		REGION_UNION (pDrawable->pScreen,
-			      &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
-			      &region);
-		break;
-	    case rgnPART:
-		REGION_INIT (pDrawable->pScreen, &region, &box, 1);
-		REGION_SUBTRACT (pDrawable->pScreen, &region, &region,
-				 &pPixmapPriv->bitRegion);
-		REGION_UNION (pDrawable->pScreen,
-			      &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
-			      &region);
-		break;
-	    }
-	}
-	else
-	{
-	    REGION_INIT (pDrawable->pScreen, &region, &box, 1);
-	    REGION_SUBTRACT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
-			     &region, &pPixmapPriv->bitRegion);
-	}
-
-	if (REGION_NUM_RECTS (&pPixmapPriv->bitRegion) == 1)
-	{
-	    BoxPtr pBox;
-
-	    pBox = REGION_RECTS (&pPixmapPriv->bitRegion);
-
-	    if (pBox->x1 <= 0			    &&
-		pBox->y1 <= 0			    &&
-		pBox->x2 >= pPixmap->drawable.width &&
-		pBox->y2 >= pPixmap->drawable.height)
-		pPixmapPriv->allBits = TRUE;
-	}
-    }
-    else
-    {
-	box.x1 = 0;
-	box.y1 = 0;
-	box.x2 = pPixmap->drawable.width;
-	box.y2 = pPixmap->drawable.height;
-
-	REGION_INIT (pDrawable->pScreen, &region, &box, 1);
-	REGION_SUBTRACT (pDrawable->pScreen, &region, &region,
-			 &pPixmapPriv->bitRegion);
-
-	pPixmapPriv->allBits = TRUE;
-    }
-
-    if (!pPixmapPriv->buffer)
-	if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
-	    return FALSE;
-
-    if (REGION_NOTEMPTY (pDrawable->pScreen, &region) && pPixmapPriv->surface)
-    {
-	glitz_pixel_format_t format;
-	BoxPtr		     pBox;
-	BoxPtr		     pExt;
-	int		     nBox;
-
-	if (!xglSyncSurface (pDrawable))
-	    FatalError (XGL_SW_FAILURE_STRING);
-
-	xglUnmapPixmapBits (pPixmap);
-
-	pBox = REGION_RECTS (&region);
-	nBox = REGION_NUM_RECTS (&region);
-	pExt = REGION_EXTENTS (pDrawable->pScreen, &region);
-
-	format.fourcc  = GLITZ_FOURCC_RGB;
-	format.masks   = pPixmapPriv->pVisual->pPixel->masks;
-	format.xoffset = pExt->x1;
-
-	if (pPixmapPriv->stride < 0)
-	{
-	    format.skip_lines	  = pPixmap->drawable.height - pExt->y2;
-	    format.bytes_per_line = -pPixmapPriv->stride;
-	    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
-	}
-	else
-	{
-	    format.skip_lines	  = pExt->y1;
-	    format.bytes_per_line = pPixmapPriv->stride;
-	    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
-	}
-
-	glitz_surface_set_clip_region (pPixmapPriv->surface,
-				       0, 0, (glitz_box_t *) pBox, nBox);
-
-	__glXleaveServer(FALSE);
-	glitz_get_pixels (pPixmapPriv->surface,
-			  pExt->x1,
-			  pExt->y1,
-			  pExt->x2 - pExt->x1,
-			  pExt->y2 - pExt->y1,
-			  &format,
-			  pPixmapPriv->buffer);
-	__glXenterServer(FALSE);
-
-	glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, NULL, 0);
-    }
-
-    REGION_UNINIT (pDrawable->pScreen, &region);
-
-    if (pPixmapPriv->allBits)
-    {
-	box.x1 = 0;
-	box.y1 = 0;
-	box.x2 = pPixmap->drawable.width;
-	box.y2 = pPixmap->drawable.height;
-
-	REGION_UNINIT (pDrawable->pScreen, &pPixmapPriv->bitRegion);
-	REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion, &box, 1);
-    }
-
-    return xglMapPixmapBits (pPixmap);
-}
-
-void
-xglSyncDamageBoxBits (DrawablePtr pDrawable)
-{
-    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
-
-    if (!xglSyncBits (pDrawable, &pPixmapPriv->damageBox))
-	FatalError (XGL_SW_FAILURE_STRING);
-}
-
-Bool
-xglSyncSurface (DrawablePtr pDrawable)
-{
-    RegionPtr pRegion;
-
-    XGL_DRAWABLE_PIXMAP (pDrawable);
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    if (!pPixmapPriv->surface)
-    {
-	if (!xglCreatePixmapSurface (pPixmap))
-	    return FALSE;
-    }
-
-    pRegion = DamageRegion (pPixmapPriv->pDamage);
-
-    if (pPixmapPriv->surface && REGION_NOTEMPTY (pDrawable->pScreen, pRegion))
-    {
-	glitz_pixel_format_t format;
-	BoxPtr		     pBox;
-	BoxPtr		     pExt;
-	int		     nBox;
-
-	xglUnmapPixmapBits (pPixmap);
-
-	nBox = REGION_NUM_RECTS (pRegion);
-	pBox = REGION_RECTS (pRegion);
-	pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
-
-	format.fourcc  = pPixmapPriv->pVisual->format.surface->color.fourcc;
-	format.masks   = pPixmapPriv->pVisual->pPixel->masks;
-	format.xoffset = pExt->x1;
-
-	if (pPixmapPriv->stride < 0)
-	{
-	    format.skip_lines	  = pPixmap->drawable.height - pExt->y2;
-	    format.bytes_per_line = -pPixmapPriv->stride;
-	    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
-	}
-	else
-	{
-	    format.skip_lines	  = pExt->y1;
-	    format.bytes_per_line = pPixmapPriv->stride;
-	    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
-	}
-
-	/* If all bits are up to date we can avoid transferring a large set
-	   of boxes by transferring the extents box instead. */
-	if (pPixmapPriv->allBits && nBox != 1)
-	{
-	    /* This many boxes. It is likely more efficient to always transfer
-	       the extents box instead. */
-	    if (nBox > 64)
-	    {
-		pBox = pExt;
-		nBox = 1;
-	    }
-	    else
-	    {
-		int i, w, e, r = 0;
-
-		for (i = 0; i < nBox; i++)
-		    r += (pBox[i].x2 - pBox[i].x1) * (pBox[i].y2 - pBox[i].y1);
-
-		e = (pExt->x2 - pExt->x1) * (pExt->y2 - pExt->y1);
-		w = e - r;
-
-		/* r, is the area of all boxes. e, is the are for the
-		   extents. w, is the area that doesn't need to be
-		   transferred.
-
-		   If w per box is less than 2 times the area of all
-		   boxes, transferring the extents has been proved more
-		   efficient. */
-		if ((w / nBox) < (r << 1))
-		{
-		    pBox = pExt;
-		    nBox = 1;
-		}
-	    }
-	}
-
-	glitz_surface_set_clip_region (pPixmapPriv->surface,
-				       0, 0, (glitz_box_t *) pBox, nBox);
-
-	__glXleaveServer(FALSE);
-	glitz_set_pixels (pPixmapPriv->surface,
-			  pExt->x1,
-			  pExt->y1,
-			  pExt->x2 - pExt->x1,
-			  pExt->y2 - pExt->y1,
-			  &format,
-			  pPixmapPriv->buffer);
-	__glXenterServer(FALSE);
-
-	glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, NULL, 0);
-
-	REGION_EMPTY (pDrawable->pScreen, pRegion);
-    }
-
-    return TRUE;
-}
-
-Bool
-xglPrepareTarget (DrawablePtr pDrawable)
-{
-    XGL_DRAWABLE_PIXMAP (pDrawable);
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    switch (pPixmapPriv->target) {
-    case xglPixmapTargetNo:
-	break;
-    case xglPixmapTargetOut:
-	if (xglSyncSurface (pDrawable))
-	{
-	    glitz_drawable_format_t *format;
-
-	    XGL_SCREEN_PRIV (pDrawable->pScreen);
-
-	    if (!pPixmapPriv->drawable)
-	    {
-		unsigned int width, height;
-
-		format = pPixmapPriv->pVisual->format.drawable;
-		width  = pPixmap->drawable.width;
-		height = pPixmap->drawable.height;
-
-		if (pPixmapPriv->pVisual->pbuffer)
-		{
-		    pPixmapPriv->drawable =
-			glitz_create_pbuffer_drawable (pScreenPriv->drawable,
-						       format, width, height);
-		}
-		else
-		{
-		    pPixmapPriv->drawable =
-			glitz_create_drawable (pScreenPriv->drawable,
-					       format, width, height);
-		}
-	    }
-
-	    if (pPixmapPriv->drawable)
-	    {
-		glitz_surface_attach (pPixmapPriv->surface,
-				      pPixmapPriv->drawable,
-				      GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
-
-		pPixmapPriv->target = xglPixmapTargetIn;
-
-		return TRUE;
-	    }
-	}
-	pPixmapPriv->target = xglPixmapTargetNo;
-	break;
-    case xglPixmapTargetIn:
-	if (xglSyncSurface (pDrawable))
-	    return TRUE;
-	break;
-    }
-
-    return FALSE;
-}
-
-void
-xglAddSurfaceDamage (DrawablePtr pDrawable,
-		     RegionPtr   pRegion)
-{
-    glitz_surface_t *surface;
-    int		    xOff, yOff;
-
-#if 0
-    miPrintRegion(pRegion);
-#endif
-
-    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
-
-    pPixmapPriv->damageBox = miEmptyBox;
-
-    XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
-
-    if (xOff || yOff)
-	REGION_TRANSLATE (pDrawable->pScreen, pRegion, xOff, yOff);
-
-    if (pPixmapPriv->pDamage)
-    {
-	RegionPtr pDamageRegion;
-
-	pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
-
-	REGION_UNION (pDrawable->pScreen,
-		      pDamageRegion, pDamageRegion,
-		      pRegion);
-    }
-
-    REGION_UNION (pDrawable->pScreen,
-		  &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
-		  pRegion);
-
-    if (xOff || yOff)
-	REGION_TRANSLATE (pDrawable->pScreen, pRegion, -xOff, -yOff);
-}
-
-void
-xglAddCurrentSurfaceDamage (DrawablePtr pDrawable)
-{
-    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
-
-    if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
-    {
-	RegionRec region;
-
-	REGION_INIT (pDrawable->pScreen, &region, &pPixmapPriv->damageBox, 1);
-
-	if (pPixmapPriv->pDamage)
-	{
-	    RegionPtr pDamageRegion;
-
-	    pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
-
-	    REGION_UNION (pDrawable->pScreen,
-			  pDamageRegion, pDamageRegion,
-			  &region);
-	}
-
-	REGION_UNION (pDrawable->pScreen,
-		      &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
-		      &region);
-
-	REGION_UNINIT (pDrawable->pScreen, &region);
-
-	pPixmapPriv->damageBox = miEmptyBox;
-    }
-}
-
-void
-xglAddBitDamage (DrawablePtr pDrawable,
-		 RegionPtr   pRegion)
-{
-    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
-
-    if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
-    {
-	BoxPtr pBox;
-	BoxPtr pExt, pBitExt;
-	int    nBox;
-
-	pBox = REGION_RECTS (pRegion);
-	pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
-	nBox = REGION_NUM_RECTS (pRegion);
-
-	pBitExt = REGION_EXTENTS (pDrawable->pScreen, &pPixmapPriv->bitRegion);
-
-	if (pExt->x1 < pBitExt->x2 &&
-	    pExt->y1 < pBitExt->y2 &&
-	    pExt->x2 > pBitExt->x1 &&
-	    pExt->y2 > pBitExt->y1)
-	{
-	    while (nBox--)
-	    {
-		if (pBox->x1 < pBitExt->x2 &&
-		    pBox->y1 < pBitExt->y2 &&
-		    pBox->x2 > pBitExt->x1 &&
-		    pBox->y2 > pBitExt->y1)
-		{
-		    REGION_UNINIT (pDrawable->pScreen,
-				   &pPixmapPriv->bitRegion);
-		    REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
-				 NullBox, 0);
-		    pPixmapPriv->allBits = FALSE;
-		    return;
-		}
-
-		pBox++;
-	    }
-	}
-    }
-}
-
-void
-xglAddCurrentBitDamage (DrawablePtr pDrawable)
-{
-    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
-
-    if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
-    {
-	BoxPtr pBitExt;
-
-	pBitExt = REGION_EXTENTS (pDrawable->pScreen, &pPixmapPriv->bitRegion);
-
-	if (pPixmapPriv->damageBox.x1 < pBitExt->x2 &&
-	    pPixmapPriv->damageBox.y1 < pBitExt->y2 &&
-	    pPixmapPriv->damageBox.x2 > pBitExt->x1 &&
-	    pPixmapPriv->damageBox.y2 > pBitExt->y1)
-	{
-	    REGION_UNINIT (pDrawable->pScreen, &pPixmapPriv->bitRegion);
-	    REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
-			 NullBox, 0);
-	    pPixmapPriv->allBits = FALSE;
-	}
-    }
-
-    pPixmapPriv->damageBox = miEmptyBox;
-}
diff --git a/hw/xgl/xgltile.c b/hw/xgl/xgltile.c
deleted file mode 100644
index 200b381..0000000
--- a/hw/xgl/xgltile.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-#include "glxserver.h"
-#include "glapi.h"
-#include "glthread.h"
-#include "dispatch.h"
-
-
-#include "xgl.h"
-
-static glitz_geometry_format_t tileGeometryFormat = {
-    {
-	GLITZ_PRIMITIVE_QUADS,
-	GLITZ_DATA_TYPE_FLOAT,
-	sizeof (glitz_float_t) * 4,
-	GLITZ_VERTEX_ATTRIBUTE_SRC_COORD_MASK, {
-	    GLITZ_DATA_TYPE_FLOAT,
-	    GLITZ_COORDINATE_SIZE_XY,
-	    sizeof (glitz_float_t) * 2,
-	}, {
-	    0, 0, 0
-	}
-    }
-};
-
-xglGeometryPtr
-xglTiledBoxGeometry (PixmapPtr pTile,
-		     int       tileX,
-		     int       tileY,
-		     BoxPtr    pBox,
-		     int       nBox)
-{
-    ScreenPtr		pScreen = pTile->drawable.pScreen;
-    glitz_point_fixed_t p1, p2;
-    xglGeometryPtr	pGeometry;
-    glitz_float_t	x1, x2, y1, y2;
-    int			x, y, width, height, i;
-    int			xTile, yTile;
-    int			widthTile, heightTile;
-    int			widthTmp, xTmp, yTmp, xTileTmp;
-    int			tileWidth, tileHeight;
-    int			size = 0;
-    glitz_float_t	*data;
-
-    XGL_PIXMAP_PRIV (pTile);
-
-    tileWidth  = pTile->drawable.width;
-    tileHeight = pTile->drawable.height;
-
-    for (i = 0; i < nBox; i++)
-	size +=
-	    (((pBox[i].x2 - pBox[i].x1) / tileWidth) + 2) *
-	    (((pBox[i].y2 - pBox[i].y1) / tileHeight) + 2);
-
-    pGeometry = xglGetScratchVertexGeometryWithType (pScreen,
-						     GEOMETRY_DATA_TYPE_FLOAT,
-						     8 * size);
-
-    data = glitz_buffer_map (pGeometry->buffer,
-			     GLITZ_BUFFER_ACCESS_WRITE_ONLY);
-
-    while (nBox--)
-    {
-	x = pBox->x1;
-	y = pBox->y1;
-	width = pBox->x2 - pBox->x1;
-	height = pBox->y2 - pBox->y1;
-
-	xTile = MOD (tileX + x, tileWidth);
-	yTile = MOD (tileY + y, tileHeight);
-
-	yTmp = y;
-
-	while (height)
-	{
-	    heightTile = MIN (tileHeight - yTile, height);
-
-	    xTileTmp = xTile;
-	    widthTmp = width;
-	    xTmp     = x;
-
-	    while (widthTmp)
-	    {
-		widthTile = MIN (tileWidth - xTileTmp, widthTmp);
-
-		p1.x = xTileTmp << 16;
-		p1.y = yTile << 16;
-		p2.x = (xTileTmp + widthTile) << 16;
-		p2.y = (yTile + heightTile) << 16;
-
-		glitz_surface_translate_point (pPixmapPriv->surface, &p1, &p1);
-		glitz_surface_translate_point (pPixmapPriv->surface, &p2, &p2);
-
-		x1 = FIXED_TO_FLOAT (p1.x);
-		y1 = FIXED_TO_FLOAT (p1.y);
-		x2 = FIXED_TO_FLOAT (p2.x);
-		y2 = FIXED_TO_FLOAT (p2.y);
-
-		*data++ = (glitz_float_t) xTmp;
-		*data++ = (glitz_float_t) yTmp;
-		*data++ = x1;
-		*data++ = y1;
-
-		*data++ = (glitz_float_t) (xTmp + widthTile);
-		*data++ = (glitz_float_t) yTmp;
-		*data++ = x2;
-		*data++ = y1;
-
-		*data++ = (glitz_float_t) (xTmp + widthTile);
-		*data++ = (glitz_float_t) (yTmp + heightTile);
-		*data++ = x2;
-		*data++ = y2;
-
-		*data++ = (glitz_float_t) xTmp;
-		*data++ = (glitz_float_t) (yTmp + heightTile);
-		*data++ = x1;
-		*data++ = y2;
-
-		pGeometry->endOffset += sizeof (glitz_float_t) * 16;
-
-		xTileTmp  = 0;
-		xTmp     += widthTile;
-		widthTmp -= widthTile;
-	    }
-
-	    yTile   = 0;
-	    yTmp   += heightTile;
-	    height -= heightTile;
-	}
-
-	pBox++;
-    }
-
-    if (glitz_buffer_unmap (pGeometry->buffer))
-	return NULL;
-
-    pGeometry->f     = tileGeometryFormat;
-    pGeometry->count =
-	pGeometry->endOffset / tileGeometryFormat.vertex.bytes_per_vertex;
-
-    pPixmapPriv->pictureMask |= xglPCFillMask;
-    glitz_surface_set_fill (pPixmapPriv->surface, GLITZ_FILL_TRANSPARENT);
-
-    return pGeometry;
-}
-
-Bool
-xglTile (DrawablePtr	  pDrawable,
-	 glitz_operator_t op,
-	 PixmapPtr	  pTile,
-	 int		  tileX,
-	 int		  tileY,
-	 xglGeometryPtr	  pGeometry,
-	 int		  x,
-	 int		  y,
-	 int		  width,
-	 int		  height,
-	 BoxPtr		  pBox,
-	 int		  nBox)
-{
-    xglPixmapPtr    pTilePriv;
-    glitz_surface_t *surface;
-    int		    xOff, yOff;
-
-    if (nBox < 1)
-	return TRUE;
-
-    if (!xglPrepareTarget (pDrawable))
-	return FALSE;
-
-    if (!xglSyncSurface (&pTile->drawable))
-	return FALSE;
-
-    XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
-
-    pTilePriv = XGL_GET_PIXMAP_PRIV (pTile);
-
-    pTilePriv->pictureMask |= xglPCFilterMask | xglPCTransformMask;
-    glitz_surface_set_filter (pTilePriv->surface,
-			      GLITZ_FILTER_NEAREST,
-			      NULL, 0);
-    glitz_surface_set_transform (pTilePriv->surface, NULL);
-
-    if (pTilePriv->acceleratedTile)
-    {
-	if (pGeometry)
-	{
-	    glitz_surface_set_clip_region (surface, xOff, yOff,
-					   (glitz_box_t *) pBox, nBox);
-	    nBox = 0;
-	}
-	else
-	{
-	    pGeometry = xglGetScratchVertexGeometry (pDrawable->pScreen,
-						     4 * nBox);
-	    GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox);
-	}
-
-	GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
-
-	if (!GEOMETRY_ENABLE (pGeometry, surface))
-	    return FALSE;
-
-	pTilePriv->pictureMask |= xglPCFillMask;
-	glitz_surface_set_fill (pTilePriv->surface, GLITZ_FILL_REPEAT);
-
-	__glXleaveServer(FALSE);
-	glitz_composite (op,
-			 pTilePriv->surface, NULL, surface,
-			 x + tileX,
-			 y + tileY,
-			 0, 0,
-			 x + xOff,
-			 y + yOff,
-			 width, height);
-	__glXenterServer(FALSE);
-
-	glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
-
-	if (!glitz_surface_get_status (surface))
-	    return TRUE;
-
-	if (!nBox)
-	    return FALSE;
-    }
-    else
-    {
-	if (pGeometry)
-	    return FALSE;
-    }
-
-    pGeometry = xglTiledBoxGeometry (pTile, tileX, tileY, pBox, nBox);
-    if (!pGeometry)
-	return FALSE;
-
-    GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
-
-    if (!GEOMETRY_ENABLE (pGeometry, surface))
-	return FALSE;
-
-    __glXleaveServer(FALSE);
-    glitz_composite (op,
-		     pTilePriv->surface, NULL, surface,
-		     0, 0,
-		     0, 0,
-		     x + xOff,
-		     y + yOff,
-		     width, height);
-    __glXenterServer(FALSE);
-
-    if (glitz_surface_get_status (surface))
-	return FALSE;
-
-    return TRUE;
-}
diff --git a/hw/xgl/xgltrap.c b/hw/xgl/xgltrap.c
deleted file mode 100644
index 26e2bc4..0000000
--- a/hw/xgl/xgltrap.c
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * Copyright © 2005 Novell, Inc.
- *
- * 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
- * Novell, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * Novell, Inc. makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL NOVELL, INC. 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-#include "gcstruct.h"
-#include "damage.h"
-
-#ifdef RENDER
-
-#define XGL_TRAP_FALLBACK_PROLOGUE(pPicture, func) \
-    xglSyncDamageBoxBits (pPicture->pDrawable);	   \
-    XGL_PICTURE_SCREEN_UNWRAP (func)
-
-#define XGL_TRAP_FALLBACK_EPILOGUE(pPicture, func, xglfunc) \
-    XGL_PICTURE_SCREEN_WRAP (func, xglfunc);		    \
-    xglAddCurrentSurfaceDamage (pPicture->pDrawable)
-
-/* just a guess */
-#define SMOOTH_TRAPS_ESTIMATE_RECTS(nTrap) (30 * nTrap)
-
-#define LINE_FIXED_X(l, _y, v)			 \
-    dx = (l)->p2.x - (l)->p1.x;			 \
-    ex = (xFixed_32_32) ((_y) - (l)->p1.y) * dx; \
-    dy = (l)->p2.y - (l)->p1.y;			 \
-    (v) = (l)->p1.x + (xFixed) (ex / dy)
-
-#define LINE_FIXED_X_CEIL(l, _y, v)		      \
-    dx = (l)->p2.x - (l)->p1.x;			      \
-    ex = (xFixed_32_32) ((_y) - (l)->p1.y) * dx;      \
-    dy = (l)->p2.y - (l)->p1.y;			      \
-    (v) = (l)->p1.x + (xFixed) ((ex + (dy - 1)) / dy)
-
-static Bool
-xglTrapezoidExtents (PicturePtr pDst,
-		     int        ntrap,
-		     xTrapezoid *traps,
-		     BoxPtr     extents)
-{
-    Bool	 x_overlap, overlap = FALSE;
-    xFixed	 dx, dy, top, bottom;
-    xFixed_32_32 ex;
-
-    if (!ntrap)
-    {
-	extents->x1 = MAXSHORT;
-	extents->x2 = MINSHORT;
-	extents->y1 = MAXSHORT;
-	extents->y2 = MINSHORT;
-
-	return FALSE;
-    }
-
-    extents->y1 = xFixedToInt (traps->top);
-    extents->y2 = xFixedToInt (xFixedCeil (traps->bottom));
-
-    LINE_FIXED_X (&traps->left, traps->top, top);
-    LINE_FIXED_X (&traps->left, traps->bottom, bottom);
-    extents->x1 = xFixedToInt (MIN (top, bottom));
-
-    LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
-    LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
-    extents->x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
-
-    ntrap--;
-    traps++;
-
-    for (; ntrap; ntrap--, traps++)
-    {
-	INT16 x1, y1, x2, y2;
-
-	if (!xTrapezoidValid (traps))
-	    continue;
-
-	y1 = xFixedToInt (traps->top);
-	y2 = xFixedToInt (xFixedCeil (traps->bottom));
-
-	LINE_FIXED_X (&traps->left, traps->top, top);
-	LINE_FIXED_X (&traps->left, traps->bottom, bottom);
-	x1 = xFixedToInt (MIN (top, bottom));
-
-	LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
-	LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
-	x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
-
-	x_overlap = FALSE;
-	if (x1 >= extents->x2)
-	    extents->x2 = x2;
-	else if (x2 <= extents->x1)
-	    extents->x1 = x1;
-	else
-	{
-	    x_overlap = TRUE;
-	    if (x1 < extents->x1)
-		extents->x1 = x1;
-	    if (x2 > extents->x2)
-		extents->x2 = x2;
-	}
-
-	if (y1 >= extents->y2)
-	    extents->y2 = y2;
-	else if (y2 <= extents->y1)
-	    extents->y1 = y1;
-	else
-	{
-	    if (y1 < extents->y1)
-		extents->y1 = y1;
-	    if (y2 > extents->y2)
-		extents->y2 = y2;
-
-	    if (x_overlap)
-		overlap = TRUE;
-	}
-    }
-
-    xglPictureClipExtents (pDst, extents);
-
-    return overlap;
-}
-
-void
-xglTrapezoids (CARD8	     op,
-	       PicturePtr    pSrc,
-	       PicturePtr    pDst,
-	       PictFormatPtr maskFormat,
-	       INT16	     xSrc,
-	       INT16	     ySrc,
-	       int	     nTrap,
-	       xTrapezoid    *traps)
-{
-    ScreenPtr	    pScreen = pDst->pDrawable->pScreen;
-    PicturePtr	    pMask = NULL, pSrcPicture, pDstPicture;
-    PicturePtr	    pMaskPicture = NULL;
-    xglGeometryPtr  pGeometry = NULL;
-    unsigned int    polyEdge = pDst->polyEdge;
-    INT16	    xDst, yDst;
-    INT16	    xOff, yOff;
-    BoxRec	    extents;
-    Bool	    overlap;
-    Bool	    target;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    xDst = traps[0].left.p1.x >> 16;
-    yDst = traps[0].left.p1.y >> 16;
-
-    overlap = xglTrapezoidExtents (pDst, nTrap, traps, &extents);
-    if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
-	return;
-
-    target = xglPrepareTarget (pDst->pDrawable);
-
-    if (nTrap > 1 && op != PictOpAdd && maskFormat &&
-	(!target || overlap || op != PictOpOver))
-    {
-	PixmapPtr  pPixmap;
-	GCPtr	   pGC;
-	xRectangle rect;
-	int	   error;
-	int	   area;
-
-	if (!pScreenPriv->pSolidAlpha)
-	{
-	    xglCreateSolidAlphaPicture (pScreen);
-	    if (!pScreenPriv->pSolidAlpha)
-		return;
-	}
-
-	rect.x = 0;
-	rect.y = 0;
-	rect.width = extents.x2 - extents.x1;
-	rect.height = extents.y2 - extents.y1;
-
-	pPixmap = (*pScreen->CreatePixmap) (pScreen,
-					    rect.width, rect.height,
-					    maskFormat->depth);
-	if (!pPixmap)
-	    return;
-
-	pMask = CreatePicture (0, &pPixmap->drawable, maskFormat,
-			       0, 0, serverClient, &error);
-	if (!pMask)
-	{
-	    (*pScreen->DestroyPixmap) (pPixmap);
-	    return;
-	}
-
-	if (!target)
-	{
-	    /* make sure we don't do accelerated drawing to mask */
-	    xglSetPixmapVisual (pPixmap, NULL);
-	}
-
-	area = rect.width * rect.height;
-	if ((SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > area)
-	    XGL_GET_PIXMAP_PRIV (pPixmap)->target = xglPixmapTargetNo;
-
-	ValidatePicture (pMask);
-	pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
-	ValidateGC (&pPixmap->drawable, pGC);
-	(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &rect);
-	FreeScratchGC (pGC);
-
-	(*pScreen->DestroyPixmap) (pPixmap);
-
-	target = xglPrepareTarget (pMask->pDrawable);
-
-	xOff = -extents.x1;
-	yOff = -extents.y1;
-	pSrcPicture = pScreenPriv->pSolidAlpha;
-	pDstPicture = pMask;
-    }
-    else
-    {
-	if (maskFormat)
-	{
-	    if (maskFormat->depth == 1)
-		polyEdge = PolyEdgeSharp;
-	    else
-		polyEdge = PolyEdgeSmooth;
-	}
-
-	xOff = 0;
-	yOff = 0;
-	pSrcPicture = pSrc;
-	pDstPicture = pDst;
-    }
-
-    if (target)
-    {
-	if (maskFormat || polyEdge == PolyEdgeSmooth)
-	{
-	    glitz_vertex_format_t *format;
-	    glitz_surface_t	  *mask;
-	    xTrapezoid		  *pTrap = traps;
-	    int			  nAddedTrap, n = nTrap;
-	    int			  offset = 0;
-	    int			  size = SMOOTH_TRAPS_ESTIMATE_RECTS (n);
-
-	    pMaskPicture = pScreenPriv->trapInfo.pMask;
-	    format = &pScreenPriv->trapInfo.format.vertex;
-	    mask = pMaskPicture->pSourcePict->source.devPrivate.ptr;
-
-	    size *= format->bytes_per_vertex;
-	    pGeometry = xglGetScratchGeometryWithSize (pScreen, size);
-
-	    while (n)
-	    {
-		if (pGeometry->size < size)
-		    GEOMETRY_RESIZE (pScreen, pGeometry, size);
-
-		if (!pGeometry->buffer)
-		{
-		    if (pMask)
-			FreePicture (pMask, 0);
-
-		    return;
-		}
-
-		offset +=
-		    glitz_add_trapezoids (pGeometry->buffer,
-					  offset, size - offset, format->type,
-					  mask, (glitz_trapezoid_t *) pTrap, n,
-					  &nAddedTrap);
-
-		n     -= nAddedTrap;
-		pTrap += nAddedTrap;
-		size  *= 2;
-	    }
-
-	    pGeometry->f     = pScreenPriv->trapInfo.format;
-	    pGeometry->count = offset / format->bytes_per_vertex;
-	}
-	else
-	{
-	    pGeometry =
-		xglGetScratchVertexGeometryWithType (pScreen,
-						     GEOMETRY_DATA_TYPE_FLOAT,
-						     4 * nTrap);
-	    if (!pGeometry->buffer)
-	    {
-		if (pMask)
-		    FreePicture (pMask, 0);
-
-		return;
-	    }
-
-	    GEOMETRY_ADD_TRAPEZOID (pScreen, pGeometry, traps, nTrap);
-	}
-
-	GEOMETRY_TRANSLATE (pGeometry,
-			    pDstPicture->pDrawable->x + xOff,
-			    pDstPicture->pDrawable->y + yOff);
-    }
-
-    if (pGeometry &&
-	xglCompositeGeneral (pMask ? PictOpAdd : op,
-			     pSrcPicture,
-			     pMaskPicture,
-			     pDstPicture,
-			     pGeometry,
-			     extents.x1 + xOff + xSrc - xDst,
-			     extents.y1 + yOff + ySrc - yDst,
-			     0, 0,
-			     pDstPicture->pDrawable->x + extents.x1 + xOff,
-			     pDstPicture->pDrawable->y + extents.y1 + yOff,
-			     extents.x2 - extents.x1,
-			     extents.y2 - extents.y1))
-    {
-	/* no intermediate mask? we need to register damage from here as
-	   CompositePicture will never be called. */
-	if (!pMask)
-	{
-	    RegionRec region;
-
-	    REGION_INIT (pScreen, &region, &extents, 1);
-	    REGION_TRANSLATE (pScreen, &region,
-			      pDst->pDrawable->x, pDst->pDrawable->y);
-
-	    DamageDamageRegion (pDst->pDrawable, &region);
-
-	    REGION_UNINIT (pScreen, &region);
-	}
-
-	xglAddCurrentBitDamage (pDstPicture->pDrawable);
-    }
-    else
-    {
-	XGL_DRAWABLE_PIXMAP_PRIV (pDstPicture->pDrawable);
-
-	pPixmapPriv->damageBox.x1 = extents.x1 + xOff;
-	pPixmapPriv->damageBox.y1 = extents.y1 + yOff;
-	pPixmapPriv->damageBox.x2 = extents.x2 + xOff;
-	pPixmapPriv->damageBox.y2 = extents.y2 + yOff;
-
-	xglSyncDamageBoxBits (pDstPicture->pDrawable);
-
-	if (pMask || (polyEdge == PolyEdgeSmooth &&
-		      op == PictOpAdd && miIsSolidAlpha (pSrc)))
-	{
-	    PictureScreenPtr ps = GetPictureScreen (pScreen);
-
-	    for (; nTrap; nTrap--, traps++)
-		(*ps->RasterizeTrapezoid) (pDstPicture, traps, xOff, yOff);
-
-	    xglAddCurrentSurfaceDamage (pDstPicture->pDrawable);
-	}
-	else
-	    miTrapezoids (op, pSrc, pDstPicture, maskFormat,
-			  xSrc, ySrc, nTrap, traps);
-    }
-
-    if (pMask)
-    {
-	CompositePicture (op, pSrc, pMask, pDst,
-			  extents.x1 + xSrc - xDst,
-			  extents.y1 + ySrc - yDst,
-			  0, 0,
-			  extents.x1, extents.y1,
-			  extents.x2 - extents.x1,
-			  extents.y2 - extents.y1);
-
-	FreePicture (pMask, 0);
-    }
-}
-
-void
-xglAddTraps (PicturePtr pDst,
-	     INT16	xOff,
-	     INT16	yOff,
-	     int	nTrap,
-	     xTrap	*traps)
-{
-    PictureScreenPtr pPictureScreen;
-    ScreenPtr	     pScreen = pDst->pDrawable->pScreen;
-
-    XGL_SCREEN_PRIV (pScreen);
-    XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
-
-    if (!pScreenPriv->pSolidAlpha)
-    {
-	xglCreateSolidAlphaPicture (pScreen);
-	if (!pScreenPriv->pSolidAlpha)
-	    return;
-    }
-
-    pPixmapPriv->damageBox.x1 = 0;
-    pPixmapPriv->damageBox.y1 = 0;
-    pPixmapPriv->damageBox.x2 = pDst->pDrawable->width;
-    pPixmapPriv->damageBox.y2 = pDst->pDrawable->height;
-
-    if (xglPrepareTarget (pDst->pDrawable))
-    {
-	PicturePtr	      pMask;
-	glitz_vertex_format_t *format;
-	glitz_surface_t	      *mask;
-	xglGeometryPtr	      pGeometry;
-	xTrap		      *pTrap = traps;
-	int		      nAddedTrap, n = nTrap;
-	int		      offset = 0;
-	int		      size = SMOOTH_TRAPS_ESTIMATE_RECTS (n);
-
-	pMask = pScreenPriv->trapInfo.pMask;
-	format = &pScreenPriv->trapInfo.format.vertex;
-	mask = pMask->pSourcePict->source.devPrivate.ptr;
-
-	size *= format->bytes_per_vertex;
-	pGeometry = xglGetScratchGeometryWithSize (pScreen, size);
-
-	while (n)
-	{
-	    if (pGeometry->size < size)
-		GEOMETRY_RESIZE (pScreen, pGeometry, size);
-
-	    if (!pGeometry->buffer)
-		return;
-
-	    offset +=
-		glitz_add_traps (pGeometry->buffer,
-				 offset, size - offset, format->type, mask,
-				 (glitz_trap_t *) pTrap, n,
-				 &nAddedTrap);
-
-	    n     -= nAddedTrap;
-	    pTrap += nAddedTrap;
-	    size  *= 2;
-	}
-
-	pGeometry->f     = pScreenPriv->trapInfo.format;
-	pGeometry->count = offset / format->bytes_per_vertex;
-
-	GEOMETRY_TRANSLATE (pGeometry,
-			    pDst->pDrawable->x + xOff,
-			    pDst->pDrawable->y + yOff);
-
-	if (xglCompositeGeneral (PictOpAdd,
-				 pScreenPriv->pSolidAlpha,
-				 pMask,
-				 pDst,
-				 pGeometry,
-				 0, 0,
-				 0, 0,
-				 pDst->pDrawable->x, pDst->pDrawable->y,
-				 pDst->pDrawable->width,
-				 pDst->pDrawable->height))
-	{
-	    xglAddCurrentBitDamage (pDst->pDrawable);
-	    return;
-	}
-    }
-
-    pPictureScreen = GetPictureScreen (pScreen);
-
-    XGL_TRAP_FALLBACK_PROLOGUE (pDst, AddTraps);
-    (*pPictureScreen->AddTraps) (pDst, xOff, yOff, nTrap, traps);
-    XGL_TRAP_FALLBACK_EPILOGUE (pDst, AddTraps, xglAddTraps);
-}
-
-#endif
diff --git a/hw/xgl/xglwindow.c b/hw/xgl/xglwindow.c
deleted file mode 100644
index 393f01d..0000000
--- a/hw/xgl/xglwindow.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-#include "fb.h"
-
-#define XGL_WINDOW_FALLBACK_PROLOGUE(pWin, func)		       \
-    if (!xglMapPixmapBits (XGL_GET_DRAWABLE_PIXMAP (&pWin->drawable))) \
-	FatalError (XGL_SW_FAILURE_STRING);			       \
-    XGL_SCREEN_UNWRAP (func)
-
-#define XGL_WINDOW_FALLBACK_EPILOGUE(pWin, pRegion, func, xglfunc) \
-    XGL_SCREEN_WRAP (func, xglfunc);				   \
-    xglAddSurfaceDamage (&pWin->drawable, pRegion)
-
-Bool
-xglCreateWindow (WindowPtr pWin)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    Bool      ret;
-
-    XGL_SCREEN_PRIV (pScreen);
-    XGL_WINDOW_PRIV (pWin);
-
-    XGL_SCREEN_UNWRAP (CreateWindow);
-    ret = (*pScreen->CreateWindow) (pWin);
-    XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
-
-    pWinPriv->pPixmap = pWin->drawable.pScreen->devPrivate;
-
-    return ret;
-}
-
-Bool
-xglDestroyWindow (WindowPtr pWin)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    Bool      ret;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    XGL_SCREEN_UNWRAP (DestroyWindow);
-    ret = (*pScreen->DestroyWindow) (pWin);
-    XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
-
-    return ret;
-}
-
-Bool
-xglChangeWindowAttributes (WindowPtr	 pWin,
-			   unsigned long mask)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    PixmapPtr pPixmap;
-    Bool      ret;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    if (mask & CWBackPixmap)
-    {
-	if (pWin->backgroundState == BackgroundPixmap)
-	{
-	    pPixmap = pWin->background.pixmap;
-
-	    if (FbEvenTile (pPixmap->drawable.width *
-			    pPixmap->drawable.bitsPerPixel))
-		xglSyncBits (&pPixmap->drawable, NULL);
-	}
-    }
-
-    if (mask & CWBorderPixmap)
-    {
-	if (pWin->borderIsPixel == FALSE)
-	{
-	    pPixmap = pWin->border.pixmap;
-
-	    if (FbEvenTile (pPixmap->drawable.width *
-			    pPixmap->drawable.bitsPerPixel))
-		xglSyncBits (&pPixmap->drawable, NULL);
-	}
-    }
-
-    XGL_SCREEN_UNWRAP (ChangeWindowAttributes);
-    ret = (*pScreen->ChangeWindowAttributes) (pWin, mask);
-    XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
-
-    return ret;
-}
-
-void
-xglCopyWindow (WindowPtr   pWin,
-	       DDXPointRec ptOldOrg,
-	       RegionPtr   prgnSrc)
-{
-    PixmapPtr pPixmap;
-    RegionRec rgnDst;
-    int	      dx, dy;
-    BoxPtr    pExtent = REGION_EXTENTS (pWin->drawable.pScreen, prgnSrc);
-    BoxRec    box;
-
-    pPixmap = XGL_GET_WINDOW_PIXMAP (pWin);
-
-    box.x1 = pExtent->x1;
-    box.y1 = pExtent->y1;
-    box.x2 = pExtent->x2;
-    box.y2 = pExtent->y2;
-
-    dx = ptOldOrg.x - pWin->drawable.x;
-    dy = ptOldOrg.y - pWin->drawable.y;
-
-    REGION_TRANSLATE (pWin->drawable.pScreen, prgnSrc, -dx, -dy);
-    REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
-    REGION_INTERSECT (pWin->drawable.pScreen,
-		      &rgnDst, &pWin->borderClip, prgnSrc);
-
-    fbCopyRegion (&pWin->drawable, &pWin->drawable,
-		  0, &rgnDst, dx, dy, xglCopyProc, 0, (void *) &box);
-
-    REGION_UNINIT (pWin->drawable.pScreen, &rgnDst);
-}
-
-PixmapPtr
-xglGetWindowPixmap (WindowPtr pWin)
-{
-    return XGL_GET_WINDOW_PIXMAP (pWin);
-}
-
-void
-xglSetWindowPixmap (WindowPtr pWin,
-		    PixmapPtr pPixmap)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    XGL_SCREEN_UNWRAP (SetWindowPixmap);
-    (*pScreen->SetWindowPixmap) (pWin, pPixmap);
-    XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap);
-
-    XGL_GET_WINDOW_PRIV (pWin)->pPixmap = pPixmap;
-
-    if (pPixmap != pScreenPriv->pScreenPixmap)
-	xglEnablePixmapAccel (pPixmap, &pScreenPriv->accel.window);
-}
diff --git a/hw/xgl/xglxv.c b/hw/xgl/xglxv.c
deleted file mode 100644
index b9f96f3..0000000
--- a/hw/xgl/xglxv.c
+++ /dev/null
@@ -1,722 +0,0 @@
-/*
- * Copyright © 2005 Novell, Inc.
- *
- * 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
- * Novell, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * Novell, Inc. makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL NOVELL, INC. 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.
- *
- * Authors: David Reveman <davidr at novell.com>
- *          Matthias Hopf <mhopf at suse.de>
- */
-
-#include "xgl.h"
-
-#ifdef XV
-
-#include "xvdix.h"
-#include "gcstruct.h"
-#include "dixstruct.h"
-
-#include <X11/extensions/Xv.h>
-#include <X11/extensions/Xvproto.h>
-
-static unsigned int  xglXvScreenIndex = 0;
-static unsigned long portResource = 0;
-
-#define XGL_GET_XV_SCREEN(pScreen)				   \
-    ((XvScreenPtr) ((pScreen)->devPrivates[xglXvScreenIndex].ptr))
-
-#define XGL_XV_SCREEN(pScreen)				\
-    XvScreenPtr pXvScreen = XGL_GET_XV_SCREEN (pScreen)
-
-#define XGL_GET_XV_SCREEN_PRIV(pScreen)			      \
-    ((xglXvScreenPtr) (GET_XV_SCREEN (pScreen)->devPriv.ptr))
-
-#define XGL_XV_SCREEN_PRIV(pScreen)				    \
-    xglXvScreenPtr pXvScreenPriv = XGL_GET_XV_SCREEN_PRIV (pScreen)
-
-#define XGL_GET_XV_PORT_PRIV(pPort)	    \
-    ((xglXvPortPtr) ((pPort)->devPriv.ptr))
-
-#define XGL_XV_PORT_PRIV(pPort)				  \
-    xglXvPortPtr pPortPriv = XGL_GET_XV_PORT_PRIV (pPort)
-
-#define XGL_XV_NUM_PORTS 32
-
-#define XGL_XV_IMAGE_MAX_WIDTH  2048
-#define XGL_XV_IMAGE_MAX_HEIGHT 2048
-
-static XvImageRec xvImages[] = {
-    {
-	GLITZ_FOURCC_YUY2, XvYUV, BITMAP_BIT_ORDER,
-	{
-	    'Y','U','Y','2',
-	    0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
-	    0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
-	},
-	16, XvPacked, 1,
-	0, 0, 0, 0,
-	8, 8, 8,  1, 2, 2,  1, 1, 1,
-	{
-	    'Y', 'U', 'Y', 'V',
-	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-	},
-	XvTopToBottom
-    }, {
-	GLITZ_FOURCC_YV12, XvYUV, BITMAP_BIT_ORDER,
-	{
-	    'Y', 'V', '1', '2',
-	    0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
-	    0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
-	},
-	12, XvPlanar, 3,
-	0, 0, 0, 0,
-	8, 8, 8,  1, 2, 2,  1, 2, 2,
-	{
-	    'Y', 'V', 'U', 0,
-	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-	},
-	XvTopToBottom
-    }, {
-	GLITZ_FOURCC_RGB, XvRGB, BITMAP_BIT_ORDER,
-	{
-	    0x03, 0x00, 0x00, 0x00,
-	    0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
-	    0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
-	},
-	32, XvPacked, 1,
-	24, 0xff0000, 0xff00, 0xff,
-	0, 0, 0,  0, 0, 0,  0, 0, 0,
-	{
-	    0, 0, 0, 0,
-	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-	},
-	XvTopToBottom
-    }
-};
-
-static struct _xglXvFormat {
-    CARD32	      format;
-    glitz_fourcc_t    fourcc;
-    xglPixelFormatRec pixel;
-} xglXvFormat[XGL_XV_FORMAT_NUM] = {
-    {
-	PICT_yuy2,
-	GLITZ_FOURCC_YUY2,
-	{
-	    16, 6,
-	    {
-		16,
-		0x00000000,
-		0x00000000,
-		0x00000000,
-		0x00000000,
-	    }
-	}
-    }, {
-	PICT_yv12,
-	GLITZ_FOURCC_YV12,
-	{
-	    12, 4,
-	    {
-		12,
-		0x00000000,
-		0x00000000,
-		0x00000000,
-		0x00000000,
-	    }
-	}
-    }, {
-	PICT_x8r8g8b8,
-	GLITZ_FOURCC_RGB,
-	{
-	    24, 8,
-	    {
-		32,
-		0x00000000,
-		0x00ff0000,
-		0x0000ff00,
-		0x000000ff,
-	    }
-	}
-    }
-};
-
-static int
-xglXvQueryAdaptors (ScreenPtr	 pScreen,
-		    XvAdaptorPtr *pAdaptors,
-		    int		 *nAdaptors)
-{
-    XGL_XV_SCREEN (pScreen);
-
-    *nAdaptors = pXvScreen->nAdaptors;
-    *pAdaptors = pXvScreen->pAdaptors;
-
-    return Success;
-}
-
-static int
-xglXvAllocatePort (unsigned long port,
-		   XvPortPtr	 pPort,
-		   XvPortPtr	 *ppPort)
-{
-    *ppPort = pPort;
-
-    return Success;
-}
-
-static int
-xglXvFreePort (XvPortPtr pPort)
-{
-    XGL_XV_PORT_PRIV (pPort);
-
-    if (pPortPriv->pDst)
-    {
-	FreePicture ((pointer) pPortPriv->pDst, 0);
-	pPortPriv->pDst = (PicturePtr) 0;
-    }
-
-    if (pPortPriv->pSrc)
-    {
-	FreePicture ((pointer) pPortPriv->pSrc, 0);
-	pPortPriv->pSrc = (PicturePtr) 0;
-    }
-
-    if (pPortPriv->pTmp)
-    {
-	FreePicture ((pointer) pPortPriv->pTmp, 0);
-	pPortPriv->pTmp = (PicturePtr) 0;
-    }
-
-    if (pPortPriv->pPixmap)
-    {
-	ScreenPtr pScreen;
-
-	pScreen = pPortPriv->pPixmap->drawable.pScreen;
-	(*pScreen->DestroyPixmap) (pPortPriv->pPixmap);
-	pPortPriv->pPixmap = (PixmapPtr) 0;
-    }
-
-    return Success;
-}
-
-static int
-xglXvQueryBestSize (ClientPtr	 client,
-		    XvPortPtr	 pPort,
-		    CARD8	 motion,
-		    CARD16	 srcWidth,
-		    CARD16	 srcHeight,
-		    CARD16	 dstWidth,
-		    CARD16	 dstHeight,
-		    unsigned int *pWidth,
-		    unsigned int *pHeight)
-{
-    *pWidth  = dstWidth;
-    *pHeight = dstHeight;
-
-    return Success;
-}
-
-static int
-xglXvStopVideo (ClientPtr   client,
-		XvPortPtr   pPort,
-		DrawablePtr pDrawable)
-{
-    xglXvFreePort (pPort);
-
-    return Success;
-}
-
-static PicturePtr
-xglXvCreateDstPict (DrawablePtr pDrawable,
-		    Mask	vmask,
-		    XID		*vlist,
-		    int		*error)
-{
-    ScreenPtr     pScreen = pDrawable->pScreen;
-    PictFormatPtr pFormat = 0;
-    int		  i;
-
-    for (i = 0; i < pScreen->numVisuals; i++)
-    {
-	if (pScreen->visuals[i].nplanes == pDrawable->depth)
-	{
-	    pFormat = PictureMatchVisual (pScreen, pDrawable->depth,
-					  &pScreen->visuals[i]);
-	    break;
-	}
-    }
-
-    if (!pFormat)
-    {
-	*error = BadImplementation;
-	return (PicturePtr) 0;
-    }
-
-    return CreatePicture (0, pDrawable,
-			  pFormat, vmask, vlist, serverClient,
-			  error);
-}
-
-static int
-xglXvPutImage (ClientPtr     client,
-	       DrawablePtr   pDrawable,
-	       XvPortPtr     pPort,
-	       GCPtr	     pGC,
-	       INT16	     srcX,
-	       INT16	     srcY,
-	       CARD16	     srcWidth,
-	       CARD16	     srcHeight,
-	       INT16	     dstX,
-	       INT16	     dstY,
-	       CARD16	     dstWidth,
-	       CARD16	     dstHeight,
-	       XvImagePtr    pImage,
-	       unsigned char *data,
-	       Bool	     sync,
-	       CARD16	     width,
-	       CARD16	     height)
-{
-    ScreenPtr	  pScreen = pDrawable->pScreen;
-    PicturePtr	  pSrc;
-    PictTransform transform;
-    int		  depth, bpp, stride, noVisual = FALSE;
-    CARD32	  format;
-
-    XGL_SCREEN_PRIV (pScreen);
-    XGL_XV_PORT_PRIV (pPort);
-    XGL_DRAWABLE_PIXMAP (pDrawable);
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    stride = ((width + 7) & ~7);
-
-    switch (pImage->id) {
-    case GLITZ_FOURCC_YUY2:
-	bpp = depth = 16;
-	format = PICT_yuy2;
-	noVisual = !pScreenPriv->pXvVisual[XGL_XV_FORMAT_YUY2].format.surface;
-	stride *= 2;
-	break;
-    case GLITZ_FOURCC_YV12:
-	depth = bpp = 12;
-	format = PICT_yv12;
-	noVisual = !pScreenPriv->pXvVisual[XGL_XV_FORMAT_YV12].format.surface;
-	break;
-    case GLITZ_FOURCC_RGB:
-	depth = 24;
-	bpp = 32;
-	format = PICT_x8r8g8b8;
-	stride *= 4;
-	break;
-    default:
-	return BadImplementation;
-    }
-
-    pPort->pDraw = pDrawable;
-
-    if (!pPortPriv->pPixmap)
-    {
-	pPortPriv->pPixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth);
-	if (!pPortPriv->pPixmap)
-	    return BadAlloc;
-    }
-
-    (*pScreen->ModifyPixmapHeader) (pPortPriv->pPixmap,
-				    srcWidth, srcHeight,
-				    depth, bpp, -1, (pointer) data);
-
-    XGL_GET_PIXMAP_PRIV (pPortPriv->pPixmap)->stride = -stride;
-
-    pPortPriv->pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-
-    if (!pPortPriv->pSrc || pPortPriv->pSrc->format != format)
-    {
-	PictFormatPtr pFormat;
-	int	      error;
-	static XID    value = RepeatPad;
-
-	pFormat = PictureMatchFormat (pScreen, depth, format);
-	if (!pFormat)
-	    return BadImplementation;
-
-	if (pPortPriv->pSrc)
-	    FreePicture ((pointer) pPortPriv->pSrc, 0);
-
-	pPortPriv->pSrc = CreatePicture (0, &pPortPriv->pPixmap->drawable,
-					 pFormat, CPRepeat, &value,
-					 serverClient, &error);
-	if (!pPortPriv->pSrc)
-	{
-	    xglXvFreePort (pPort);
-	    return error;
-	}
-
-	SetPictureFilter (pPortPriv->pSrc,
-			  pScreenPriv->xvFilter,
-			  strlen (pScreenPriv->xvFilter),
-			  0, 0);
-    }
-
-    pSrc = pPortPriv->pSrc;
-
-    if (!pPortPriv->pDst || pPortPriv->pDst->pDrawable != pDrawable)
-    {
-	int error;
-
-	if (pPortPriv->pDst)
-	    FreePicture ((pointer) pPortPriv->pDst, 0);
-
-	pPortPriv->pDst = xglXvCreateDstPict (pDrawable, 0, NULL, &error);
-	if (!pPortPriv->pDst)
-	{
-	    xglXvFreePort (pPort);
-	    return error;
-	}
-    }
-
-    if (pPixmap != pScreenPriv->pScreenPixmap && !pPixmapPriv->target)
-	xglEnablePixmapAccel (pPixmap, &pScreenPriv->accel.xv);
-
-    /* software color-space conversion */
-    if (pPixmapPriv->target && (noVisual || pScreenPriv->noYuv))
-    {
-	if (!pPortPriv->pTmp				   ||
-	    srcWidth  != pPortPriv->pTmp->pDrawable->width ||
-	    srcHeight != pPortPriv->pTmp->pDrawable->height)
-	{
-	    static XID value = RepeatPad;
-	    int	       error;
-
-	    if (pPortPriv->pTmp)
-		FreePicture ((pointer) pPortPriv->pTmp, 0);
-
-	    pPixmap = (*pScreen->CreatePixmap) (pScreen,
-						srcWidth, srcHeight,
-						pDrawable->depth);
-	    if (!pPixmap)
-	    {
-		xglXvFreePort (pPort);
-		return BadAlloc;
-	    }
-
-	    pPortPriv->pTmp = xglXvCreateDstPict (&pPixmap->drawable,
-						  CPRepeat, &value,
-						  &error);
-	    if (!pPortPriv->pTmp)
-	    {
-		(*pScreen->DestroyPixmap) (pPixmap);
-		xglXvFreePort (pPort);
-		return error;
-	    }
-
-	    /* no accelerated drawing */
-	    XGL_GET_PIXMAP_PRIV (pPixmap)->target = xglPixmapTargetNo;
-
-	    (*pScreen->DestroyPixmap) (pPixmap);
-
-	    SetPictureFilter (pPortPriv->pTmp,
-			      pScreenPriv->xvFilter,
-			      strlen (pScreenPriv->xvFilter),
-			      0, 0);
-	}
-
-	SetPictureTransform (pSrc, 0);
-
-	CompositePicture (PictOpSrc,
-			  pSrc,
-			  (PicturePtr) 0,
-			  pPortPriv->pTmp,
-			  0, 0,
-			  0, 0,
-			  0, 0,
-			  srcWidth, srcHeight);
-
-	pSrc = pPortPriv->pTmp;
-    }
-
-    transform.matrix[0][0] = ((srcWidth << 16) + (dstWidth >> 1))
-			     / dstWidth;
-    transform.matrix[0][1] = 0;
-    transform.matrix[0][2] = 0;
-
-    /* flip Y */
-    transform.matrix[1][0] = 0;
-    transform.matrix[1][1] = -((srcHeight << 16) + (dstHeight >> 1))
-			     / dstHeight;
-    transform.matrix[1][2] = (srcHeight << 16);
-
-    transform.matrix[2][0] = 0;
-    transform.matrix[2][1] = 0;
-    transform.matrix[2][2] = 1 << 16;
-
-    SetPictureTransform (pSrc, &transform);
-
-    CompositePicture (PictOpSrc,
-		      pSrc,
-		      (PicturePtr) 0,
-		      pPortPriv->pDst,
-		      srcX, srcY,
-		      0, 0,
-		      dstX, dstY,
-		      dstWidth, dstHeight);
-
-    return Success;
-}
-
-static int
-xglXvQueryImageAttributes (ClientPtr  client,
-			   XvPortPtr  pPort,
-			   XvImagePtr pImage,
-			   CARD16     *width,
-			   CARD16     *height,
-			   int	      *pitches,
-			   int	      *offsets)
-{
-    if (*width > XGL_XV_IMAGE_MAX_WIDTH)
-	*width = XGL_XV_IMAGE_MAX_WIDTH;
-
-    if (*height > XGL_XV_IMAGE_MAX_HEIGHT)
-	*height = XGL_XV_IMAGE_MAX_HEIGHT;
-
-    *width = (*width + 7) & ~7;
-
-    switch (pImage->id) {
-    case GLITZ_FOURCC_YUY2:
-	if (offsets)
-	    offsets[0] = 0;
-
-	if (pitches)
-	    pitches[0] = *width * 2;
-
-	return *width * *height * 2;
-    case GLITZ_FOURCC_YV12:
-	*height = (*height + 1) & ~1;
-
-	if (offsets)
-	{
-	    offsets[0] = 0;
-	    offsets[1] = *width * *height;
-	    offsets[2] = *width * *height + (*width >> 1) * (*height >> 1);
-	}
-
-	if (pitches)
-	{
-	    pitches[0] = *width;
-	    pitches[1] = pitches[2] = *width >> 1;
-	}
-
-	return *width * *height + (*width >> 1) * *height;
-    case GLITZ_FOURCC_RGB:
-	if (offsets)
-	    offsets[0] = 0;
-
-	if (pitches)
-	    pitches[0] = *width * 4;
-
-	return *width * *height * 4;
-    default:
-	return 0;
-    }
-}
-
-static void
-xglXvFreeAdaptor (XvAdaptorPtr pAdaptor)
-{
-    xfree (pAdaptor->pEncodings);
-    xfree (pAdaptor->pFormats);
-
-    if (pAdaptor->pPorts)
-	xfree (pAdaptor->pPorts);
-}
-
-static Bool
-xglXvInitAdaptors (ScreenPtr pScreen)
-{
-    XvAdaptorPtr  pAdaptor;
-    xglXvPortPtr  pPortPriv;
-    XvPortPtr     pPort;
-    XvFormatPtr   pFormat;
-    XvEncodingPtr pEncoding;
-    int		  i;
-
-    XGL_XV_SCREEN (pScreen);
-
-    pXvScreen->nAdaptors = 0;
-    pXvScreen->pAdaptors = NULL;
-
-    pAdaptor = xcalloc (1, sizeof (XvAdaptorRec));
-    if (!pAdaptor)
-	return FALSE;
-
-    pAdaptor->type    = XvInputMask | XvImageMask;
-    pAdaptor->pScreen = pScreen;
-
-    pAdaptor->ddAllocatePort	     = xglXvAllocatePort;
-    pAdaptor->ddFreePort	     = xglXvFreePort;
-    pAdaptor->ddStopVideo	     = xglXvStopVideo;
-    pAdaptor->ddPutImage	     = xglXvPutImage;
-    pAdaptor->ddQueryBestSize	     = xglXvQueryBestSize;
-    pAdaptor->ddQueryImageAttributes = xglXvQueryImageAttributes;
-
-    pAdaptor->name = "Xgl Generic Texture Video";
-
-    pEncoding = xcalloc (1, sizeof (XvEncodingRec));
-    if (!pEncoding)
-	return FALSE;
-
-    pEncoding->id      = 0;
-    pEncoding->pScreen = pScreen;
-    pEncoding->name    = "XV_IMAGE";
-
-    pEncoding->width  = XGL_XV_IMAGE_MAX_WIDTH;
-    pEncoding->height = XGL_XV_IMAGE_MAX_HEIGHT;
-
-    pEncoding->rate.numerator	= 1;
-    pEncoding->rate.denominator = 1;
-
-    pAdaptor->nEncodings = 1;
-    pAdaptor->pEncodings = pEncoding;
-
-    pAdaptor->nImages = sizeof (xvImages) / sizeof (XvImageRec);
-    pAdaptor->pImages = xvImages;
-
-    /* TODO: Currently no attributes */
-    pAdaptor->nAttributes = 0;
-    pAdaptor->pAttributes = 0;
-
-    pFormat = xcalloc (pScreen->numVisuals, sizeof (XvFormatRec));
-    if (!pFormat)
-	return FALSE;
-
-    for (i = 0; i < pScreen->numVisuals; i++)
-    {
-	pFormat[i].depth  = pScreen->visuals[i].nplanes;
-	pFormat[i].visual = pScreen->visuals[i].vid;
-    }
-
-    /* All visuals allowed */
-    pAdaptor->nFormats = pScreen->numVisuals;
-    pAdaptor->pFormats = pFormat;
-
-    pPort = xcalloc (XGL_XV_NUM_PORTS,
-		     sizeof (XvPortRec) + sizeof (xglXvPortRec));
-    pPortPriv = (xglXvPortPtr) (pPort + XGL_XV_NUM_PORTS);
-    if (!pPort)
-	return FALSE;
-
-    for (i = 0; i < XGL_XV_NUM_PORTS; i++)
-    {
-	pPort[i].id = FakeClientID (0);
-	if (!pPort[i].id)
-	    return FALSE;
-
-	if (!AddResource (pPort[i].id, portResource, &pPort[i]))
-	    return FALSE;
-
-	pPort[i].pAdaptor    = pAdaptor;
-	pPort[i].pNotify     = (XvPortNotifyPtr) 0;
-	pPort[i].pDraw	     = (DrawablePtr) 0;
-	pPort[i].client      = (ClientPtr) 0;
-	pPort[i].grab.client = (ClientPtr) 0;
-	pPort[i].time	     = currentTime;
-	pPort[i].devPriv.ptr = pPortPriv + i;
-    }
-
-    pAdaptor->nPorts  = XGL_XV_NUM_PORTS;
-    pAdaptor->pPorts  = pPort;
-    pAdaptor->base_id = pPort->id;
-
-    pXvScreen->pAdaptors = pAdaptor;
-    pXvScreen->nAdaptors = 1;
-
-    return TRUE;
-}
-
-static Bool
-xglXvCloseScreen (int i, ScreenPtr pScreen)
-{
-    int	j;
-
-    XGL_XV_SCREEN (pScreen);
-
-    for (j = 0; j < pXvScreen->nAdaptors; j++)
-	xglXvFreeAdaptor (&pXvScreen->pAdaptors[j]);
-
-    if (pXvScreen->pAdaptors)
-	xfree (pXvScreen->pAdaptors);
-
-    return TRUE;
-}
-
-Bool
-xglXvScreenInit (ScreenPtr pScreen)
-{
-    XvScreenPtr  pXvScreen;
-    xglVisualPtr v;
-    int		 i, status, vid = 0;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    status = XvScreenInit (pScreen);
-    if (status != Success)
-	return FALSE;
-
-    xglXvScreenIndex = XvGetScreenIndex ();
-    portResource = XvGetRTPort ();
-
-    pXvScreen = XGL_GET_XV_SCREEN (pScreen);
-
-    /* Anyone initializing the Xv layer must provide these two.
-       The Xv di layer calls them without even checking if they exist! */
-    pXvScreen->ddCloseScreen   = xglXvCloseScreen;
-    pXvScreen->ddQueryAdaptors = xglXvQueryAdaptors;
-
-    pXvScreen->devPriv.ptr = (pointer) 0;
-
-    if (!xglXvInitAdaptors (pScreen))
-	return FALSE;
-
-    for (v = pScreenPriv->pVisual; v; v = v->next)
-    {
-	if (v->vid > vid)
-	    vid = v->vid;
-    }
-
-    memset (pScreenPriv->pXvVisual, 0, sizeof (pScreenPriv->pXvVisual));
-
-    for (i = 0; i < XGL_XV_FORMAT_NUM; i++)
-    {
-	glitz_format_t templ;
-
-	templ.color.fourcc = xglXvFormat[i].fourcc;
-
-	pScreenPriv->pXvVisual[i].vid = ++vid;
-	pScreenPriv->pXvVisual[i].pPixel = &xglXvFormat[i].pixel;
-	pScreenPriv->pXvVisual[i].format.surface =
-	    glitz_find_format (pScreenPriv->drawable,
-			       GLITZ_FORMAT_FOURCC_MASK,
-			       &templ, 0);
-    }
-
-    return TRUE;
-}
-
-#endif
diff --git a/xgl/Makefile.am b/xgl/Makefile.am
new file mode 100644
index 0000000..494a73b
--- /dev/null
+++ b/xgl/Makefile.am
@@ -0,0 +1,42 @@
+noinst_LTLIBRARIES = libxgl.la
+
+INCLUDES = -I at MESA_SOURCE@/include \
+           -I$(top_srcdir)/GL/mesa/glapi \
+           -I$(top_srcdir)/GL/glx \
+           -I$(top_srcdir)/GL/include \
+           -I$(top_srcdir)/hw/xfree86/os-support \
+           -I$(top_srcdir)/hw/xfree86/os-support/bus \
+           -I$(top_srcdir)/hw/xfree86/common
+
+# -DXFree86Server is required because the X11 driver in Mesa thinks that
+# symbol means "being built in the server"
+AM_CFLAGS = \
+	@DIX_CFLAGS@ \
+	@LIBDRM_CFLAGS@ \
+	@DRIPROTO_CFLAGS@ \
+	$(XGL_CFLAGS) \
+	@GLX_DEFINES@ \
+	-DXFree86Server
+
+libxgl_la_SOURCES = \
+	xgl.h \
+	xglarea.c \
+	xglcmap.c \
+	xglcompose.c \
+	xglcopy.c \
+	xglfill.c \
+	xglgc.c \
+	xglgeometry.c \
+	xglget.c \
+	xglglyph.c \
+	xglpict.c \
+	xglpixmap.c \
+	xglshm.c \
+	xglsolid.c \
+	xglsync.c \
+	xgltile.c \
+	xgltrap.c \
+	xglwindow.c \
+	xglxv.c
+
+libxgl_la_LIBADD = $(XGL_LIBS)
diff --git a/xgl/xgl.h b/xgl/xgl.h
new file mode 100644
index 0000000..62bbee0
--- /dev/null
+++ b/xgl/xgl.h
@@ -0,0 +1,1504 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+
+#ifndef _XGL_H_
+#define _XGL_H_
+
+#include <xgl-config.h>
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include <glitz.h>
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "mi.h"
+#include "dix.h"
+#include "damage.h"
+#include "gc.h"
+#include "micmap.h"
+/* I'd like gc.h to provide this */
+typedef struct _GCFuncs *GCFuncsPtr;
+
+#ifdef RENDER
+#include "mipict.h"
+#else
+#ifdef XV
+#undef XV /* Xv implementation require RENDER */
+#endif
+#endif
+
+#ifdef XV
+#define XGL_XV_FORMAT_YUY2 0
+#define XGL_XV_FORMAT_YV12 1
+#define XGL_XV_FORMAT_RGB  2
+#define XGL_XV_FORMAT_NUM  3
+#endif
+
+/* For the modules.  We should decide what the actual version numbering should
+ * be.
+ */
+#define VERSION "0.0.1"
+
+extern WindowPtr *WindowTable;
+
+#define XGL_DEFAULT_PBO_MASK 0
+
+typedef struct _xglSizeConstraint {
+    int minWidth;
+    int minHeight;
+    int aboveWidth;
+    int aboveHeight;
+} xglSizeConstraintRec, *xglSizeConstraintPtr;
+
+typedef struct _xglAccelInfo {
+    Bool		 enabled;
+    Bool		 pbuffer;
+    xglSizeConstraintRec size;
+} xglAccelInfoRec, *xglAccelInfoPtr;
+
+typedef struct _xglScreenAccelInfo {
+    xglAccelInfoRec pixmap;
+    xglAccelInfoRec window;
+    xglAccelInfoRec glx;
+    xglAccelInfoRec xv;
+} xglScreenAccelInfoRec, *xglScreenAccelInfoPtr;
+
+typedef struct _xglScreenInfo {
+    glitz_drawable_t	  *drawable;
+    unsigned int	  depth;
+    unsigned int	  width;
+    unsigned int	  height;
+    unsigned int	  widthMm;
+    unsigned int	  heightMm;
+    int			  geometryDataType;
+    int			  geometryUsage;
+    Bool		  yInverted;
+    int			  pboMask;
+    Bool		  lines;
+    Bool		  noYuv;
+    char		  *xvFilter;
+    xglScreenAccelInfoRec accel;
+} xglScreenInfoRec, *xglScreenInfoPtr;
+
+extern xglScreenInfoRec xglScreenInfo;
+
+typedef struct _xglPixelFormat {
+    CARD8		depth, bitsPerRGB;
+    glitz_pixel_masks_t masks;
+} xglPixelFormatRec, *xglPixelFormatPtr;
+
+typedef struct _xglVisual {
+    struct _xglVisual *next;
+    VisualID	      vid;
+    xglPixelFormatPtr pPixel;
+    Bool	      pbuffer;
+    struct {
+	glitz_drawable_format_t *drawable;
+	glitz_format_t	        *surface;
+    } format;
+} xglVisualRec, *xglVisualPtr;
+
+extern xglVisualPtr xglVisuals;
+extern xglPixelFormatRec xglPixelFormats[];
+
+#define xglAreaAvailable 0
+#define xglAreaDivided   1
+#define xglAreaOccupied  2
+
+typedef struct _xglRootArea *xglRootAreaPtr;
+
+typedef struct _xglArea {
+    int		    state;
+    int		    level;
+    int		    x, y;
+    int		    width, height;
+    struct _xglArea *pArea[4];
+    xglRootAreaPtr  pRoot;
+    pointer	    closure;
+    DevUnion	    devPrivate;
+} xglAreaRec, *xglAreaPtr;
+
+typedef struct _xglAreaFuncs {
+    Bool (*Create)	(xglAreaPtr pArea);
+
+    Bool (*MoveIn)      (xglAreaPtr pArea,
+			 pointer    closure);
+
+    void (*MoveOut)     (xglAreaPtr pArea,
+			 pointer    closure);
+
+    int (*CompareScore) (xglAreaPtr pArea,
+			 pointer    closure1,
+			 pointer    closure2);
+
+} xglAreaFuncsRec, *xglAreaFuncsPtr;
+
+typedef struct _xglRootArea {
+    int		    maxLevel;
+    int		    width, height;
+    xglAreaPtr	    pArea;
+    xglAreaFuncsPtr funcs;
+    int		    devPrivateSize;
+    pointer	    closure;
+} xglRootAreaRec;
+
+typedef struct xglGeometry {
+    glitz_buffer_t          *buffer;
+    pointer	            *data;
+    Bool		    broken;
+    glitz_fixed16_16_t	    xOff, yOff;
+    int			    dataType;
+    int			    usage;
+    int			    size, endOffset;
+    glitz_geometry_type_t   type;
+    glitz_geometry_format_t f;
+    int			    first, width, count;
+    glitz_multi_array_t     *array;
+} xglGeometryRec, *xglGeometryPtr;
+
+#ifdef RENDER
+typedef struct _xglFBox {
+    glitz_float_t x1, y1, x2, y2;
+} xglFBoxRec;
+
+typedef union _xglBox {
+    BoxRec     sBox;
+    xglFBoxRec fBox;
+} xglBoxRec, *xglBoxPtr;
+
+typedef struct _xglRange {
+    int		 first;
+    unsigned int count;
+} xglRangeRec, *xglRangePtr;
+
+typedef struct _xglGlyphTexture {
+    PicturePtr		    pMask;
+    glitz_pixel_format_t    pixel;
+    glitz_geometry_format_t format;
+    int			    geometryDataType;
+} xglGlyphTextureRec, *xglGlyphTexturePtr;
+
+typedef struct _xglGlyphArea {
+    unsigned long serial;
+    union {
+	xglBoxRec   box;
+	xglRangeRec range;
+    } u;
+} xglGlyphAreaRec, *xglGlyphAreaPtr;
+
+typedef struct _xglGlyphCache {
+    ScreenPtr		    pScreen;
+    int			    depth;
+    xglRootAreaRec	    rootArea;
+    union {
+	xglGlyphTextureRec texture;
+	xglGeometryRec	   geometry;
+    } u;
+} xglGlyphCacheRec, *xglGlyphCachePtr;
+
+typedef struct _xglGlyph {
+    xglAreaPtr pArea;
+} xglGlyphRec, *xglGlyphPtr;
+
+extern int xglGlyphPrivateIndex;
+
+#define XGL_GET_GLYPH_PRIV(pScreen, pGlyph) ((xglGlyphPtr)		     \
+    (GetGlyphPrivatesForScreen (pGlyph, pScreen))[xglGlyphPrivateIndex].ptr)
+
+#define XGL_GLYPH_PRIV(pScreen, pGlyph)				  \
+    xglGlyphPtr pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pGlyph)
+
+#endif
+
+typedef struct _xglScreen {
+    xglVisualPtr		  pVisual;
+
+#ifdef GLXEXT
+    xglVisualPtr		  pGlxVisual;
+#endif
+
+#ifdef XV
+    xglVisualRec		  pXvVisual[XGL_XV_FORMAT_NUM];
+#endif
+
+    xglVisualPtr		  rootVisual;
+    glitz_drawable_t		  *drawable;
+    glitz_surface_t		  *surface;
+    PixmapPtr			  pScreenPixmap;
+    unsigned long		  features;
+    int				  geometryUsage;
+    int				  geometryDataType;
+    Bool			  yInverted;
+    int				  pboMask;
+    Bool			  lines;
+    Bool			  noYuv;
+    char			  *xvFilter;
+    xglGeometryRec		  scratchGeometry;
+    xglScreenAccelInfoRec	  accel;
+
+#ifdef RENDER
+    xglGlyphCacheRec		  glyphCache[33];
+    PicturePtr			  pSolidAlpha;
+    struct _trapInfo {
+	PicturePtr		  pMask;
+	glitz_geometry_format_t	  format;
+    } trapInfo;
+#endif
+
+    GetImageProcPtr		  GetImage;
+    GetSpansProcPtr		  GetSpans;
+    CreateWindowProcPtr		  CreateWindow;
+    DestroyWindowProcPtr	  DestroyWindow;
+    ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+    CopyWindowProcPtr		  CopyWindow;
+    CreateGCProcPtr		  CreateGC;
+    CloseScreenProcPtr		  CloseScreen;
+    SetWindowPixmapProcPtr	  SetWindowPixmap;
+    BitmapToRegionProcPtr	  BitmapToRegion;
+
+#ifdef RENDER
+    CompositeProcPtr		  Composite;
+    GlyphsProcPtr		  Glyphs;
+    TrapezoidsProcPtr		  Trapezoids;
+    AddTrapsProcPtr		  AddTraps;
+    AddTrianglesProcPtr		  AddTriangles;
+    ChangePictureProcPtr	  ChangePicture;
+    ChangePictureTransformProcPtr ChangePictureTransform;
+    ChangePictureFilterProcPtr	  ChangePictureFilter;
+
+    RealizeGlyphProcPtr		  RealizeGlyph;
+    UnrealizeGlyphProcPtr	  UnrealizeGlyph;
+#endif
+} xglScreenRec, *xglScreenPtr;
+
+extern int xglScreenPrivateIndex;
+
+#define XGL_GET_SCREEN_PRIV(pScreen)				       \
+    ((xglScreenPtr) (pScreen)->devPrivates[xglScreenPrivateIndex].ptr)
+
+#define XGL_SET_SCREEN_PRIV(pScreen, v)				      \
+    ((pScreen)->devPrivates[xglScreenPrivateIndex].ptr = (pointer) v)
+
+#define XGL_SCREEN_PRIV(pScreen)			     \
+    xglScreenPtr pScreenPriv = XGL_GET_SCREEN_PRIV (pScreen)
+
+#define XGL_SCREEN_WRAP(field, wrapper)	 \
+    pScreenPriv->field = pScreen->field; \
+    pScreen->field     = wrapper
+
+#define XGL_SCREEN_UNWRAP(field)	\
+    pScreen->field = pScreenPriv->field
+
+#ifdef RENDER
+#define XGL_PICTURE_SCREEN_WRAP(field, wrapper)	   \
+    pScreenPriv->field    = pPictureScreen->field; \
+    pPictureScreen->field = wrapper
+
+#define XGL_PICTURE_SCREEN_UNWRAP(field)       \
+    pPictureScreen->field = pScreenPriv->field
+#endif
+
+#define xglGCSoftwareDrawableFlag (1L << 0)
+#define xglGCBadFunctionFlag	  (1L << 1)
+#define xglGCPlaneMaskFlag	  (1L << 2)
+
+typedef struct _xglGC {
+    glitz_surface_t   *fg;
+    glitz_surface_t   *bg;
+    glitz_format_id_t id;
+    glitz_operator_t  op;
+    unsigned long     flags;
+    GCFuncsPtr	      funcs;
+    GCOpsPtr	      ops;
+} xglGCRec, *xglGCPtr;
+
+extern int xglGCPrivateIndex;
+
+#define XGL_GET_GC_PRIV(pGC)				   \
+    ((xglGCPtr) (pGC)->devPrivates[xglGCPrivateIndex].ptr)
+
+#define XGL_GC_PRIV(pGC)		     \
+    xglGCPtr pGCPriv = XGL_GET_GC_PRIV (pGC)
+
+#define XGL_GC_WRAP(field, wrapper) \
+    pGCPriv->field = pGC->field;    \
+    pGC->field     = wrapper
+
+#define XGL_GC_UNWRAP(field)    \
+    pGC->field = pGCPriv->field
+
+
+#define xglPCFillMask		(1L << 0)
+#define xglPCFilterMask		(1L << 1)
+#define xglPCTransformMask	(1L << 2)
+#define xglPCComponentAlphaMask (1L << 3)
+#define xglPCDitherMask		(1L << 4)
+
+#define xglPFFilterMask		(1L << 8)
+
+#define xglPixmapTargetNo  0
+#define xglPixmapTargetOut 1
+#define xglPixmapTargetIn  2
+
+#ifdef XV
+
+typedef struct _xglXvPort {
+    PixmapPtr  pPixmap;
+    PicturePtr pSrc;
+    PicturePtr pDst;
+    PicturePtr pTmp;
+} xglXvPortRec, *xglXvPortPtr;
+
+#endif
+
+typedef struct _xglPixmap {
+    xglVisualPtr     pVisual;
+    glitz_surface_t  *surface;
+    glitz_drawable_t *drawable;
+    glitz_buffer_t   *buffer;
+    int		     target;
+    Bool	     acceleratedTile;
+    pointer	     bits;
+    int		     stride;
+    DamagePtr	     pDamage;
+    BoxRec	     damageBox;
+    RegionRec	     bitRegion;
+    Bool	     allBits;
+    unsigned long    pictureMask;
+    xglGeometryPtr   pGeometry;
+
+#ifdef XV
+    xglXvPortPtr     pPortPriv;
+#endif
+
+} xglPixmapRec, *xglPixmapPtr;
+
+extern int xglPixmapPrivateIndex;
+
+#define XGL_GET_PIXMAP_PRIV(pPixmap)				       \
+    ((xglPixmapPtr) (pPixmap)->devPrivates[xglPixmapPrivateIndex].ptr)
+
+#define XGL_PIXMAP_PRIV(pPixmap)			     \
+    xglPixmapPtr pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap)
+
+#define XGL_PICTURE_CHANGES(pictureMask)  (pictureMask & 0x0000ffff)
+#define XGL_PICTURE_FAILURES(pictureMask) (pictureMask & 0xffff0000)
+
+typedef struct _xglWin {
+    PixmapPtr    pPixmap;
+} xglWinRec, *xglWinPtr;
+
+extern int xglWinPrivateIndex;
+
+#define XGL_GET_WINDOW_PRIV(pWin)			      \
+    ((xglWinPtr) (pWin)->devPrivates[xglWinPrivateIndex].ptr)
+
+#define XGL_WINDOW_PRIV(pWin)			    \
+    xglWinPtr pWinPriv = XGL_GET_WINDOW_PRIV (pWin)
+
+#define XGL_GET_WINDOW_PIXMAP(pWin)		       \
+    (XGL_GET_WINDOW_PRIV((WindowPtr) (pWin))->pPixmap)
+
+
+#define XGL_GET_DRAWABLE_PIXMAP(pDrawable)   \
+    (((pDrawable)->type == DRAWABLE_WINDOW)? \
+     XGL_GET_WINDOW_PIXMAP (pDrawable):	     \
+     (PixmapPtr) (pDrawable))
+
+#define XGL_DRAWABLE_PIXMAP(pDrawable)			    \
+    PixmapPtr pPixmap = XGL_GET_DRAWABLE_PIXMAP (pDrawable)
+
+#define XGL_GET_DRAWABLE_PIXMAP_PRIV(pDrawable)		      \
+    XGL_GET_PIXMAP_PRIV (XGL_GET_DRAWABLE_PIXMAP (pDrawable))
+
+#define XGL_DRAWABLE_PIXMAP_PRIV(pDrawable)			        \
+    xglPixmapPtr pPixmapPriv = XGL_GET_DRAWABLE_PIXMAP_PRIV (pDrawable)
+
+#ifdef COMPOSITE
+#define __XGL_OFF_X_WIN(pPix) (-(pPix)->screen_x)
+#define __XGL_OFF_Y_WIN(pPix) (-(pPix)->screen_y)
+#else
+#define __XGL_OFF_X_WIN(pPix) (0)
+#define __XGL_OFF_Y_WIN(pPix) (0)
+#endif
+
+#define XGL_GET_DRAWABLE(pDrawable, pSurface, xOff, yOff)  \
+    {							   \
+	PixmapPtr _pPix;				   \
+	if ((pDrawable)->type != DRAWABLE_PIXMAP) {	   \
+	    _pPix = XGL_GET_WINDOW_PIXMAP (pDrawable);	   \
+	    (xOff) = __XGL_OFF_X_WIN (_pPix);		   \
+	    (yOff) = __XGL_OFF_Y_WIN (_pPix);		   \
+	} else {					   \
+	    _pPix = (PixmapPtr) (pDrawable);		   \
+	    (yOff) = (xOff) = 0;			   \
+	}						   \
+	(pSurface) = XGL_GET_PIXMAP_PRIV (_pPix)->surface; \
+    }
+
+#define XGL_DEFAULT_DPI 96
+
+#define XGL_SW_FAILURE_STRING "software fall-back failure"
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+#define POWER_OF_TWO(v) ((v & (v - 1)) == 0)
+
+#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
+
+#define FIXED_TO_FLOAT(f) (((glitz_float_t) (f)) / 65536)
+#define FLOAT_TO_FIXED(f) ((int) ((f) * 65536))
+
+#define BOX_NOTEMPTY(pBox)	      \
+    (((pBox)->x2 - (pBox)->x1) > 0 && \
+     ((pBox)->y2 - (pBox)->y1) > 0)
+
+
+/* xglinput.c */
+
+int
+xglMouseProc (DeviceIntPtr pDevice,
+	      int	   onoff);
+
+int
+xglKeybdProc (DeviceIntPtr pDevice,
+	      int	   onoff);
+
+void
+xglBell (int	      volume,
+	 DeviceIntPtr pDev,
+	 pointer      ctrl,
+	 int	      something);
+
+void
+xglKbdCtrl (DeviceIntPtr pDevice,
+	    KeybdCtrl	 *ctrl);
+
+void
+xglInitInput (int argc, char **argv);
+
+#ifdef XEVDEV
+
+extern Bool useEvdev;
+extern char *kbdEvdevFile;
+extern char *ptrEvdevFile;
+
+void
+xglEvdevReadInput (void);
+
+void
+xglWakeupHandler (pointer blockData,
+		  int	  result,
+		  pointer pReadMask);
+
+#endif
+
+/* xgloutput.c */
+
+void
+xglSetPixmapFormats (ScreenInfo *pScreenInfo);
+
+void
+xglSetRootClip (ScreenPtr pScreen,
+		Bool	  enable);
+
+
+/* xglcmap.c */
+
+void
+xglSetVisualTypes (int depth,
+		   int visuals,
+		   int redSize,
+		   int greenSize,
+		   int blueSize);
+
+Bool
+xglHasVisualTypes (xglVisualPtr pVisual,
+		   int		depth);
+
+glitz_format_t *
+xglFindBestSurfaceFormat (ScreenPtr         pScreen,
+			  xglPixelFormatPtr pPixel);
+
+void
+xglInitVisuals (ScreenPtr pScreen);
+
+xglVisualPtr
+xglFindVisualWithDepth (ScreenPtr pScreen,
+			int       depth);
+
+xglVisualPtr
+xglFindVisualWithId (ScreenPtr pScreen,
+		     int       vid);
+
+void
+xglClearVisualTypes (void);
+
+int
+xglNumPixelFormats (void);
+
+
+/* xglparse.c */
+
+char *
+xglParseFindNext (char *cur,
+		  char *delim,
+		  char *save,
+		  char *last);
+
+void
+xglParseScreen (char *arg);
+
+void
+xglUseMsg (void);
+
+int
+xglProcessArgument (int	 argc,
+		    char **argv,
+		    int	 i);
+
+
+/* xglscreen.c */
+
+Bool
+xglScreenInit (ScreenPtr pScreen);
+
+Bool
+xglFinishScreenInit (ScreenPtr pScreen);
+
+Bool
+xglCloseScreen (int	  index,
+		ScreenPtr pScreen);
+
+void
+xglCreateSolidAlphaPicture (ScreenPtr pScreen);
+
+
+/* xglarea.c */
+
+Bool
+xglRootAreaInit (xglRootAreaPtr	    pRoot,
+		 int		    maxLevel,
+		 int		    width,
+		 int		    height,
+		 int		    devPrivateSize,
+		 xglAreaFuncsPtr    funcs,
+		 pointer	    closure);
+
+void
+xglRootAreaFini (xglRootAreaPtr pRoot);
+
+void
+xglLeaveArea (xglAreaPtr pArea);
+
+void
+xglWithdrawArea (xglAreaPtr pArea);
+
+Bool
+xglFindArea (xglAreaPtr pArea,
+	     int	width,
+	     int	height,
+	     Bool	kickOut,
+	     pointer	closure);
+
+
+/* xglgeometry.c */
+
+#define GEOMETRY_DATA_TYPE_SHORT 0
+#define GEOMETRY_DATA_TYPE_FLOAT 1
+
+typedef struct _xglDataTypeInfo {
+    glitz_data_type_t type;
+    int		      size;
+} xglDataTypeInfoRec, *xglDataTypeInfoPtr;
+
+extern xglDataTypeInfoRec xglGeometryDataTypes[2];
+
+#define DEFAULT_GEOMETRY_DATA_TYPE GEOMETRY_DATA_TYPE_FLOAT
+
+#define GEOMETRY_USAGE_STREAM  0
+#define GEOMETRY_USAGE_STATIC  1
+#define GEOMETRY_USAGE_DYNAMIC 2
+#define GEOMETRY_USAGE_SYSMEM  3
+
+#define DEFAULT_GEOMETRY_USAGE GEOMETRY_USAGE_SYSMEM
+
+#define GEOMETRY_INIT(pScreen, pGeometry, _type, _usage, _size)		  \
+    {									  \
+	(pGeometry)->type      = _type;					  \
+	(pGeometry)->usage     = _usage;				  \
+	(pGeometry)->dataType  = DEFAULT_GEOMETRY_DATA_TYPE;		  \
+	(pGeometry)->usage     = _usage;				  \
+	(pGeometry)->size      = 0;					  \
+	(pGeometry)->endOffset = 0;					  \
+	(pGeometry)->data      = (pointer) 0;				  \
+	(pGeometry)->buffer    = NULL;					  \
+	(pGeometry)->broken    = FALSE;					  \
+	(pGeometry)->xOff      = 0;					  \
+	(pGeometry)->yOff      = 0;					  \
+	(pGeometry)->array     = NULL;					  \
+	(pGeometry)->first     = 0;					  \
+	(pGeometry)->count     = 0;					  \
+	if (_type == GLITZ_GEOMETRY_TYPE_VERTEX)			  \
+	{								  \
+	    (pGeometry)->width = 2;					  \
+	    (pGeometry)->f.vertex.type =				  \
+		xglGeometryDataTypes[(pGeometry)->dataType].type;	  \
+	    (pGeometry)->f.vertex.bytes_per_vertex = (pGeometry)->width * \
+		xglGeometryDataTypes[(pGeometry)->dataType].size;	  \
+	    (pGeometry)->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS;	  \
+	    (pGeometry)->f.vertex.attributes = 0;			  \
+	    (pGeometry)->f.vertex.src.type = GLITZ_DATA_TYPE_FLOAT;	  \
+	    (pGeometry)->f.vertex.src.size = GLITZ_COORDINATE_SIZE_X;	  \
+	    (pGeometry)->f.vertex.src.offset = 0;			  \
+	    (pGeometry)->f.vertex.mask.type = GLITZ_DATA_TYPE_FLOAT;	  \
+	    (pGeometry)->f.vertex.mask.size = GLITZ_COORDINATE_SIZE_X;	  \
+	    (pGeometry)->f.vertex.mask.offset = 0;			  \
+	}								  \
+	else								  \
+	{								  \
+	    (pGeometry)->width = 0;					  \
+	    (pGeometry)->f.bitmap.scanline_order =			  \
+		GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;			  \
+	    (pGeometry)->f.bitmap.bytes_per_line = 0;			  \
+	    (pGeometry)->f.bitmap.pad = GLYPHPADBYTES;			  \
+	}								  \
+	if (_size)							  \
+	    xglGeometryResize (pScreen, pGeometry, _size);		  \
+    }
+
+#define GEOMETRY_UNINIT(pGeometry)			    \
+    {							    \
+	if ((pGeometry)->array)				    \
+	    glitz_multi_array_destroy ((pGeometry)->array); \
+	if ((pGeometry)->buffer)			    \
+	    glitz_buffer_destroy ((pGeometry)->buffer);     \
+	if ((pGeometry)->data)				    \
+	    xfree ((pGeometry)->data);			    \
+    }
+
+#define GEOMETRY_SET_BUFFER(pGeometry, _buffer)		\
+    {							\
+	glitz_buffer_reference (_buffer);		\
+	if ((pGeometry)->buffer)			\
+	    glitz_buffer_destroy ((pGeometry)->buffer); \
+	(pGeometry)->buffer = _buffer;			\
+    }
+
+#define GEOMETRY_SET_MULTI_ARRAY(pGeometry, _array)	    \
+    {							    \
+	glitz_multi_array_reference (_array);		    \
+	if ((pGeometry)->array)				    \
+	    glitz_multi_array_destroy ((pGeometry)->array); \
+	(pGeometry)->array = _array;			    \
+    }
+
+#define GEOMETRY_RESIZE(pScreen, pGeometry, size) \
+    xglGeometryResize (pScreen, pGeometry, size)
+
+#define GEOMETRY_SET_TRANSLATE(pGeometry, _x, _y) \
+    {						  \
+	(pGeometry)->xOff = (_x) << 16;		  \
+	(pGeometry)->yOff = (_y) << 16;		  \
+    }
+
+#define GEOMETRY_TRANSLATE(pGeometry, tx, ty) \
+    {				              \
+	(pGeometry)->xOff += (tx) << 16;      \
+	(pGeometry)->yOff += (ty) << 16;      \
+    }
+
+#define GEOMETRY_TRANSLATE_FIXED(pGeometry, ftx, fty) \
+    {						      \
+	(pGeometry)->xOff += (ftx);		      \
+	(pGeometry)->yOff += (fty);		      \
+    }
+
+#define GEOMETRY_SET_VERTEX_PRIMITIVE(pGeometry, _primitive) \
+    (pGeometry)->f.vertex.primitive = _primitive
+
+#define GEOMETRY_SET_VERTEX_DATA_TYPE(pGeometry, _type)		       \
+    {								       \
+	(pGeometry)->dataType = _type;				       \
+	(pGeometry)->f.vertex.type = xglGeometryDataTypes[_type].type; \
+	(pGeometry)->f.vertex.bytes_per_vertex = (pGeometry)->width *  \
+	    xglGeometryDataTypes[_type].size;			       \
+    }
+
+#define GEOMETRY_ADD_BOX(pScreen, pGeometry, pBox, nBox) \
+    xglGeometryAddBox (pScreen, pGeometry, pBox, nBox,	 \
+		       (pGeometry)->endOffset)
+
+#define GEOMETRY_ADD_REGION_AT(pScreen, pGeometry, pRegion, offset) \
+     xglGeometryAddBox (pScreen, pGeometry,			    \
+			REGION_RECTS (pRegion),			    \
+			REGION_NUM_RECTS (pRegion),		    \
+			offset)
+
+#define GEOMETRY_ADD_REGION(pScreen, pGeometry, pRegion) \
+    xglGeometryAddBox (pScreen, pGeometry,		 \
+		       REGION_RECTS (pRegion),		 \
+		       REGION_NUM_RECTS (pRegion),	 \
+		       (pGeometry)->endOffset)
+
+#define GEOMETRY_ADD_SPAN(pScreen, pGeometry, ppt, pwidth, n) \
+    xglGeometryAddSpan (pScreen, pGeometry, ppt, pwidth, n,   \
+			(pGeometry)->endOffset)
+
+#define GEOMETRY_ADD_LINE(pScreen, pGeometry, loop, mode, npt, ppt) \
+    xglGeometryAddLine (pScreen, pGeometry, loop, mode, npt, ppt,   \
+			(pGeometry)->endOffset)
+
+#define GEOMETRY_ADD_SEGMENT(pScreen, pGeometry, nsegInit, pSegInit) \
+    xglGeometryAddSegment (pScreen, pGeometry, nsegInit, pSegInit,   \
+			   (pGeometry)->endOffset)
+
+#define GEOMETRY_FOR_GLYPH(pScreen, pGeometry, nGlyph, ppciInit, pglyphBase) \
+    xglGeometryForGlyph (pScreen, pGeometry, nGlyph, ppciInit, pglyphBase);
+
+#define GEOMETRY_ADD_TRAPEZOID(pScreen, pGeometry, pTrap, nTrap) \
+    xglGeometryAddTrapezoid (pScreen, pGeometry, pTrap, nTrap,	 \
+			     (pGeometry)->endOffset)
+
+#define GEOMETRY_ADD_TRAP(pScreen, pGeometry, pTrap, nTrap) \
+    xglGeometryAddTrap (pScreen, pGeometry, pTrap, nTrap,   \
+			(pGeometry)->endOffset)
+
+#define GEOMETRY_GET_FORMAT(pGeometry, format) \
+    xglGeometryGetFormat (pGeometry, format)
+
+#define GEOMETRY_ENABLE(pGeometry, surface) \
+    xglSetGeometry (pGeometry, surface)
+
+#define GEOMETRY_DISABLE(surface)				       \
+    glitz_set_geometry (surface, GLITZ_GEOMETRY_TYPE_NONE, NULL, NULL)
+
+void
+xglGeometryResize (ScreenPtr	  pScreen,
+		   xglGeometryPtr pGeometry,
+		   int		  size);
+
+void
+xglGeometryAddBox (ScreenPtr	  pScreen,
+		   xglGeometryPtr pGeometry,
+		   BoxPtr	  pBox,
+		   int		  nBox,
+		   int		  offset);
+
+void
+xglGeometryAddSpan (ScreenPtr	   pScreen,
+		    xglGeometryPtr pGeometry,
+		    DDXPointPtr	   ppt,
+		    int		   *pwidth,
+		    int		   n,
+		    int		   offset);
+
+void
+xglGeometryAddLine (ScreenPtr	   pScreen,
+		    xglGeometryPtr pGeometry,
+		    int		   loop,
+		    int		   mode,
+		    int		   npt,
+		    DDXPointPtr    ppt,
+		    int		   offset);
+
+void
+xglGeometryAddSegment (ScreenPtr      pScreen,
+		       xglGeometryPtr pGeometry,
+		       int	      nsegInit,
+		       xSegment       *pSegInit,
+		       int	      offset);
+
+void
+xglGeometryForGlyph (ScreenPtr	    pScreen,
+		     xglGeometryPtr pGeometry,
+		     unsigned int   nGlyph,
+		     CharInfoPtr    *ppciInit,
+		     pointer	    pglyphBase);
+
+void
+xglGeometryAddTrapezoid (ScreenPtr	pScreen,
+			 xglGeometryPtr pGeometry,
+			 xTrapezoid	*pTrap,
+			 int		nTrap,
+			 int		offset);
+
+void
+xglGeometryAddTrap (ScreenPtr	   pScreen,
+		    xglGeometryPtr pGeometry,
+		    xTrap	   *pTrap,
+		    int		   nTrap,
+		    int		   offset);
+
+xglGeometryPtr
+xglGetScratchGeometryWithSize (ScreenPtr pScreen,
+			       int	 size);
+
+xglGeometryPtr
+xglGetScratchVertexGeometryWithType (ScreenPtr pScreen,
+				     int       type,
+				     int       count);
+
+xglGeometryPtr
+xglGetScratchVertexGeometry (ScreenPtr pScreen,
+			     int       count);
+
+Bool
+xglSetGeometry (xglGeometryPtr	pGeometry,
+		glitz_surface_t *surface);
+
+
+/* xglpixmap.c */
+
+#define XGL_PIXMAP_USAGE_HINT_STREAM_DRAW  1
+#define XGL_PIXMAP_USAGE_HINT_STREAM_READ  2
+#define XGL_PIXMAP_USAGE_HINT_STREAM_COPY  3
+#define XGL_PIXMAP_USAGE_HINT_STATIC_DRAW  4
+#define XGL_PIXMAP_USAGE_HINT_STATIC_READ  5
+#define XGL_PIXMAP_USAGE_HINT_STATIC_COPY  6
+#define XGL_PIXMAP_USAGE_HINT_DYNAMIC_DRAW 7
+#define XGL_PIXMAP_USAGE_HINT_DYNAMIC_READ 8
+#define XGL_PIXMAP_USAGE_HINT_DYNAMIC_COPY 9
+
+#define XGL_PIXMAP_USAGE_HINT_DEFAULT XGL_PIXMAP_USAGE_HINT_STREAM_DRAW
+
+PixmapPtr
+xglCreatePixmap (ScreenPtr  pScreen,
+		 int	    width,
+		 int	    height,
+		 int	    depth);
+
+void
+xglFiniPixmap (PixmapPtr pPixmap);
+
+Bool
+xglDestroyPixmap (PixmapPtr pPixmap);
+
+Bool
+xglModifyPixmapHeader (PixmapPtr pPixmap,
+		       int	 width,
+		       int	 height,
+		       int	 depth,
+		       int	 bitsPerPixel,
+		       int	 devKind,
+		       pointer	 pPixData);
+
+void
+xglSetPixmapVisual (PixmapPtr    pPixmap,
+		    xglVisualPtr pVisual);
+
+RegionPtr
+xglPixmapToRegion (PixmapPtr pPixmap);
+
+xglGeometryPtr
+xglPixmapToGeometry (PixmapPtr pPixmap,
+		     int       xOff,
+		     int       yOff);
+
+Bool
+xglCreatePixmapSurface (PixmapPtr pPixmap);
+
+Bool
+xglAllocatePixmapBits (PixmapPtr pPixmap, int hint);
+
+Bool
+xglMapPixmapBits (PixmapPtr pPixmap);
+
+Bool
+xglUnmapPixmapBits (PixmapPtr pPixmap);
+
+Bool
+xglCheckPixmapSize (PixmapPtr		 pPixmap,
+		    xglSizeConstraintPtr pSize);
+
+void
+xglEnablePixmapAccel (PixmapPtr	      pPixmap,
+		      xglAccelInfoPtr pAccel);
+
+Bool
+xglPixmapSurfaceInit (PixmapPtr     pPixmap,
+		      unsigned long features,
+		      int           width,
+		      int           height);
+
+Bool
+xglPixmapCreateDamage (PixmapPtr pPixmap);
+
+/* xglsync.c */
+
+Bool
+xglSyncBits (DrawablePtr pDrawable,
+	     BoxPtr	 pExtents);
+
+void
+xglSyncDamageBoxBits (DrawablePtr pDrawable);
+
+Bool
+xglSyncSurface (DrawablePtr pDrawable);
+
+Bool
+xglPrepareTarget (DrawablePtr pDrawable);
+
+void
+xglAddSurfaceDamage (DrawablePtr pDrawable,
+		     RegionPtr   pRegion);
+
+void
+xglAddCurrentSurfaceDamage (DrawablePtr pDrawable);
+
+void
+xglAddBitDamage (DrawablePtr pDrawable,
+		 RegionPtr   pRegion);
+
+void
+xglAddCurrentBitDamage (DrawablePtr pDrawable);
+
+
+/* xglsolid.c */
+
+Bool
+xglSolid (DrawablePtr	   pDrawable,
+	  glitz_operator_t op,
+	  glitz_surface_t  *solid,
+	  xglGeometryPtr   pGeometry,
+	  int		   x,
+	  int		   y,
+	  int		   width,
+	  int		   height,
+	  BoxPtr	   pBox,
+	  int		   nBox);
+
+Bool
+xglSolidGlyph (DrawablePtr  pDrawable,
+	       GCPtr	    pGC,
+	       int	    x,
+	       int	    y,
+	       unsigned int nGlyph,
+	       CharInfoPtr  *ppci,
+	       pointer      pglyphBase);
+
+
+/* xgltile.c */
+
+xglGeometryPtr
+xglTiledBoxGeometry (PixmapPtr pTile,
+		     int       tileX,
+		     int       tileY,
+		     BoxPtr    pBox,
+		     int       nBox);
+
+Bool
+xglTile (DrawablePtr	  pDrawable,
+	 glitz_operator_t op,
+	 PixmapPtr	  pTile,
+	 int		  tileX,
+	 int		  tileY,
+	 xglGeometryPtr	  pGeometry,
+	 int		  x,
+	 int		  y,
+	 int		  width,
+	 int		  height,
+	 BoxPtr		  pBox,
+	 int		  nBox);
+
+
+/* xglcopy.c */
+
+Bool
+xglCopy (DrawablePtr pSrc,
+	 DrawablePtr pDst,
+	 int	     dx,
+	 int	     dy,
+	 BoxPtr	     pBox,
+	 int	     nBox);
+
+void
+xglCopyProc (DrawablePtr pSrc,
+	     DrawablePtr pDst,
+	     GCPtr	 pGC,
+	     BoxPtr	 pBox,
+	     int	 nBox,
+	     int	 dx,
+	     int	 dy,
+	     Bool	 reverse,
+	     Bool	 upsidedown,
+	     Pixel	 bitplane,
+	     void	 *closure);
+
+
+/* xglfill.c */
+
+Bool
+xglFill (DrawablePtr	pDrawable,
+	 GCPtr		pGC,
+	 xglGeometryPtr pGeometry,
+	 int		x,
+	 int		y,
+	 int		width,
+	 int		height,
+	 BoxPtr		pBox,
+	 int		nBox);
+
+void
+xglFillSpan (DrawablePtr pDrawable,
+	     GCPtr	 pGC,
+	     int	 n,
+	     DDXPointPtr ppt,
+	     int	 *pwidth);
+
+void
+xglFillRect (DrawablePtr pDrawable,
+	     GCPtr	 pGC,
+	     int	 nrect,
+	     xRectangle  *prect);
+
+Bool
+xglFillLine (DrawablePtr pDrawable,
+	     GCPtr       pGC,
+	     int	 mode,
+	     int	 npt,
+	     DDXPointPtr ppt);
+
+Bool
+xglFillSegment (DrawablePtr pDrawable,
+		GCPtr	    pGC,
+		int	    nsegInit,
+		xSegment    *pSegInit);
+
+Bool
+xglFillGlyph (DrawablePtr  pDrawable,
+	      GCPtr	   pGC,
+	      int	   x,
+	      int	   y,
+	      unsigned int nglyph,
+	      CharInfoPtr  *ppciInit,
+	      pointer      pglyphBase);
+
+
+/* xglwindow.c */
+
+Bool
+xglCreateWindow (WindowPtr pWin);
+
+Bool
+xglDestroyWindow (WindowPtr pWin);
+
+Bool
+xglChangeWindowAttributes (WindowPtr	 pWin,
+			   unsigned long mask);
+
+void
+xglCopyWindow (WindowPtr   pWin,
+	       DDXPointRec ptOldOrg,
+	       RegionPtr   prgnSrc);
+
+PixmapPtr
+xglGetWindowPixmap (WindowPtr pWin);
+
+void
+xglSetWindowPixmap (WindowPtr pWin,
+		    PixmapPtr pPixmap);
+
+
+/* xglget.c */
+
+void
+xglGetImage (DrawablePtr   pDrawable,
+	     int	   x,
+	     int	   y,
+	     int	   w,
+	     int	   h,
+	     unsigned int  format,
+	     unsigned long planeMask,
+	     char	   *d);
+
+void
+xglGetSpans (DrawablePtr pDrawable,
+	     int	 wMax,
+	     DDXPointPtr ppt,
+	     int	 *pwidth,
+	     int	 nspans,
+	     char	 *pchardstStart);
+
+
+/* xglgc.c */
+
+Bool
+xglCreateGC (GCPtr pGC);
+
+void
+xglDestroyGC (GCPtr pGC);
+
+void
+xglValidateGC (GCPtr	     pGC,
+	       unsigned long changes,
+	       DrawablePtr   pDrawable);
+
+void
+xglFillSpans  (DrawablePtr pDrawable,
+	       GCPtr	   pGC,
+	       int	   nspans,
+	       DDXPointPtr ppt,
+	       int	   *pwidth,
+	       int	   fSorted);
+
+void
+xglSetSpans (DrawablePtr pDrawable,
+	     GCPtr	 pGC,
+	     char	 *psrc,
+	     DDXPointPtr ppt,
+	     int	 *pwidth,
+	     int	 nspans,
+	     int	 fSorted);
+
+void
+xglPutImage (DrawablePtr pDrawable,
+	     GCPtr	 pGC,
+	     int	 depth,
+	     int	 x,
+	     int	 y,
+	     int	 w,
+	     int	 h,
+	     int	 leftPad,
+	     int	 format,
+	     char	 *bits);
+
+RegionPtr
+xglCopyArea (DrawablePtr pSrc,
+	     DrawablePtr pDst,
+	     GCPtr	 pGC,
+	     int	 srcX,
+	     int	 srcY,
+	     int	 w,
+	     int	 h,
+	     int	 dstX,
+	     int	 dstY);
+
+RegionPtr
+xglCopyPlane (DrawablePtr   pSrc,
+	      DrawablePtr   pDst,
+	      GCPtr	    pGC,
+	      int	    srcX,
+	      int	    srcY,
+	      int	    w,
+	      int	    h,
+	      int	    dstX,
+	      int	    dstY,
+	      unsigned long bitPlane);
+
+void
+xglPolyPoint (DrawablePtr pDrawable,
+	      GCPtr       pGC,
+	      int	  mode,
+	      int	  npt,
+	      DDXPointPtr pptInit);
+
+void
+xglPolylines (DrawablePtr pDrawable,
+	      GCPtr       pGC,
+	      int	  mode,
+	      int	  npt,
+	      DDXPointPtr ppt);
+
+void
+xglPolySegment (DrawablePtr pDrawable,
+		GCPtr	    pGC,
+		int	    nsegInit,
+		xSegment    *pSegInit);
+
+void
+xglPolyArc (DrawablePtr pDrawable,
+	    GCPtr	pGC,
+	    int		narcs,
+	    xArc	*pArcs);
+
+void
+xglPolyFillRect (DrawablePtr pDrawable,
+		 GCPtr	     pGC,
+		 int	     nrect,
+		 xRectangle  *prect);
+
+void
+xglPolyFillArc (DrawablePtr pDrawable,
+		GCPtr	    pGC,
+		int	    narcs,
+		xArc	    *pArcs);
+
+void
+xglImageGlyphBlt (DrawablePtr  pDrawable,
+		  GCPtr	       pGC,
+		  int	       x,
+		  int	       y,
+		  unsigned int nglyph,
+		  CharInfoPtr  *ppci,
+		  pointer      pglyphBase);
+
+void
+xglPolyGlyphBlt (DrawablePtr  pDrawable,
+		 GCPtr	      pGC,
+		 int	      x,
+		 int	      y,
+		 unsigned int nglyph,
+		 CharInfoPtr  *ppci,
+		 pointer      pglyphBase);
+void
+xglPushPixels (GCPtr	   pGC,
+	       PixmapPtr   pBitmap,
+	       DrawablePtr pDrawable,
+	       int	   w,
+	       int	   h,
+	       int	   x,
+	       int	   y);
+
+
+#ifdef MITSHM
+
+/* xglshm.c */
+
+void
+xglShmPutImage (DrawablePtr  pDrawable,
+		GCPtr	     pGC,
+		int	     depth,
+		unsigned int format,
+		int	     w,
+		int	     h,
+		int	     sx,
+		int	     sy,
+		int	     sw,
+		int	     sh,
+		int	     dx,
+		int	     dy,
+		char	     *data);
+
+#endif
+
+
+#ifdef RENDER
+
+/* xglpict.c */
+
+void
+xglComposite (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
+xglAddTriangles (PicturePtr pDst,
+		 INT16	    xOff,
+		 INT16	    yOff,
+		 int	    ntri,
+		 xTriangle  *tris);
+
+void
+xglChangePicture (PicturePtr pPicture,
+		  Mask	     mask);
+
+int
+xglChangePictureTransform (PicturePtr    pPicture,
+			   PictTransform *transform);
+
+int
+xglChangePictureFilter (PicturePtr pPicture,
+			int	   filter,
+			xFixed	   *params,
+			int	   nparams);
+
+PicturePtr
+xglCreateDevicePicture (pointer data);
+
+Bool
+xglSyncPicture (ScreenPtr  pScreen,
+		PicturePtr pPicture,
+		INT16	   x,
+		INT16	   y,
+		CARD16	   width,
+		CARD16	   height,
+		INT16	   *xOff,
+		INT16	   *yOff);
+
+Bool
+xglPictureInit (ScreenPtr pScreen);
+
+void
+xglPictureClipExtents (PicturePtr pPicture,
+		       BoxPtr     extents);
+
+
+/* xglcompose.c */
+
+Bool
+xglCompositeGeneral (CARD8	     op,
+		     PicturePtr	     pSrc,
+		     PicturePtr	     pMask,
+		     PicturePtr	     pDst,
+		     xglGeometryPtr  pGeometry,
+		     INT16	     xSrc,
+		     INT16	     ySrc,
+		     INT16	     xMask,
+		     INT16	     yMask,
+		     INT16	     xDst,
+		     INT16	     yDst,
+		     CARD16	     width,
+		     CARD16	     height);
+
+
+/* xglglyph.c */
+
+Bool
+xglRealizeGlyph (ScreenPtr pScreen,
+		 GlyphPtr  pGlyph);
+
+void
+xglUnrealizeGlyph (ScreenPtr pScreen,
+		   GlyphPtr  pGlyph);
+
+Bool
+xglInitGlyphCache (xglGlyphCachePtr pCache,
+		   ScreenPtr	    pScreen,
+		   PictFormatPtr    format);
+
+void
+xglFiniGlyphCache (xglGlyphCachePtr pCache);
+
+void
+xglGlyphs (CARD8	 op,
+	   PicturePtr	 pSrc,
+	   PicturePtr	 pDst,
+	   PictFormatPtr maskFormat,
+	   INT16	 xSrc,
+	   INT16	 ySrc,
+	   int		 nlist,
+	   GlyphListPtr	 list,
+	   GlyphPtr	 *glyphs);
+
+
+/* xgltrap.c */
+
+void
+xglTrapezoids (CARD8	     op,
+	       PicturePtr    pSrc,
+	       PicturePtr    pDst,
+	       PictFormatPtr maskFormat,
+	       INT16	     xSrc,
+	       INT16	     ySrc,
+	       int	     nTrap,
+	       xTrapezoid    *traps);
+
+void
+xglAddTraps (PicturePtr pDst,
+	     INT16	xOff,
+	     INT16	yOff,
+	     int	nTrap,
+	     xTrap	*traps);
+
+#endif
+
+#ifdef XGL_MODULAR
+
+/* xglloader.c */
+
+typedef struct _xglSymbol {
+    void       **ptr;
+    const char *name;
+} xglSymbolRec, *xglSymbolPtr;
+
+void *
+xglLoadModule (const char *name,
+	       int	  flag);
+
+void
+xglUnloadModule (void *handle);
+
+Bool
+xglLookupSymbols (void         *handle,
+		  xglSymbolPtr sym,
+		  int	       nSym);
+
+#endif
+
+
+/* xglxv.c */
+
+#ifdef XV
+
+Bool
+xglXvScreenInit (ScreenPtr pScreen);
+
+#endif
+
+
+/* xglhash.c */
+
+typedef struct _xglHashTable *xglHashTablePtr;
+
+Bool
+xglLoadHashFuncs (void *handle);
+
+xglHashTablePtr
+xglNewHashTable (void);
+
+void
+xglDeleteHashTable (xglHashTablePtr pTable);
+
+void *
+xglHashLookup (const xglHashTablePtr pTable,
+	       unsigned int	     key);
+
+void
+xglHashInsert (xglHashTablePtr pTable,
+	       unsigned int    key,
+	       void	       *data);
+
+void
+xglHashRemove (xglHashTablePtr pTable,
+	       unsigned int    key);
+
+unsigned int
+xglHashFirstEntry (xglHashTablePtr pTable);
+
+unsigned int
+xglHashNextEntry (const xglHashTablePtr pTable,
+		  unsigned int		key);
+
+unsigned int
+xglHashFindFreeKeyBlock (xglHashTablePtr pTable,
+			 unsigned int	 numKeys);
+
+#endif /* _XGL_H_ */
diff --git a/xgl/xglarea.c b/xgl/xglarea.c
new file mode 100644
index 0000000..cdf652d
--- /dev/null
+++ b/xgl/xglarea.c
@@ -0,0 +1,323 @@
+/*
+ * Copyright © 2005 Novell, Inc.
+ *
+ * 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
+ * Novell, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Novell, Inc. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NOVELL, INC. 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+
+static Bool
+xglAreaMoveIn (xglAreaPtr pArea,
+	       pointer	  closure)
+{
+    pArea->closure = closure;
+    pArea->state   = xglAreaOccupied;
+
+    return (*pArea->pRoot->funcs->MoveIn) (pArea, closure);
+}
+
+static void
+xglAreaMoveOut (xglAreaPtr pArea)
+{
+    (*pArea->pRoot->funcs->MoveOut) (pArea, pArea->closure);
+
+    pArea->closure = (pointer) 0;
+    pArea->state   = xglAreaAvailable;
+}
+
+static xglAreaPtr
+xglAreaCreate (xglRootAreaPtr pRoot,
+	       int	      level,
+	       int	      x,
+	       int	      y,
+	       int	      width,
+	       int	      height)
+{
+    xglAreaPtr pArea;
+    int	       n = 4;
+
+    pArea = xalloc (sizeof (xglAreaRec) + pRoot->devPrivateSize);
+    if (!pArea)
+	return NULL;
+
+    pArea->level   = level;
+    pArea->x	   = x;
+    pArea->y	   = y;
+    pArea->width   = width;
+    pArea->height  = height;
+    pArea->pRoot   = pRoot;
+    pArea->closure = (pointer) 0;
+    pArea->state   = xglAreaAvailable;
+
+    while (n--)
+	pArea->pArea[n] = NULL;
+
+    if (pRoot->devPrivateSize)
+	pArea->devPrivate.ptr = pArea + 1;
+    else
+	pArea->devPrivate.ptr = (pointer) 0;
+
+    if (!(*pArea->pRoot->funcs->Create) (pArea))
+    {
+	free (pArea);
+	return NULL;
+    }
+
+    return pArea;
+}
+
+static void
+xglAreaDestroy (xglAreaPtr pArea)
+{
+    if (!pArea)
+	return;
+
+    if (pArea->state == xglAreaOccupied)
+    {
+	xglAreaMoveOut (pArea);
+    }
+    else
+    {
+	int n = 4;
+
+	while (n--)
+	    xglAreaDestroy (pArea->pArea[n]);
+    }
+
+    xfree (pArea);
+}
+
+static xglAreaPtr
+xglAreaGetTopScoredSubArea (xglAreaPtr pArea)
+{
+    if (!pArea)
+	return NULL;
+
+    switch (pArea->state) {
+    case xglAreaOccupied:
+	return pArea;
+    case xglAreaAvailable:
+	break;
+    case xglAreaDivided: {
+	xglAreaPtr tmp, top = NULL;
+	int	   i;
+
+	for (i = 0; i < 4; i++)
+	{
+	    tmp = xglAreaGetTopScoredSubArea (pArea->pArea[i]);
+	    if (tmp && top)
+	    {
+		if ((*pArea->pRoot->funcs->CompareScore) (tmp,
+							  tmp->closure,
+							  top->closure) > 0)
+		    top = tmp;
+	    }
+	    else if (tmp)
+	    {
+		top = tmp;
+	    }
+	}
+	return top;
+    }
+    }
+
+    return NULL;
+}
+
+static Bool
+xglAreaFind (xglAreaPtr pArea,
+	     int	width,
+	     int	height,
+	     Bool	kickOut,
+	     pointer	closure)
+{
+    if (pArea->width < width || pArea->height < height)
+	return FALSE;
+
+    switch (pArea->state) {
+    case xglAreaOccupied:
+	if (kickOut)
+	{
+	    if ((*pArea->pRoot->funcs->CompareScore) (pArea,
+						      pArea->closure,
+						      closure) >= 0)
+		return FALSE;
+
+	    xglAreaMoveOut (pArea);
+	} else
+	    return FALSE;
+
+    /* fall-through */
+    case xglAreaAvailable:
+    {
+	if (pArea->level == pArea->pRoot->maxLevel ||
+	    (pArea->width == width && pArea->height == height))
+	{
+	    if (xglAreaMoveIn (pArea, closure))
+		return TRUE;
+	}
+	else
+	{
+	    int dx[4], dy[4], w[4], h[4], i;
+
+	    dx[0] = dx[2] = dy[0] = dy[1] = 0;
+
+	    w[0] = w[2] = dx[1] = dx[3] = width;
+	    h[0] = h[1] = dy[2] = dy[3] = height;
+
+	    w[1] = w[3] = pArea->width - width;
+	    h[2] = h[3] = pArea->height - height;
+
+	    for (i = 0; i < 2; i++)
+	    {
+		if (w[i])
+		    pArea->pArea[i] =
+			xglAreaCreate (pArea->pRoot,
+				       pArea->level + 1,
+				       pArea->x + dx[i],
+				       pArea->y + dy[i],
+				       w[i], h[i]);
+	    }
+
+	    for (; i < 4; i++)
+	    {
+		if (w[i] && h[i])
+		    pArea->pArea[i] =
+			xglAreaCreate (pArea->pRoot,
+				       pArea->level + 1,
+				       pArea->x + dx[i],
+				       pArea->y + dy[i],
+				       w[i], h[i]);
+	    }
+
+	    pArea->state = xglAreaDivided;
+
+	    if (xglAreaFind (pArea->pArea[0], width, height, kickOut, closure))
+		return TRUE;
+	}
+    } break;
+    case xglAreaDivided:
+    {
+	xglAreaPtr topArea;
+	int	   i, rejected = FALSE;
+
+	for (i = 0; i < 4; i++)
+	{
+	    if (pArea->pArea[i])
+	    {
+		if (pArea->pArea[i]->width >= width &&
+		    pArea->pArea[i]->height >= height)
+		{
+		    if (xglFindArea (pArea->pArea[i], width, height, kickOut,
+				     closure))
+			return TRUE;
+
+		    rejected = TRUE;
+		}
+	    }
+	}
+
+	if (rejected)
+	    return FALSE;
+
+	topArea = xglAreaGetTopScoredSubArea (pArea);
+	if (topArea)
+	{
+	    if (kickOut)
+	    {
+		if ((*pArea->pRoot->funcs->CompareScore) (topArea,
+							  topArea->closure,
+							  closure) >= 0)
+		    return FALSE;
+	    } else
+		return FALSE;
+	}
+
+	for (i = 0; i < 4; i++)
+	{
+	    xglAreaDestroy (pArea->pArea[i]);
+	    pArea->pArea[i] = NULL;
+	}
+
+	pArea->closure = (pointer) 0;
+	pArea->state   = xglAreaAvailable;
+	if (xglFindArea (pArea, width, height, TRUE, closure))
+	    return TRUE;
+
+    } break;
+    }
+
+    return FALSE;
+}
+
+Bool
+xglRootAreaInit (xglRootAreaPtr	    pRoot,
+		 int		    maxLevel,
+		 int		    width,
+		 int		    height,
+		 int		    devPrivateSize,
+		 xglAreaFuncsPtr    funcs,
+		 pointer	    closure)
+{
+    pRoot->maxLevel	  = maxLevel;
+    pRoot->funcs	  = funcs;
+    pRoot->devPrivateSize = devPrivateSize;
+    pRoot->closure	  = closure;
+
+    pRoot->pArea = xglAreaCreate (pRoot, 0, 0, 0, width, height);
+    if (!pRoot->pArea)
+	return FALSE;
+
+    return TRUE;
+}
+
+void
+xglRootAreaFini (xglRootAreaPtr pRoot)
+{
+    xglAreaDestroy (pRoot->pArea);
+}
+
+void
+xglLeaveArea (xglAreaPtr pArea)
+{
+    xglAreaMoveOut (pArea);
+}
+
+void
+xglWithdrawArea (xglAreaPtr pArea)
+{
+    pArea->closure = NULL;
+    pArea->state   = xglAreaAvailable;
+}
+
+Bool
+xglFindArea (xglAreaPtr pArea,
+	     int	width,
+	     int	height,
+	     Bool	kickOut,
+	     pointer	closure)
+{
+    if (width < 1 || height < 0)
+	return FALSE;
+
+    return xglAreaFind (pArea, width, height, kickOut, closure);
+}
diff --git a/xgl/xglcmap.c b/xgl/xglcmap.c
new file mode 100644
index 0000000..99593eb
--- /dev/null
+++ b/xgl/xglcmap.c
@@ -0,0 +1,455 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+#include "colormapst.h"
+#include "micmap.h"
+#include "fb.h"
+
+xglPixelFormatRec xglPixelFormats[] = {
+    {
+	8, 8,
+	{
+	    8,
+	    0x000000ff,
+	    0x00000000,
+	    0x00000000,
+	    0x00000000
+	}
+    }, {
+	15, 5,
+	{
+	    16,
+	    0x00000000,
+	    0x00007c00,
+	    0x000003e0,
+	    0x0000001f
+	}
+    }, {
+	16, 6,
+	{
+	    16,
+	    0x00000000,
+	    0x0000f800,
+	    0x000007e0,
+	    0x0000001f
+	}
+    }, {
+	24, 8,
+	{
+	    32,
+	    0x00000000,
+	    0x00ff0000,
+	    0x0000ff00,
+	    0x000000ff
+	}
+    }, {
+	32, 8,
+	{
+	    32,
+	    0xff000000,
+	    0x00ff0000,
+	    0x0000ff00,
+	    0x000000ff
+	}
+    }
+};
+
+xglVisualPtr xglVisuals = NULL;
+
+int
+xglNumPixelFormats(void)
+{
+    return (sizeof (xglPixelFormats) / sizeof(xglPixelFormats[0]));
+}
+
+void
+xglSetVisualTypes (int depth,
+		   int visuals,
+		   int redSize,
+		   int greenSize,
+		   int blueSize)
+{
+    xglPixelFormatPtr pBestFormat = 0;
+    int		      i, rs, gs, bs, diff, bestDiff = 0;
+
+    for (i = 0; i < xglNumPixelFormats(); i++)
+    {
+	if (xglPixelFormats[i].depth == depth)
+	{
+	    if (visuals)
+	    {
+		rs = Ones (xglPixelFormats[i].masks.red_mask);
+		gs = Ones (xglPixelFormats[i].masks.green_mask);
+		bs = Ones (xglPixelFormats[i].masks.blue_mask);
+
+		if (redSize   >= rs &&
+		    greenSize >= gs &&
+		    blueSize  >= bs)
+		{
+		    diff = (redSize - rs) + (greenSize - gs) + (blueSize - bs);
+		    if (pBestFormat)
+		    {
+			if (diff < bestDiff)
+			{
+			    pBestFormat = &xglPixelFormats[i];
+			    bestDiff = diff;
+			}
+		    }
+		    else
+		    {
+			pBestFormat = &xglPixelFormats[i];
+			bestDiff = diff;
+		    }
+		}
+	    }
+	    else
+	    {
+		pBestFormat = &xglPixelFormats[i];
+		break;
+	    }
+	}
+    }
+
+    if (pBestFormat)
+    {
+	xglVisualPtr new, *prev, v;
+
+	new = xalloc (sizeof (xglVisualRec));
+	if (!new)
+	    return;
+
+	new->next = 0;
+
+	new->format.surface  = 0;
+	new->format.drawable = 0;
+	new->pPixel	     = pBestFormat;
+	new->vid	     = 0;
+
+	for (prev = &xglVisuals; (v = *prev); prev = &v->next);
+	*prev = new;
+    }
+}
+
+Bool
+xglHasVisualTypes (xglVisualPtr pVisual,
+		   int		depth)
+{
+    xglVisualPtr v;
+
+    for (v = pVisual; v; v = v->next)
+	if (v->pPixel->depth == depth)
+	    return TRUE;
+
+    return FALSE;
+}
+
+glitz_format_t *
+xglFindBestSurfaceFormat (ScreenPtr         pScreen,
+			  xglPixelFormatPtr pPixel)
+{
+    glitz_format_t templ, *format, *best = 0;
+    unsigned int   mask;
+    unsigned short rs, gs, bs, as;
+    int	           i = 0;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    rs = Ones (pPixel->masks.red_mask);
+    gs = Ones (pPixel->masks.green_mask);
+    bs = Ones (pPixel->masks.blue_mask);
+    as = Ones (pPixel->masks.alpha_mask);
+
+    templ.color.fourcc = GLITZ_FOURCC_RGB;
+    mask = GLITZ_FORMAT_FOURCC_MASK;
+
+    do {
+	format = glitz_find_format (pScreenPriv->drawable, mask, &templ, i++);
+	if (format)
+	{
+	    if (format->color.red_size   >= rs &&
+		format->color.green_size >= gs &&
+		format->color.blue_size  >= bs &&
+		format->color.alpha_size >= as)
+	    {
+		if (best)
+		{
+		    if (((format->color.red_size   - rs) +
+			 (format->color.green_size - gs) +
+			 (format->color.blue_size  - bs)) <
+			((best->color.red_size   - rs) +
+			 (best->color.green_size - gs) +
+			 (best->color.blue_size  - bs)))
+			best = format;
+		}
+		else
+		{
+		    best = format;
+		}
+	    }
+	}
+    } while (format);
+
+    return best;
+}
+
+static Bool
+xglInitVisual (ScreenPtr	 pScreen,
+	       xglVisualPtr	 pVisual,
+	       xglPixelFormatPtr pPixel,
+	       VisualID		 vid)
+{
+    glitz_format_t *format;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    format = xglFindBestSurfaceFormat (pScreen, pPixel);
+    if (format)
+    {
+	glitz_drawable_format_t templ;
+	unsigned long	        mask;
+
+	templ.color        = format->color;
+	templ.depth_size   = 0;
+	templ.stencil_size = 0;
+	templ.doublebuffer = 0;
+	templ.samples      = 1;
+
+	mask =
+	    GLITZ_FORMAT_FOURCC_MASK       |
+	    GLITZ_FORMAT_RED_SIZE_MASK     |
+	    GLITZ_FORMAT_GREEN_SIZE_MASK   |
+	    GLITZ_FORMAT_BLUE_SIZE_MASK    |
+	    GLITZ_FORMAT_ALPHA_SIZE_MASK   |
+	    GLITZ_FORMAT_DEPTH_SIZE_MASK   |
+	    GLITZ_FORMAT_STENCIL_SIZE_MASK |
+	    GLITZ_FORMAT_DOUBLEBUFFER_MASK |
+	    GLITZ_FORMAT_SAMPLES_MASK;
+
+	pVisual->next	 = 0;
+	pVisual->vid	 = vid;
+	pVisual->pPixel	 = pPixel;
+	pVisual->pbuffer = FALSE;
+
+	pVisual->format.surface  = format;
+	pVisual->format.drawable =
+	    glitz_find_drawable_format (pScreenPriv->drawable,
+					mask, &templ, 0);
+
+	return TRUE;
+    }
+
+    return FALSE;
+}
+
+static Bool
+xglInitPbufferVisual (ScreenPtr	        pScreen,
+		      xglVisualPtr	pVisual,
+		      xglPixelFormatPtr pPixel,
+		      VisualID		vid)
+{
+    glitz_format_t *format;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    format = xglFindBestSurfaceFormat (pScreen, pPixel);
+    if (format)
+    {
+	glitz_drawable_format_t templ, *screenFormat;
+	unsigned long	        mask;
+
+	/* use same drawable format as screen for pbuffers */
+	screenFormat = glitz_drawable_get_format (pScreenPriv->drawable);
+	templ.id = screenFormat->id;
+
+	templ.color   = format->color;
+	templ.samples = 1;
+
+	mask =
+	    GLITZ_FORMAT_ID_MASK	 |
+	    GLITZ_FORMAT_FOURCC_MASK     |
+	    GLITZ_FORMAT_RED_SIZE_MASK   |
+	    GLITZ_FORMAT_GREEN_SIZE_MASK |
+	    GLITZ_FORMAT_BLUE_SIZE_MASK  |
+	    GLITZ_FORMAT_SAMPLES_MASK;
+
+	pVisual->next	 = 0;
+	pVisual->vid	 = vid;
+	pVisual->pPixel	 = pPixel;
+	pVisual->pbuffer = TRUE;
+
+	pVisual->format.surface  = format;
+	pVisual->format.drawable =
+	    glitz_find_pbuffer_format (pScreenPriv->drawable,
+				       mask, &templ, 0);
+
+	if (pVisual->format.drawable)
+	    return TRUE;
+    }
+
+    return FALSE;
+}
+
+void
+xglInitVisuals (ScreenPtr pScreen)
+{
+    xglVisualPtr pVisual, v, new, *prev;
+    int		 i;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    for (i = 0; i < pScreen->numVisuals; i++)
+    {
+	for (pVisual = xglVisuals; pVisual; pVisual = pVisual->next)
+	    if (pVisual->pPixel->depth == pScreen->visuals[i].nplanes)
+		break;
+
+	if (pVisual)
+	{
+	    new = xalloc (sizeof (xglVisualRec));
+	    if (new)
+	    {
+		if (xglInitVisual (pScreen, new, pVisual->pPixel,
+				   pScreen->visuals[i].vid))
+		{
+		    new->next = 0;
+
+		    prev = &pScreenPriv->pVisual;
+		    while ((v = *prev))
+			prev = &v->next;
+
+		    *prev = new;
+		}
+		else
+		{
+		    xfree (new);
+		}
+	    }
+
+	    new = xalloc (sizeof (xglVisualRec));
+	    if (new)
+	    {
+		if (xglInitPbufferVisual (pScreen, new, pVisual->pPixel,
+					  pScreen->visuals[i].vid))
+		{
+		    new->next = 0;
+
+		    prev = &pScreenPriv->pVisual;
+		    while ((v = *prev))
+			prev = &v->next;
+
+		    *prev = new;
+		}
+		else
+		{
+		    xfree (new);
+		}
+	    }
+	}
+    }
+
+    /* Add additional Xgl visuals for pixmap formats */
+    for (i = 0; i < screenInfo.numPixmapFormats; i++)
+    {
+	if (!xglHasVisualTypes (pScreenPriv->pVisual,
+				screenInfo.formats[i].depth))
+	{
+	    for (v = xglVisuals; v; v = v->next)
+		if (v->pPixel->depth == screenInfo.formats[i].depth)
+		    break;
+
+	    if (v)
+	    {
+		new = xalloc (sizeof (xglVisualRec));
+		if (new)
+		{
+		    if (xglInitVisual (pScreen, new, v->pPixel, 0))
+		    {
+			new->next = 0;
+
+			prev = &pScreenPriv->pVisual;
+			while ((v = *prev))
+			    prev = &v->next;
+
+			*prev = new;
+		    }
+		    else
+		    {
+			xfree (new);
+		    }
+		}
+	    }
+	}
+    }
+}
+
+xglVisualPtr
+xglFindVisualWithDepth (ScreenPtr pScreen,
+			int       depth)
+{
+    xglVisualPtr v;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    for (v = pScreenPriv->pVisual; v; v = v->next)
+    {
+	if (v->pPixel->depth == depth)
+	    return v;
+    }
+
+    return 0;
+}
+
+xglVisualPtr
+xglFindVisualWithId (ScreenPtr pScreen,
+		     int       vid)
+{
+    xglVisualPtr v;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    for (v = pScreenPriv->pVisual; v; v = v->next)
+    {
+	if (v->vid == vid)
+	    return v;
+    }
+
+    return 0;
+}
+
+void
+xglClearVisualTypes (void)
+{
+    xglVisualPtr v;
+
+    while (xglVisuals)
+    {
+	v = xglVisuals;
+	xglVisuals = v->next;
+	xfree (v);
+    }
+
+    miClearVisualTypes ();
+}
diff --git a/xgl/xglcompose.c b/xgl/xglcompose.c
new file mode 100644
index 0000000..f6725ac
--- /dev/null
+++ b/xgl/xglcompose.c
@@ -0,0 +1,288 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+
+#include "glxserver.h"
+#include "glapi.h"
+#include "glthread.h"
+#include "dispatch.h"
+#include "xgl.h"
+
+#ifdef RENDER
+
+static glitz_operator_t xglOperators[] = {
+    GLITZ_OPERATOR_CLEAR,
+    GLITZ_OPERATOR_SRC,
+    GLITZ_OPERATOR_DST,
+    GLITZ_OPERATOR_OVER,
+    GLITZ_OPERATOR_OVER_REVERSE,
+    GLITZ_OPERATOR_IN,
+    GLITZ_OPERATOR_IN_REVERSE,
+    GLITZ_OPERATOR_OUT,
+    GLITZ_OPERATOR_OUT_REVERSE,
+    GLITZ_OPERATOR_ATOP,
+    GLITZ_OPERATOR_ATOP_REVERSE,
+    GLITZ_OPERATOR_XOR,
+    GLITZ_OPERATOR_ADD
+};
+
+#define NUM_XGL_OPERATORS			       \
+    (sizeof (xglOperators) / sizeof (xglOperators[0]))
+
+#define XGL_OPERATOR(op) (xglOperators[op])
+
+#define XGL_GET_SOURCE_PICTURE(pPicture, outSurface)			   \
+    (outSurface) = ((pPicture)->pDrawable) ?				   \
+	XGL_GET_PIXMAP_PRIV ((PixmapPtr) (pPicture)->pDrawable)->surface : \
+	(glitz_surface_t *) (pPicture)->pSourcePict->source.devPrivate.ptr
+
+Bool
+xglCompositeGeneral (CARD8	     op,
+		     PicturePtr	     pSrc,
+		     PicturePtr	     pMask,
+		     PicturePtr	     pDst,
+		     xglGeometryPtr  pGeometry,
+		     INT16	     xSrc,
+		     INT16	     ySrc,
+		     INT16	     xMask,
+		     INT16	     yMask,
+		     INT16	     xDst,
+		     INT16	     yDst,
+		     CARD16	     width,
+		     CARD16	     height)
+{
+    ScreenPtr	    pScreen = pDst->pDrawable->pScreen;
+    INT16	    xOff, yOff;
+    glitz_surface_t *src, *mask = NULL, *dst;
+    int		    dstXoff, dstYoff;
+    RegionRec	    region;
+    BoxPtr	    pBox, pExt;
+    int		    nBox;
+
+    if (pDst->alphaMap)
+	return FALSE;
+
+    if (op >= NUM_XGL_OPERATORS)
+	return FALSE;
+
+    if (pSrc->pDrawable)
+    {
+	if (pSrc->pDrawable->type != DRAWABLE_PIXMAP)
+	    return FALSE;
+
+	if (pSrc->pDrawable->bitsPerPixel == 1)
+	    return FALSE;
+    }
+
+    if (pMask)
+    {
+       if (pMask->pDrawable)
+       {
+	   if (pMask->pDrawable->type != DRAWABLE_PIXMAP)
+	       return FALSE;
+
+	   if (pSrc->pDrawable == pMask->pDrawable && pSrc != pMask)
+	       return FALSE;
+       }
+    }
+
+    if (!xglPrepareTarget (pDst->pDrawable))
+	return FALSE;
+
+    if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
+				   xSrc, ySrc, xMask, yMask,
+				   xDst, yDst, width, height))
+	return TRUE;
+
+    pBox = REGION_RECTS (&region);
+    nBox = REGION_NUM_RECTS (&region);
+    pExt = REGION_EXTENTS (pScreen, &region);
+
+    XGL_GET_DRAWABLE (pDst->pDrawable, dst, dstXoff, dstYoff);
+
+    if (!xglSyncPicture (pScreen, pSrc,
+			 pExt->x1 + xSrc - xDst,
+			 pExt->y1 + ySrc - yDst,
+			 pExt->x2 - pExt->x1,
+			 pExt->y2 - pExt->y1,
+			 &xOff, &yOff))
+    {
+	REGION_UNINIT (pScreen, &region);
+	return FALSE;
+    }
+
+    xSrc -= xOff;
+    ySrc -= yOff;
+
+    XGL_GET_SOURCE_PICTURE (pSrc, src);
+
+    if (pMask)
+    {
+	/* bitmap as mask */
+	if (pMask->pDrawable && pMask->pDrawable->bitsPerPixel == 1)
+	{
+	    if (pGeometry)
+	    {
+		REGION_UNINIT (pScreen, &region);
+		return FALSE;
+	    }
+
+	    pGeometry = xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable,
+					     xDst - xMask,
+					     yDst - yMask);
+	    if (!pGeometry)
+	    {
+		REGION_UNINIT (pScreen, &region);
+		return FALSE;
+	    }
+	}
+	else
+	{
+	    if (!xglSyncPicture (pScreen, pMask,
+				 pExt->x1 + xMask - xDst,
+				 pExt->y1 + yMask - yDst,
+				 pExt->x2 - pExt->x1,
+				 pExt->y2 - pExt->y1,
+				 &xOff, &yOff))
+	    {
+		REGION_UNINIT (pScreen, &region);
+		return FALSE;
+	    }
+
+	    xMask -= xOff;
+	    yMask -= yOff;
+
+	    XGL_GET_SOURCE_PICTURE (pMask, mask);
+	}
+    }
+
+    if (!pGeometry)
+    {
+	if (pSrc->pDrawable && !pSrc->transform &&
+	    pSrc->filter != PictFilterConvolution)
+	{
+	    if (pSrc->repeatType == RepeatNormal)
+	    {
+		XGL_PIXMAP_PRIV ((PixmapPtr) pSrc->pDrawable);
+
+		/* tile */
+		if (!pPixmapPriv->acceleratedTile)
+		{
+		    pGeometry =
+			xglTiledBoxGeometry ((PixmapPtr) pSrc->pDrawable,
+					     xSrc - xDst, ySrc - yDst,
+					     pBox, nBox);
+		    if (!pGeometry)
+		    {
+			REGION_UNINIT (pScreen, &region);
+			return FALSE;
+		    }
+
+		    pBox = pExt;
+		    nBox = 1;
+		}
+	    }
+	    else
+	    {
+		/* copy */
+		if (op == PictOpSrc && !mask)
+		{
+		    if (xglCopy (pSrc->pDrawable,
+				 pDst->pDrawable,
+				 xSrc - xDst,
+				 ySrc - yDst,
+				 pBox,
+				 nBox))
+		    {
+			REGION_UNINIT (pScreen, &region);
+			return TRUE;
+		    }
+		}
+	    }
+	}
+
+	if (nBox > 1)
+	{
+	    pGeometry = xglGetScratchVertexGeometry (pScreen, 4 * nBox);
+
+	    GEOMETRY_ADD_BOX (pScreen, pGeometry, pBox, nBox);
+
+	    pBox = pExt;
+	}
+
+	xSrc += pBox->x1 - xDst;
+	ySrc += pBox->y1 - yDst;
+
+	if (pMask)
+	{
+	    xMask += pBox->x1 - xDst;
+	    yMask += pBox->y1 - yDst;
+	}
+
+	xDst = pBox->x1;
+	yDst = pBox->y1;
+
+	width  = pBox->x2 - pBox->x1;
+	height = pBox->y2 - pBox->y1;
+    }
+    else
+    {
+	glitz_surface_set_clip_region (dst,
+				       dstXoff, dstYoff,
+				       (glitz_box_t *) pBox, nBox);
+    }
+
+    if (pGeometry)
+    {
+	GEOMETRY_TRANSLATE (pGeometry, dstXoff, dstYoff);
+
+	if (!GEOMETRY_ENABLE (pGeometry, dst))
+	{
+	    REGION_UNINIT (pScreen, &region);
+	    return FALSE;
+	}
+    }
+    else
+	GEOMETRY_DISABLE (dst);
+
+    __glXleaveServer(FALSE);
+    glitz_composite (XGL_OPERATOR (op),
+		     src, mask, dst,
+		     xSrc, ySrc,
+		     xMask, yMask,
+		     xDst + dstXoff, yDst + dstYoff,
+		     width, height);
+    __glXenterServer(FALSE);
+
+    glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
+
+    REGION_UNINIT (pScreen, &region);
+
+    if (glitz_surface_get_status (dst))
+	return FALSE;
+
+    return TRUE;
+}
+
+#endif
diff --git a/xgl/xglcopy.c b/xgl/xglcopy.c
new file mode 100644
index 0000000..b0cf82f
--- /dev/null
+++ b/xgl/xglcopy.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+#include "glxserver.h"
+#include "glapi.h"
+#include "glthread.h"
+#include "dispatch.h"
+
+
+#include "xgl.h"
+#include "fb.h"
+
+Bool
+xglCopy (DrawablePtr pSrc,
+	 DrawablePtr pDst,
+	 int	     dx,
+	 int	     dy,
+	 BoxPtr	     pBox,
+	 int	     nBox)
+{
+    glitz_surface_t *src, *dst;
+    int		    srcXoff, srcYoff;
+    int		    dstXoff, dstYoff;
+
+    XGL_DRAWABLE_PIXMAP (pDst);
+
+    if (!nBox)
+	return TRUE;
+
+    if (xglPrepareTarget (pDst))
+    {
+	if (!xglSyncSurface (pSrc))
+	    return FALSE;
+    }
+    else
+    {
+	if (!xglPrepareTarget (pSrc))
+	    return FALSE;
+
+	if (!xglSyncSurface (pDst))
+	    return FALSE;
+    }
+
+    XGL_GET_DRAWABLE (pSrc, src, srcXoff, srcYoff);
+    XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff);
+
+    glitz_surface_set_clip_region (dst,
+				   dstXoff, dstYoff,
+				   (glitz_box_t *) pBox, nBox);
+
+    __glXleaveServer(FALSE);
+    glitz_copy_area (src,
+		     dst,
+		     srcXoff + dx,
+		     srcYoff + dy,
+		     pPixmap->drawable.width - dstXoff,
+		     pPixmap->drawable.height - dstYoff,
+		     dstXoff,
+		     dstYoff);
+    __glXenterServer(FALSE);
+
+    glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
+
+    if (glitz_surface_get_status (dst))
+	return FALSE;
+
+    return TRUE;
+}
+
+void
+xglCopyProc (DrawablePtr pSrc,
+	     DrawablePtr pDst,
+	     GCPtr	 pGC,
+	     BoxPtr	 pBox,
+	     int	 nBox,
+	     int	 dx,
+	     int	 dy,
+	     Bool	 reverse,
+	     Bool	 upsidedown,
+	     Pixel	 bitplane,
+	     void	 *closure)
+{
+    BoxPtr pSrcBox = (BoxPtr) closure;
+
+    if (!xglCopy (pSrc, pDst, dx, dy, pBox, nBox))
+    {
+	RegionRec region;
+
+	XGL_DRAWABLE_PIXMAP (pDst);
+	XGL_PIXMAP_PRIV (pPixmap);
+
+	if (!xglSyncBits (pSrc, pSrcBox))
+	    FatalError (XGL_SW_FAILURE_STRING);
+
+	if (!xglMapPixmapBits (pPixmap))
+	    FatalError (XGL_SW_FAILURE_STRING);
+
+	fbCopyNtoN (pSrc, pDst, pGC,
+		    pBox, nBox,
+		    dx, dy,
+		    reverse, upsidedown, bitplane,
+		    (void *) 0);
+
+	pPixmapPriv->damageBox = miEmptyBox;
+
+	while (nBox--)
+	{
+	    REGION_INIT (pDst->pScreen, &region, pBox, 1);
+	    xglAddSurfaceDamage (pDst, &region);
+	    REGION_UNINIT (pDst->pScreen, &region);
+
+	    pBox++;
+	}
+    } else
+	xglAddCurrentBitDamage (pDst);
+}
diff --git a/xgl/xglfill.c b/xgl/xglfill.c
new file mode 100644
index 0000000..a2957b2
--- /dev/null
+++ b/xgl/xglfill.c
@@ -0,0 +1,774 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+#include "gcstruct.h"
+#include "fb.h"
+
+Bool
+xglFill (DrawablePtr	pDrawable,
+	 GCPtr		pGC,
+	 xglGeometryPtr pGeometry,
+	 int		x,
+	 int		y,
+	 int		width,
+	 int		height,
+	 BoxPtr		pBox,
+	 int		nBox)
+{
+    XGL_GC_PRIV (pGC);
+
+    switch (pGC->fillStyle) {
+    case FillSolid:
+	if (xglSolid (pDrawable,
+		      pGCPriv->op, pGCPriv->fg,
+		      pGeometry,
+		      x, y,
+		      width, height,
+		      pBox, nBox))
+	    return TRUE;
+	break;
+    case FillStippled:
+    case FillOpaqueStippled:
+	break;
+    case FillTiled:
+	if (xglTile (pDrawable,
+		     pGCPriv->op, pGC->tile.pixmap,
+		     -(pGC->patOrg.x + pDrawable->x),
+		     -(pGC->patOrg.y + pDrawable->y),
+		     pGeometry,
+		     x, y,
+		     width, height,
+		     pBox, nBox))
+	    return TRUE;
+	break;
+    }
+
+    return FALSE;
+}
+
+static void
+xglFillBox (DrawablePtr pDrawable,
+	    GCPtr	pGC,
+	    int		x,
+	    int		y,
+	    int		width,
+	    int		height,
+	    BoxPtr	pBox,
+	    int		nBox)
+{
+    if (!nBox)
+	return;
+
+    if (!xglFill (pDrawable, pGC, NULL, x, y, width, height, pBox, nBox))
+    {
+	RegionRec region;
+
+	XGL_DRAWABLE_PIXMAP (pDrawable);
+	XGL_PIXMAP_PRIV (pPixmap);
+
+	if (!xglMapPixmapBits (pPixmap))
+	    FatalError (XGL_SW_FAILURE_STRING);
+
+	switch (pGC->fillStyle) {
+	case FillSolid:
+	    break;
+	case FillStippled:
+	case FillOpaqueStippled:
+	    if (!xglSyncBits (&pGC->stipple->drawable, NullBox))
+		FatalError (XGL_SW_FAILURE_STRING);
+	    break;
+	case FillTiled:
+	    if (!xglSyncBits (&pGC->tile.pixmap->drawable, NullBox))
+		FatalError (XGL_SW_FAILURE_STRING);
+	    break;
+	}
+
+	pPixmapPriv->damageBox = miEmptyBox;
+
+	while (nBox--)
+	{
+	    fbFill (pDrawable, pGC,
+		    pBox->x1, pBox->y1,
+		    pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
+
+	    REGION_INIT (pDrawable->pScreen, &region, pBox, 1);
+	    xglAddSurfaceDamage (pDrawable, &region);
+	    REGION_UNINIT (pDrawable->pScreen, &region);
+
+	    pBox++;
+	}
+    } else
+	xglAddCurrentBitDamage (pDrawable);
+}
+
+#define N_STACK_BOX 1024
+
+static BoxPtr
+xglMoreBoxes (BoxPtr stackBox,
+	      BoxPtr heapBox,
+	      int    nBoxes)
+{
+    Bool stack = !heapBox;
+
+    heapBox = xrealloc (heapBox, sizeof (BoxRec) * nBoxes);
+    if (!heapBox)
+	return NULL;
+
+    if (stack)
+	memcpy (heapBox, stackBox, sizeof (BoxRec) * N_STACK_BOX);
+
+    return heapBox;
+}
+
+#define ADD_BOX(pBox, nBox, stackBox, heapBox, size, box)	\
+    {								\
+	if ((nBox) == (size))					\
+	{							\
+	    (size) *= 2;					\
+	    (heapBox) = xglMoreBoxes (stackBox, heapBox, size);	\
+	    if (heapBox)					\
+	    {							\
+		(pBox) = (heapBox) + (nBox);			\
+		*(pBox)++ = (box);				\
+		(nBox)++;					\
+	    }							\
+	}							\
+	else							\
+	{							\
+	    *(pBox)++ = (box);					\
+	    (nBox)++;						\
+	}							\
+    }
+
+void
+xglFillRect (DrawablePtr pDrawable,
+	     GCPtr	 pGC,
+	     int	 nrect,
+	     xRectangle  *prect)
+{
+    RegionPtr pClip = pGC->pCompositeClip;
+    BoxPtr    pClipBox;
+    BoxPtr    pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
+    int	      fullX1, fullX2, fullY1, fullY2;
+    BoxRec    part, full;
+    BoxPtr    heapBox = NULL;
+    BoxRec    stackBox[N_STACK_BOX];
+    int       size = N_STACK_BOX;
+    BoxPtr    pBox = stackBox;
+    int	      nClip, nBox = 0;
+
+    while (nrect--)
+    {
+	fullX1 = prect->x + pDrawable->x;
+	fullY1 = prect->y + pDrawable->y;
+	fullX2 = fullX1 + (int) prect->width;
+	fullY2 = fullY1 + (int) prect->height;
+
+	prect++;
+
+	if (fullX1 < pExtent->x1)
+	    fullX1 = pExtent->x1;
+	if (fullY1 < pExtent->y1)
+	    fullY1 = pExtent->y1;
+	if (fullX2 > pExtent->x2)
+	    fullX2 = pExtent->x2;
+	if (fullY2 > pExtent->y2)
+	    fullY2 = pExtent->y2;
+
+	full.x1 = fullX1;
+	full.y1 = fullY1;
+	full.x2 = fullX2;
+	full.y2 = fullY2;
+
+	if (full.x1 >= full.x2 || full.y1 >= full.y2)
+	    continue;
+
+	nClip = REGION_NUM_RECTS (pClip);
+	if (nClip == 1)
+	{
+	    ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
+	}
+	else
+	{
+	    pClipBox = REGION_RECTS (pClip);
+	    while (nClip--)
+	    {
+		part = *pClipBox++;
+
+		if (part.x1 < full.x1)
+		    part.x1 = full.x1;
+		if (part.y1 < full.y1)
+		    part.y1 = full.y1;
+		if (part.x2 > full.x2)
+		    part.x2 = full.x2;
+		if (part.y2 > full.y2)
+		    part.y2 = full.y2;
+
+		if (part.x1 < part.x2 && part.y1 < part.y2)
+		    ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
+	    }
+	}
+    }
+
+    xglFillBox (pDrawable, pGC,
+		pExtent->x1, pExtent->y1,
+		pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
+		(heapBox) ? heapBox : stackBox, nBox);
+
+    if (heapBox)
+	xfree (heapBox);
+}
+
+void
+xglFillSpan (DrawablePtr pDrawable,
+	     GCPtr	 pGC,
+	     int	 n,
+	     DDXPointPtr ppt,
+	     int	 *pwidth)
+{
+    RegionPtr pClip = pGC->pCompositeClip;
+    BoxPtr    pClipBox;
+    BoxPtr    pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
+    int	      fullX1, fullX2, fullY1, fullY2;
+    BoxRec    part, full;
+    BoxPtr    heapBox = NULL;
+    BoxRec    stackBox[N_STACK_BOX];
+    int       size = N_STACK_BOX;
+    BoxPtr    pBox = stackBox;
+    int	      nClip, nBox = 0;
+
+    while (n--)
+    {
+	fullX1 = ppt->x;
+	fullY1 = ppt->y;
+	fullX2 = fullX1 + *pwidth;
+	fullY2 = fullY1 + 1;
+
+	pwidth++;
+	ppt++;
+
+	if (fullX1 < pExtent->x1)
+	    fullX1 = pExtent->x1;
+	if (fullY1 < pExtent->y1)
+	    fullY1 = pExtent->y1;
+	if (fullX2 > pExtent->x2)
+	    fullX2 = pExtent->x2;
+	if (fullY2 > pExtent->y2)
+	    fullY2 = pExtent->y2;
+
+	full.x1 = fullX1;
+	full.y1 = fullY1;
+	full.x2 = fullX2;
+	full.y2 = fullY2;
+
+	if (full.x1 >= full.x2 || full.y1 >= full.y2)
+	    continue;
+
+	nClip = REGION_NUM_RECTS (pClip);
+	if (nClip == 1)
+	{
+	    ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
+	}
+	else
+	{
+	    pClipBox = REGION_RECTS (pClip);
+	    while (nClip--)
+	    {
+		part = *pClipBox++;
+
+		if (part.x1 < full.x1)
+		    part.x1 = full.x1;
+		if (part.y1 < full.y1)
+		    part.y1 = full.y1;
+		if (part.x2 > full.x2)
+		    part.x2 = full.x2;
+		if (part.y2 > full.y2)
+		    part.y2 = full.y2;
+
+		if (part.x1 < part.x2 && part.y1 < part.y2)
+		    ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
+	    }
+	}
+    }
+
+    xglFillBox (pDrawable, pGC,
+		pExtent->x1, pExtent->y1,
+		pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
+		(heapBox) ? heapBox : stackBox, nBox);
+
+    if (heapBox)
+	xfree (heapBox);
+}
+
+Bool
+xglFillLine (DrawablePtr pDrawable,
+	     GCPtr       pGC,
+	     int	 mode,
+	     int	 npt,
+	     DDXPointPtr ppt)
+{
+    RegionPtr	   pClip = pGC->pCompositeClip;
+    BoxPtr	   pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
+    Bool	   coincidentEndpoints = FALSE;
+    Bool	   horizontalAndVertical = TRUE;
+    DDXPointPtr    pptTmp;
+    int		   nptTmp;
+    DDXPointRec    pt;
+    xglGeometryPtr pGeometry;
+
+    XGL_SCREEN_PRIV (pGC->pScreen);
+
+    if (npt < 2)
+	return TRUE;
+
+    pt = *ppt;
+
+    nptTmp = npt - 1;
+    pptTmp = ppt + 1;
+
+    if (mode == CoordModePrevious)
+    {
+	while (nptTmp--)
+	{
+	    if (pptTmp->x && pptTmp->y)
+		horizontalAndVertical = FALSE;
+
+	    pt.x += pptTmp->x;
+	    pt.y += pptTmp->y;
+
+	    pptTmp++;
+	}
+
+	if (pt.x == ppt->x && pt.y == ppt->y)
+	    coincidentEndpoints = TRUE;
+    }
+    else
+    {
+	while (nptTmp--)
+	{
+	    if (pptTmp->x != pt.x && pptTmp->y != pt.y)
+	    {
+		horizontalAndVertical = FALSE;
+		break;
+	    }
+
+	    pt = *pptTmp++;
+	}
+
+	if (ppt[npt - 1].x == ppt->x && ppt[npt - 1].y == ppt->y)
+	    coincidentEndpoints = TRUE;
+    }
+
+    if (horizontalAndVertical)
+    {
+	BoxPtr pClipBox;
+	int    fullX1, fullX2, fullY1, fullY2;
+	BoxRec part, full;
+	BoxPtr heapBox = NULL;
+	BoxRec stackBox[N_STACK_BOX];
+	int    size = N_STACK_BOX;
+	BoxPtr pBox = stackBox;
+	int    nClip, nBox = 0;
+	int    dx, dy;
+
+	pt = *ppt;
+
+	ppt++;
+	npt--;
+
+	while (npt--)
+	{
+	    if (mode == CoordModePrevious)
+	    {
+		dx = ppt->x;
+		dy = ppt->y;
+	    }
+	    else
+	    {
+		dx = ppt->x - pt.x;
+		dy = ppt->y - pt.y;
+	    }
+
+	    if (dx)
+	    {
+		if (dx > 0)
+		{
+		    fullX1 = pt.x + pDrawable->x;
+
+		    if (npt || coincidentEndpoints)
+			fullX2 = fullX1 + dx;
+		    else
+			fullX2 = fullX1 + dx + 1;
+		}
+		else
+		{
+		    fullX2 = pt.x + pDrawable->x + 1;
+
+		    if (npt || coincidentEndpoints)
+			fullX1 = fullX2 + dx;
+		    else
+			fullX1 = fullX2 + dx - 1;
+		}
+
+		fullY1 = pt.y + pDrawable->y;
+		fullY2 = fullY1 + 1;
+	    }
+	    else
+	    {
+		if (dy > 0)
+		{
+		    fullY1 = pt.y + pDrawable->y;
+
+		    if (npt || coincidentEndpoints)
+			fullY2 = fullY1 + dy;
+		    else
+			fullY2 = fullY1 + dy + 1;
+		}
+		else
+		{
+		    fullY2 = pt.y + pDrawable->y + 1;
+
+		    if (npt || coincidentEndpoints)
+			fullY1 = fullY2 + dy;
+		    else
+			fullY1 = fullY2 + dy - 1;
+		}
+
+		fullX1 = pt.x + pDrawable->x;
+		fullX2 = fullX1 + 1;
+	    }
+
+	    pt.x += dx;
+	    pt.y += dy;
+
+	    ppt++;
+
+	    if (fullX1 < pExtent->x1)
+		fullX1 = pExtent->x1;
+	    if (fullY1 < pExtent->y1)
+		fullY1 = pExtent->y1;
+	    if (fullX2 > pExtent->x2)
+		fullX2 = pExtent->x2;
+	    if (fullY2 > pExtent->y2)
+		fullY2 = pExtent->y2;
+
+	    full.x1 = fullX1;
+	    full.y1 = fullY1;
+	    full.x2 = fullX2;
+	    full.y2 = fullY2;
+
+	    if (full.x1 >= full.x2 || full.y1 >= full.y2)
+		continue;
+
+	    nClip = REGION_NUM_RECTS (pClip);
+	    if (nClip == 1)
+	    {
+		ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
+	    }
+	    else
+	    {
+		pClipBox = REGION_RECTS (pClip);
+		while (nClip--)
+		{
+		    part = *pClipBox++;
+
+		    if (part.x1 < full.x1)
+			part.x1 = full.x1;
+		    if (part.y1 < full.y1)
+			part.y1 = full.y1;
+		    if (part.x2 > full.x2)
+			part.x2 = full.x2;
+		    if (part.y2 > full.y2)
+			part.y2 = full.y2;
+
+		    if (part.x1 < part.x2 && part.y1 < part.y2)
+			ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
+		}
+	    }
+	}
+
+	xglFillBox (pDrawable, pGC,
+		    pExtent->x1, pExtent->y1,
+		    pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
+		    (heapBox) ? heapBox : stackBox, nBox);
+
+	if (heapBox)
+	    xfree (heapBox);
+
+	return TRUE;
+    }
+
+    if (!pScreenPriv->lines)
+	return FALSE;
+
+    if (coincidentEndpoints)
+	npt--;
+
+    pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, npt);
+
+    GEOMETRY_ADD_LINE (pGC->pScreen, pGeometry,
+		       coincidentEndpoints, mode, npt, ppt);
+
+    if (coincidentEndpoints)
+	GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINE_LOOP);
+    else
+	GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINE_STRIP);
+
+    /* Lines need a 0.5 translate */
+    GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15);
+
+    GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y);
+
+    pExtent = REGION_EXTENTS (pDrawable->pScreen, pGC->pCompositeClip);
+
+    if (xglFill (pDrawable, pGC, pGeometry,
+		 pExtent->x1, pExtent->y1,
+		 pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
+		 REGION_RECTS (pGC->pCompositeClip),
+		 REGION_NUM_RECTS (pGC->pCompositeClip)))
+    {
+	xglAddCurrentBitDamage (pDrawable);
+	return TRUE;
+    }
+
+    return FALSE;
+}
+
+Bool
+xglFillSegment (DrawablePtr pDrawable,
+		GCPtr	    pGC,
+		int	    nSegInit,
+		xSegment    *pSegInit)
+{
+    RegionPtr	   pClip = pGC->pCompositeClip;
+    BoxPtr	   pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
+    Bool	   horizontalAndVertical = TRUE;
+    xglGeometryPtr pGeometry;
+    xSegment	   *pSeg;
+    int		   nSeg;
+
+    XGL_SCREEN_PRIV (pGC->pScreen);
+
+    if (nSegInit < 1)
+	return TRUE;
+
+    pSeg = pSegInit;
+    nSeg = nSegInit;
+    while (nSeg--)
+    {
+	if (pSeg->x1 != pSeg->x2 && pSeg->y1 != pSeg->y2)
+	    horizontalAndVertical = FALSE;
+
+	pSeg++;
+    }
+
+    if (horizontalAndVertical)
+    {
+	BoxPtr pClipBox;
+	int    fullX1, fullX2, fullY1, fullY2;
+	BoxRec part, full;
+	BoxPtr heapBox = NULL;
+	BoxRec stackBox[N_STACK_BOX];
+	int    size = N_STACK_BOX;
+	BoxPtr pBox = stackBox;
+	int    nClip, nBox = 0;
+
+	while (nSegInit--)
+	{
+	    if (pSegInit->x1 != pSegInit->x2)
+	    {
+		if (pSegInit->x1 < pSegInit->x2)
+		{
+		    fullX1 = pSegInit->x1;
+		    fullX2 = pSegInit->x2;
+		    if (pGC->capStyle != CapNotLast)
+			fullX2++;
+		}
+		else
+		{
+		    fullX1 = pSegInit->x2;
+		    fullX2 = pSegInit->x1 + 1;
+		    if (pGC->capStyle == CapNotLast)
+			fullX1++;
+		}
+
+		fullX1 += pDrawable->x;
+		fullX2 += pDrawable->x;
+		fullY1  = pSegInit->y1 + pDrawable->y;
+		fullY2  = fullY1 + 1;
+	    }
+	    else
+	    {
+		if (pSegInit->y1 < pSegInit->y2)
+		{
+		    fullY1 = pSegInit->y1;
+		    fullY2 = pSegInit->y2;
+		    if (pGC->capStyle != CapNotLast)
+			fullY2++;
+		}
+		else
+		{
+		    fullY1 = pSegInit->y2;
+		    fullY2 = pSegInit->y1 + 1;
+		    if (pGC->capStyle == CapNotLast)
+			fullY1++;
+		}
+
+		fullY1 += pDrawable->y;
+		fullY2 += pDrawable->y;
+		fullX1  = pSegInit->x1 + pDrawable->x;
+		fullX2  = fullX1 + 1;
+	    }
+
+	    pSegInit++;
+
+	    if (fullX1 < pExtent->x1)
+		fullX1 = pExtent->x1;
+	    if (fullY1 < pExtent->y1)
+		fullY1 = pExtent->y1;
+	    if (fullX2 > pExtent->x2)
+		fullX2 = pExtent->x2;
+	    if (fullY2 > pExtent->y2)
+		fullY2 = pExtent->y2;
+
+	    full.x1 = fullX1;
+	    full.y1 = fullY1;
+	    full.x2 = fullX2;
+	    full.y2 = fullY2;
+
+	    if (full.x1 >= full.x2 || full.y1 >= full.y2)
+		continue;
+
+	    nClip = REGION_NUM_RECTS (pClip);
+	    if (nClip == 1)
+	    {
+		ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
+	    }
+	    else
+	    {
+		pClipBox = REGION_RECTS (pClip);
+		while (nClip--)
+		{
+		    part = *pClipBox++;
+
+		    if (part.x1 < full.x1)
+			part.x1 = full.x1;
+		    if (part.y1 < full.y1)
+			part.y1 = full.y1;
+		    if (part.x2 > full.x2)
+			part.x2 = full.x2;
+		    if (part.y2 > full.y2)
+			part.y2 = full.y2;
+
+		    if (part.x1 < part.x2 && part.y1 < part.y2)
+			ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
+		}
+	    }
+	}
+
+	xglFillBox (pDrawable, pGC,
+		    pExtent->x1, pExtent->y1,
+		    pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
+		    (heapBox) ? heapBox : stackBox, nBox);
+
+	if (heapBox)
+	    xfree (heapBox);
+
+	return TRUE;
+    }
+
+    if (!pScreenPriv->lines)
+	return FALSE;
+
+    pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, 2 * nSegInit);
+
+    GEOMETRY_ADD_SEGMENT (pGC->pScreen, pGeometry, nSegInit, pSegInit);
+
+    /* Line segments need 0.5 translate */
+    GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15);
+    GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINES);
+
+    GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y);
+
+    if (xglFill (pDrawable, pGC, pGeometry,
+		 pExtent->x1, pExtent->y1,
+		 pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
+		 REGION_RECTS (pGC->pCompositeClip),
+		 REGION_NUM_RECTS (pGC->pCompositeClip)))
+    {
+	xglAddCurrentBitDamage (pDrawable);
+	return TRUE;
+    }
+
+    return FALSE;
+}
+
+Bool
+xglFillGlyph (DrawablePtr  pDrawable,
+	      GCPtr	   pGC,
+	      int	   x,
+	      int	   y,
+	      unsigned int nGlyph,
+	      CharInfoPtr  *ppci,
+	      pointer      pglyphBase)
+{
+    BoxPtr	   pExtent;
+    xglGeometryRec geometry;
+
+    if (nGlyph < 1)
+	return TRUE;
+
+    pExtent = REGION_EXTENTS (pDrawable->pScreen, pGC->pCompositeClip);
+
+    x += pDrawable->x;
+    y += pDrawable->y;
+
+    GEOMETRY_INIT (pDrawable->pScreen, &geometry,
+		   GLITZ_GEOMETRY_TYPE_BITMAP,
+		   GEOMETRY_USAGE_SYSMEM, 0);
+
+    GEOMETRY_FOR_GLYPH (pDrawable->pScreen,
+			&geometry,
+			nGlyph,
+			ppci,
+			pglyphBase);
+
+    GEOMETRY_TRANSLATE (&geometry, x, y);
+
+    if (xglFill (pDrawable, pGC, &geometry,
+		 pExtent->x1, pExtent->y1,
+		 pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
+		 REGION_RECTS (pGC->pCompositeClip),
+		 REGION_NUM_RECTS (pGC->pCompositeClip)))
+    {
+	GEOMETRY_UNINIT (&geometry);
+	xglAddCurrentBitDamage (pDrawable);
+	return TRUE;
+    }
+
+    GEOMETRY_UNINIT (&geometry);
+    return FALSE;
+}
diff --git a/xgl/xglgc.c b/xgl/xglgc.c
new file mode 100644
index 0000000..deb3982
--- /dev/null
+++ b/xgl/xglgc.c
@@ -0,0 +1,648 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+#include "fb.h"
+#include "gcstruct.h"
+#include "migc.h"
+
+#define XGL_GC_OP_FALLBACK_PROLOGUE(pDrawable) \
+    xglSyncDamageBoxBits (pDrawable);	       \
+    XGL_GC_UNWRAP (funcs);		       \
+    XGL_GC_UNWRAP (ops)
+
+#define XGL_GC_OP_FALLBACK_EPILOGUE(pDrawable)	  \
+    XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs); \
+    XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);	  \
+    xglAddCurrentSurfaceDamage (pDrawable)
+
+#define XGL_GC_FILL_OP_FALLBACK_PROLOGUE(pDrawable)		 \
+    switch (pGC->fillStyle) {					 \
+    case FillSolid:						 \
+	break;							 \
+    case FillStippled:						 \
+    case FillOpaqueStippled:					 \
+	if (!xglSyncBits (&pGC->stipple->drawable, NullBox))	 \
+	    FatalError (XGL_SW_FAILURE_STRING);			 \
+	break;							 \
+    case FillTiled:						 \
+	if (!xglSyncBits (&pGC->tile.pixmap->drawable, NullBox)) \
+	    FatalError (XGL_SW_FAILURE_STRING);			 \
+	break;							 \
+    }								 \
+    XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable)
+
+static const GCFuncs xglGCFuncs = {
+    xglValidateGC,
+    miChangeGC,
+    miCopyGC,
+    xglDestroyGC,
+    miChangeClip,
+    miDestroyClip,
+    miCopyClip
+};
+
+static const GCOps xglGCOps = {
+    xglFillSpans,
+    xglSetSpans,
+    xglPutImage,
+    xglCopyArea,
+    xglCopyPlane,
+    xglPolyPoint,
+    xglPolylines,
+    xglPolySegment,
+    miPolyRectangle,
+    xglPolyArc,
+    miFillPolygon,
+    xglPolyFillRect,
+    xglPolyFillArc,
+    miPolyText8,
+    miPolyText16,
+    miImageText8,
+    miImageText16,
+    xglImageGlyphBlt,
+    xglPolyGlyphBlt,
+    xglPushPixels
+#ifdef NEED_LINEHELPER
+    , NULL
+#endif
+};
+
+void
+xglFillSpans (DrawablePtr pDrawable,
+	      GCPtr	  pGC,
+	      int	  nspans,
+	      DDXPointPtr ppt,
+	      int	  *pwidth,
+	      int	  fSorted)
+{
+    XGL_GC_PRIV (pGC);
+
+    if (pGCPriv->flags || pGC->fillStyle == FillStippled)
+    {
+	XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
+	(*pGC->ops->FillSpans) (pDrawable, pGC, nspans, ppt, pwidth, fSorted);
+	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+    }
+    else
+    {
+	/* xglFillSpan handles fall-back */
+	xglFillSpan (pDrawable, pGC, nspans, ppt, pwidth);
+    }
+}
+
+void
+xglSetSpans (DrawablePtr pDrawable,
+	     GCPtr	 pGC,
+	     char	 *psrc,
+	     DDXPointPtr ppt,
+	     int	 *pwidth,
+	     int	 nspans,
+	     int	 fSorted)
+{
+    XGL_GC_PRIV (pGC);
+
+    XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
+    (*pGC->ops->SetSpans) (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
+    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+}
+
+void
+xglPutImage (DrawablePtr pDrawable,
+	     GCPtr	 pGC,
+	     int	 depth,
+	     int	 x,
+	     int	 y,
+	     int	 w,
+	     int	 h,
+	     int	 leftPad,
+	     int	 format,
+	     char	 *bits)
+{
+    XGL_GC_PRIV (pGC);
+
+    if (pGC->alu != GXcopy || (pGCPriv->flags & xglGCPlaneMaskFlag))
+    {
+	XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
+	(*pGC->ops->PutImage) (pDrawable, pGC, depth,
+			       x, y, w, h, leftPad, format, bits);
+	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+    }
+    else
+    {
+	RegionPtr pClip = pGC->pCompositeClip;
+	RegionRec region;
+	BoxRec	  box;
+
+	XGL_DRAWABLE_PIXMAP (pDrawable);
+
+	if (!xglMapPixmapBits (pPixmap))
+	    FatalError (XGL_SW_FAILURE_STRING);
+
+	XGL_GC_UNWRAP (funcs);
+	XGL_GC_UNWRAP (ops);
+
+	(*pGC->ops->PutImage) (pDrawable, pGC, depth,
+			       x, y, w, h, leftPad, format, bits);
+
+	XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
+	XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
+
+	box.x1 = pDrawable->x + x;
+	box.y1 = pDrawable->y + y;
+	box.x2 = box.x1 + w;
+	box.y2 = box.y1 + h;
+
+	REGION_INIT (pDrawable->pScreen, &region, &box, 1);
+	REGION_INTERSECT (pDrawable->pScreen, &region, pClip, &region);
+
+	xglAddSurfaceDamage (pDrawable, &region);
+
+	REGION_UNINIT (pDrawable->pScreen, &region);
+    }
+}
+
+RegionPtr
+xglCopyArea (DrawablePtr pSrc,
+	     DrawablePtr pDst,
+	     GCPtr	 pGC,
+	     int	 srcX,
+	     int	 srcY,
+	     int	 w,
+	     int	 h,
+	     int	 dstX,
+	     int	 dstY)
+{
+    RegionPtr pRegion;
+    BoxRec    box;
+
+    XGL_GC_PRIV (pGC);
+
+    box.x1 = pSrc->x + srcX;
+    box.y1 = pSrc->y + srcY;
+    box.x2 = box.x1 + w;
+    box.y2 = box.y1 + h;
+
+    if (pGC->alu != GXcopy || pGCPriv->flags)
+    {
+	if (!xglSyncBits (pSrc, &box))
+	    FatalError (XGL_SW_FAILURE_STRING);
+
+	XGL_GC_OP_FALLBACK_PROLOGUE (pDst);
+	pRegion = (*pGC->ops->CopyArea) (pSrc, pDst, pGC,
+					 srcX, srcY, w, h, dstX, dstY);
+	XGL_GC_OP_FALLBACK_EPILOGUE (pDst);
+    }
+    else
+    {
+	/* xglCopyProc handles fall-back */
+	pRegion = fbDoCopy (pSrc, pDst, pGC,
+			    srcX, srcY,
+			    w, h,
+			    dstX, dstY,
+			    xglCopyProc, 0,
+			    (void *) &box);
+    }
+
+    return pRegion;
+}
+
+RegionPtr
+xglCopyPlane (DrawablePtr   pSrc,
+	      DrawablePtr   pDst,
+	      GCPtr	    pGC,
+	      int	    srcX,
+	      int	    srcY,
+	      int	    w,
+	      int	    h,
+	      int	    dstX,
+	      int	    dstY,
+	      unsigned long bitPlane)
+{
+    RegionPtr pRegion;
+    BoxRec    box;
+
+    XGL_GC_PRIV (pGC);
+
+    box.x1 = pSrc->x + srcX;
+    box.y1 = pSrc->y + srcY;
+    box.x2 = box.x1 + w;
+    box.y2 = box.y1 + h;
+
+    if (!xglSyncBits (pSrc, &box))
+	FatalError (XGL_SW_FAILURE_STRING);
+
+    XGL_GC_OP_FALLBACK_PROLOGUE (pDst);
+    pRegion = (*pGC->ops->CopyPlane) (pSrc, pDst, pGC,
+				      srcX, srcY, w, h, dstX, dstY,
+				      bitPlane);
+    XGL_GC_OP_FALLBACK_EPILOGUE (pDst);
+
+    return pRegion;
+}
+
+void
+xglPolyPoint (DrawablePtr pDrawable,
+	      GCPtr       pGC,
+	      int	  mode,
+	      int	  npt,
+	      DDXPointPtr pptInit)
+{
+    XGL_GC_PRIV (pGC);
+
+    XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
+    (*pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pptInit);
+    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+}
+
+void
+xglPolylines (DrawablePtr pDrawable,
+	      GCPtr       pGC,
+	      int	  mode,
+	      int	  npt,
+	      DDXPointPtr ppt)
+{
+    if (pGC->lineWidth == 0)
+    {
+	XGL_GC_PRIV (pGC);
+
+	if (!pGCPriv->flags)
+	{
+	    if (pGC->lineStyle == LineSolid)
+	    {
+		if (xglFillLine (pDrawable, pGC, mode, npt, ppt))
+		    return;
+	    }
+	}
+
+	XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
+	(*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, ppt);
+	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+    }
+    else
+    {
+	if (pGC->lineStyle != LineSolid)
+	    miWideDash (pDrawable, pGC, mode, npt, ppt);
+	else
+	    miWideLine (pDrawable, pGC, mode, npt, ppt);
+    }
+}
+
+void
+xglPolySegment (DrawablePtr pDrawable,
+		GCPtr	    pGC,
+		int	    nsegInit,
+		xSegment    *pSegInit)
+{
+    if (pGC->lineWidth == 0)
+    {
+	XGL_GC_PRIV (pGC);
+
+	if (!pGCPriv->flags)
+	{
+	    if (pGC->lineStyle == LineSolid)
+	    {
+		if (xglFillSegment (pDrawable, pGC, nsegInit, pSegInit))
+		    return;
+	    }
+	}
+
+	XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
+	(*pGC->ops->PolySegment) (pDrawable, pGC, nsegInit, pSegInit);
+	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+    } else
+	miPolySegment (pDrawable, pGC, nsegInit, pSegInit);
+}
+
+void
+xglPolyArc (DrawablePtr pDrawable,
+	    GCPtr	pGC,
+	    int		narcs,
+	    xArc	*pArcs)
+{
+    if (pGC->lineWidth == 0)
+    {
+	XGL_GC_PRIV (pGC);
+
+	XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
+	(*pGC->ops->PolyArc) (pDrawable, pGC, narcs, pArcs);
+	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+    } else
+	miPolyArc (pDrawable, pGC, narcs, pArcs);
+}
+
+void
+xglPolyFillRect (DrawablePtr pDrawable,
+		 GCPtr	     pGC,
+		 int	     nrect,
+		 xRectangle  *prect)
+{
+    XGL_GC_PRIV (pGC);
+
+    if (pGC->fillStyle == FillStippled || pGCPriv->flags)
+    {
+	XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
+	(*pGC->ops->PolyFillRect) (pDrawable, pGC, nrect, prect);
+	XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+    }
+    else
+    {
+	/* xglFillRect handles fall-back */
+	xglFillRect (pDrawable, pGC, nrect, prect);
+    }
+}
+
+void
+xglPolyFillArc (DrawablePtr pDrawable,
+		GCPtr	    pGC,
+		int	    narcs,
+		xArc	    *pArcs)
+{
+    XGL_GC_PRIV (pGC);
+
+    XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
+    (*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, pArcs);
+    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+}
+
+void
+xglImageGlyphBlt (DrawablePtr  pDrawable,
+		  GCPtr	       pGC,
+		  int	       x,
+		  int	       y,
+		  unsigned int nglyph,
+		  CharInfoPtr  *ppci,
+		  pointer      pglyphBase)
+{
+    XGL_GC_PRIV (pGC);
+
+    if (!pGCPriv->flags)
+    {
+	if (xglSolidGlyph (pDrawable,
+			   pGC,
+			   x,
+			   y,
+			   nglyph,
+			   ppci,
+			   pglyphBase))
+	    return;
+    }
+
+    XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
+    (*pGC->ops->ImageGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci,
+				pglyphBase);
+    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+}
+
+void
+xglPolyGlyphBlt (DrawablePtr  pDrawable,
+		 GCPtr	      pGC,
+		 int	      x,
+		 int	      y,
+		 unsigned int nglyph,
+		 CharInfoPtr  *ppci,
+		 pointer      pglyphBase)
+{
+    XGL_GC_PRIV (pGC);
+
+    if (!pGCPriv->flags)
+    {
+	if (xglFillGlyph (pDrawable,
+			  pGC,
+			  x,
+			  y,
+			  nglyph,
+			  ppci,
+			  pglyphBase))
+	    return;
+    }
+
+    XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
+    (*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+}
+
+void
+xglPushPixels (GCPtr	   pGC,
+	       PixmapPtr   pBitmap,
+	       DrawablePtr pDrawable,
+	       int	   w,
+	       int	   h,
+	       int	   x,
+	       int	   y)
+{
+    XGL_GC_PRIV (pGC);
+
+    if (!xglSyncBits (&pBitmap->drawable, NullBox))
+	FatalError (XGL_SW_FAILURE_STRING);
+
+    XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
+    (*pGC->ops->PushPixels) (pGC, pBitmap, pDrawable, w, h, x, y);
+    XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
+}
+
+Bool
+xglCreateGC (GCPtr pGC)
+{
+    ScreenPtr pScreen = pGC->pScreen;
+    Bool      ret;
+
+    XGL_SCREEN_PRIV (pScreen);
+    XGL_GC_PRIV (pGC);
+
+    XGL_SCREEN_UNWRAP (CreateGC);
+    ret = (*pScreen->CreateGC) (pGC);
+    XGL_SCREEN_WRAP (CreateGC, xglCreateGC);
+
+    XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
+    XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
+
+    pGCPriv->flags = 0;
+    pGCPriv->op = GLITZ_OPERATOR_SRC;
+
+    pGCPriv->fg = NULL;
+    pGCPriv->bg = NULL;
+    pGCPriv->id = ~0;
+
+    return ret;
+}
+
+void
+xglDestroyGC (GCPtr pGC)
+{
+    XGL_GC_PRIV (pGC);
+
+    if (pGCPriv->fg)
+	glitz_surface_destroy (pGCPriv->fg);
+
+    if (pGCPriv->bg)
+	glitz_surface_destroy (pGCPriv->bg);
+
+    XGL_GC_UNWRAP (funcs);
+    XGL_GC_UNWRAP (ops);
+    (*pGC->funcs->DestroyGC) (pGC);
+    XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
+    XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
+}
+
+void
+xglValidateGC (GCPtr	     pGC,
+	       unsigned long changes,
+	       DrawablePtr   pDrawable)
+{
+    XGL_GC_PRIV (pGC);
+
+    if (changes & GCTile)
+    {
+	if (!pGC->tileIsPixel &&
+	    FbEvenTile (pGC->tile.pixmap->drawable.width *
+			pDrawable->bitsPerPixel))
+	    xglSyncBits (&pGC->tile.pixmap->drawable, NULL);
+    }
+
+    if (changes & GCStipple)
+    {
+	if (pGC->stipple)
+	    xglSyncBits (&pGC->stipple->drawable, NULL);
+    }
+
+    XGL_GC_UNWRAP (funcs);
+    XGL_GC_UNWRAP (ops);
+    (*pGC->funcs->ValidateGC) (pGC, changes, pDrawable);
+    XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
+    XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
+
+    if (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
+    {
+	XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
+
+	if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
+	{
+	    glitz_format_t *format;
+
+	    format = pPixmapPriv->pVisual->format.surface;
+	    if (format->id != pGCPriv->id)
+	    {
+		XGL_SCREEN_PRIV (pDrawable->pScreen);
+
+		pGCPriv->flags |= xglGCSoftwareDrawableFlag;
+
+		if (pGCPriv->fg)
+		    glitz_surface_destroy (pGCPriv->fg);
+
+		pGCPriv->fg = glitz_surface_create (pScreenPriv->drawable,
+						    format, 1, 1, 0, NULL);
+		if (pGCPriv->fg)
+		    glitz_surface_set_fill (pGCPriv->fg, GLITZ_FILL_REPEAT);
+
+		if (pGCPriv->bg)
+		    glitz_surface_destroy (pGCPriv->bg);
+
+		pGCPriv->bg = glitz_surface_create (pScreenPriv->drawable,
+						    format, 1, 1, 0, NULL);
+		if (pGCPriv->bg)
+		    glitz_surface_set_fill (pGCPriv->bg, GLITZ_FILL_REPEAT);
+
+		pGCPriv->id = format->id;
+
+		if (pGCPriv->fg && pGCPriv->bg)
+		{
+		    changes |= (GCForeground | GCBackground);
+		    pGCPriv->flags &= ~xglGCSoftwareDrawableFlag;
+		}
+	    }
+	}
+	else
+	    pGCPriv->flags |= xglGCSoftwareDrawableFlag;
+    }
+
+    if (changes & GCFunction)
+    {
+	switch (pGC->alu) {
+	case GXclear:
+	    pGCPriv->op = GLITZ_OPERATOR_CLEAR;
+	    pGCPriv->flags &= ~xglGCBadFunctionFlag;
+	    break;
+	case GXcopy:
+	    pGCPriv->op = GLITZ_OPERATOR_SRC;
+	    pGCPriv->flags &= ~xglGCBadFunctionFlag;
+	    break;
+	case GXnoop:
+	    pGCPriv->op = GLITZ_OPERATOR_DST;
+	    pGCPriv->flags &= ~xglGCBadFunctionFlag;
+	    break;
+	default:
+	    pGCPriv->flags |= xglGCBadFunctionFlag;
+	    break;
+	}
+    }
+
+    if (changes & GCPlaneMask)
+    {
+	FbBits mask;
+
+	mask = FbFullMask (pDrawable->depth);
+
+	if ((pGC->planemask & mask) != mask)
+	    pGCPriv->flags |= xglGCPlaneMaskFlag;
+	else
+	    pGCPriv->flags &= ~xglGCPlaneMaskFlag;
+    }
+
+    if (!(pGCPriv->flags & xglGCSoftwareDrawableFlag))
+    {
+	if (changes & (GCForeground | GCBackground))
+	{
+	    glitz_pixel_format_t format;
+	    glitz_buffer_t	 *buffer;
+	    CARD32		 pixel;
+
+	    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
+
+	    format.fourcc	  = GLITZ_FOURCC_RGB;
+	    format.masks	  = pPixmapPriv->pVisual->pPixel->masks;
+	    format.xoffset	  = 0;
+	    format.skip_lines     = 0;
+	    format.bytes_per_line = sizeof (CARD32);
+	    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
+
+	    buffer = glitz_buffer_create_for_data (&pixel);
+
+	    if (changes & GCForeground)
+	    {
+		pixel = pGC->fgPixel;
+		glitz_set_pixels (pGCPriv->fg, 0, 0, 1, 1, &format, buffer);
+	    }
+
+	    if (changes & GCBackground)
+	    {
+		pixel = pGC->bgPixel;
+		glitz_set_pixels (pGCPriv->bg, 0, 0, 1, 1, &format, buffer);
+	    }
+
+	    glitz_buffer_destroy (buffer);
+	}
+    }
+}
diff --git a/xgl/xglgeometry.c b/xgl/xglgeometry.c
new file mode 100644
index 0000000..7ab1ba4
--- /dev/null
+++ b/xgl/xglgeometry.c
@@ -0,0 +1,724 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+
+xglDataTypeInfoRec xglGeometryDataTypes[2] = {
+    { GLITZ_DATA_TYPE_SHORT, sizeof (glitz_short_t) },
+    { GLITZ_DATA_TYPE_FLOAT, sizeof (glitz_float_t) }
+};
+
+glitz_buffer_hint_t usageTypes[] = {
+    GLITZ_BUFFER_HINT_STREAM_DRAW,
+    GLITZ_BUFFER_HINT_STATIC_DRAW,
+    GLITZ_BUFFER_HINT_DYNAMIC_DRAW
+};
+
+void
+xglGeometryResize (ScreenPtr	  pScreen,
+		   xglGeometryPtr pGeometry,
+		   int		  size)
+{
+    XGL_SCREEN_PRIV (pScreen);
+
+    if (size == pGeometry->size)
+	return;
+
+    if (pGeometry->broken)
+	return;
+
+    if (pGeometry->usage == GEOMETRY_USAGE_SYSMEM)
+    {
+	pGeometry->data = xrealloc (pGeometry->data, size);
+
+	if (pGeometry->buffer)
+	    glitz_buffer_destroy (pGeometry->buffer);
+
+	pGeometry->buffer = NULL;
+
+	if (pGeometry->data)
+	{
+	    pGeometry->buffer = glitz_buffer_create_for_data (pGeometry->data);
+	    if (!pGeometry->buffer)
+	    {
+		pGeometry->broken = TRUE;
+		return;
+	    }
+	}
+	else if (size)
+	{
+	    pGeometry->broken = TRUE;
+	    return;
+	}
+    }
+    else
+    {
+	glitz_buffer_t *newBuffer;
+
+	if (size)
+	{
+	    newBuffer =
+		glitz_vertex_buffer_create (pScreenPriv->drawable, NULL, size,
+					    usageTypes[pGeometry->usage]);
+	    if (!newBuffer)
+	    {
+		pGeometry->broken = TRUE;
+		return;
+	    }
+	} else
+	    newBuffer = NULL;
+
+	if (pGeometry->buffer && newBuffer)
+	{
+	    void *oldData, *newData;
+
+	    oldData = glitz_buffer_map (pGeometry->buffer,
+					GLITZ_BUFFER_ACCESS_READ_ONLY);
+	    newData = glitz_buffer_map (newBuffer,
+					GLITZ_BUFFER_ACCESS_WRITE_ONLY);
+
+	    if (oldData && newData)
+		memcpy (newData, oldData, MIN (size, pGeometry->size));
+
+	    glitz_buffer_unmap (pGeometry->buffer);
+	    glitz_buffer_unmap (newBuffer);
+
+	    glitz_buffer_destroy (pGeometry->buffer);
+	}
+	pGeometry->buffer = newBuffer;
+    }
+
+    pGeometry->size = size;
+
+    if (pGeometry->endOffset > size)
+	pGeometry->endOffset = size;
+}
+
+#define MAP_GEOMETRY(pScreen, pGeometry, offset, units, ptr, _size)	  \
+    if ((pGeometry)->broken)						  \
+	return;								  \
+    (_size) = (units) * xglGeometryDataTypes[(pGeometry)->dataType].size; \
+    if (((pGeometry)->size - (offset)) < (_size))			  \
+    {									  \
+	xglGeometryResize (pScreen, pGeometry,				  \
+			   (pGeometry)->endOffset + (_size) + 500);	  \
+	if ((pGeometry)->broken)					  \
+	    return;							  \
+    }									  \
+    (ptr) = glitz_buffer_map ((pGeometry)->buffer,			  \
+			      GLITZ_BUFFER_ACCESS_WRITE_ONLY);		  \
+    if (!(ptr))								  \
+    {									  \
+	(pGeometry)->broken = TRUE;					  \
+	return;								  \
+    }									  \
+    (ptr) += (offset)
+
+#define UNMAP_GEOMETRY(pGeometry, offset, _size)			   \
+    if (glitz_buffer_unmap ((pGeometry)->buffer))			   \
+    {									   \
+	(pGeometry)->broken = TRUE;					   \
+	return;								   \
+    }									   \
+    if (((offset) + (_size)) > (pGeometry)->endOffset)			   \
+    {									   \
+	(pGeometry)->endOffset = (offset) + (_size);			   \
+	(pGeometry)->count = (pGeometry)->endOffset /			   \
+	    (2 * xglGeometryDataTypes[(pGeometry)->dataType].size);	   \
+    }
+
+/*
+ * Adds a number of boxes as GL_QUAD primitives
+ */
+void
+xglGeometryAddBox (ScreenPtr	  pScreen,
+		   xglGeometryPtr pGeometry,
+		   BoxPtr	  pBox,
+		   int		  nBox,
+		   int		  offset)
+{
+    int  size;
+    char *ptr;
+
+    if (nBox < 1)
+	return;
+
+    MAP_GEOMETRY (pScreen, pGeometry, offset, nBox * 8, ptr, size);
+
+    switch (pGeometry->dataType) {
+    case GEOMETRY_DATA_TYPE_SHORT:
+    {
+	glitz_short_t *data = (glitz_short_t *) ptr;
+
+	while (nBox--)
+	{
+	    *data++ = (glitz_short_t) pBox->x1;
+	    *data++ = (glitz_short_t) pBox->y1;
+	    *data++ = (glitz_short_t) pBox->x2;
+	    *data++ = (glitz_short_t) pBox->y1;
+	    *data++ = (glitz_short_t) pBox->x2;
+	    *data++ = (glitz_short_t) pBox->y2;
+	    *data++ = (glitz_short_t) pBox->x1;
+	    *data++ = (glitz_short_t) pBox->y2;
+
+	    pBox++;
+	}
+    } break;
+    case GEOMETRY_DATA_TYPE_FLOAT:
+    {
+	glitz_float_t *data = (glitz_float_t *) ptr;
+
+	while (nBox--)
+	{
+	    *data++ = (glitz_float_t) pBox->x1;
+	    *data++ = (glitz_float_t) pBox->y1;
+	    *data++ = (glitz_float_t) pBox->x2;
+	    *data++ = (glitz_float_t) pBox->y1;
+	    *data++ = (glitz_float_t) pBox->x2;
+	    *data++ = (glitz_float_t) pBox->y2;
+	    *data++ = (glitz_float_t) pBox->x1;
+	    *data++ = (glitz_float_t) pBox->y2;
+
+	    pBox++;
+	}
+    } break;
+    }
+
+    UNMAP_GEOMETRY (pGeometry, offset, size);
+}
+
+/*
+ * Adds a number of spans as GL_LINE primitives
+ */
+void
+xglGeometryAddSpan (ScreenPtr	   pScreen,
+		    xglGeometryPtr pGeometry,
+		    DDXPointPtr	   ppt,
+		    int		   *pwidth,
+		    int		   n,
+		    int		   offset)
+{
+    int  size;
+    char *ptr;
+
+    if (n < 1)
+	return;
+
+    MAP_GEOMETRY (pScreen, pGeometry, offset, n * 4, ptr, size);
+
+    switch (pGeometry->dataType) {
+    case GEOMETRY_DATA_TYPE_SHORT:
+    {
+	glitz_short_t *data = (glitz_short_t *) ptr;
+
+	while (n--)
+	{
+	    *data++ = (glitz_short_t) ppt->x;
+	    *data++ = (glitz_short_t) ppt->y;
+	    *data++ = (glitz_short_t) (ppt->x + *pwidth);
+	    *data++ = (glitz_short_t) ppt->y;
+
+	    ppt++;
+	    pwidth++;
+	}
+    } break;
+    case GEOMETRY_DATA_TYPE_FLOAT:
+    {
+	glitz_float_t *data = (glitz_float_t *) ptr;
+
+	while (n--)
+	{
+	    *data++ = (glitz_float_t) ppt->x;
+	    *data++ = (glitz_float_t) ppt->y;
+	    *data++ = (glitz_float_t) (ppt->x + *pwidth);
+	    *data++ = (glitz_float_t) ppt->y;
+
+	    ppt++;
+	    pwidth++;
+	}
+    } break;
+    }
+
+    UNMAP_GEOMETRY (pGeometry, offset, size);
+}
+
+/*
+ * This macro is needed for end pixels to be rasterized correctly using
+ * OpenGL as OpenGL line segments are half-opened.
+ */
+#define ADJUST_END_POINT(start, end, isPoint) \
+    (((end) > (start)) ? (end) + 1:	      \
+     ((end) < (start)) ? (end) - 1:	      \
+     (isPoint)	       ? (end) + 1:	      \
+     (end))
+
+/*
+ * Adds a number of connected lines as GL_LINE_STRIP primitives
+ */
+void
+xglGeometryAddLine (ScreenPtr	   pScreen,
+		    xglGeometryPtr pGeometry,
+		    int		   loop,
+		    int		   mode,
+		    int		   npt,
+		    DDXPointPtr    ppt,
+		    int		   offset)
+{
+    DDXPointRec pt;
+    int		size;
+    char	*ptr;
+
+    if (npt < 2)
+	return;
+
+    MAP_GEOMETRY (pScreen, pGeometry, offset, npt * 2, ptr, size);
+
+    pt.x = 0;
+    pt.y = 0;
+
+    switch (pGeometry->dataType) {
+    case GEOMETRY_DATA_TYPE_SHORT:
+    {
+	glitz_short_t *data = (glitz_short_t *) ptr;
+
+	while (npt--)
+	{
+	    if (mode == CoordModePrevious)
+	    {
+		pt.x += ppt->x;
+		pt.y += ppt->y;
+	    }
+	    else
+	    {
+		pt.x = ppt->x;
+		pt.y = ppt->y;
+	    }
+
+	    if (npt || loop)
+	    {
+		*data++ = (glitz_short_t) pt.x;
+		*data++ = (glitz_short_t) pt.y;
+	    }
+	    else
+	    {
+		ppt--;
+		*data++ = (glitz_short_t)
+		    ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
+		*data++ = (glitz_short_t) ADJUST_END_POINT (ppt->y, pt.y, 0);
+	    }
+
+	    ppt++;
+	}
+    } break;
+    case GEOMETRY_DATA_TYPE_FLOAT:
+    {
+	glitz_float_t *data = (glitz_float_t *) ptr;
+
+	while (npt--)
+	{
+	    if (mode == CoordModePrevious)
+	    {
+		pt.x += ppt->x;
+		pt.y += ppt->y;
+	    }
+	    else
+	    {
+		pt.x = ppt->x;
+		pt.y = ppt->y;
+	    }
+
+	    if (npt || loop)
+	    {
+		*data++ = (glitz_float_t) pt.x;
+		*data++ = (glitz_float_t) pt.y;
+	    }
+	    else
+	    {
+		ppt--;
+		*data++ = (glitz_float_t)
+		    ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
+		*data++ = (glitz_float_t) ADJUST_END_POINT (ppt->y, pt.y, 0);
+	    }
+
+	    ppt++;
+	}
+    } break;
+    }
+
+    UNMAP_GEOMETRY (pGeometry, offset, size);
+}
+
+/*
+ * Adds a number of line segments as GL_LINE primitives
+ */
+void
+xglGeometryAddSegment (ScreenPtr      pScreen,
+		       xglGeometryPtr pGeometry,
+		       int	      nsegInit,
+		       xSegment       *pSegInit,
+		       int	      offset)
+{
+    int  size;
+    char *ptr;
+
+    if (nsegInit < 1)
+	return;
+
+    MAP_GEOMETRY (pScreen, pGeometry, offset, nsegInit * 4, ptr, size);
+
+    switch (pGeometry->dataType) {
+    case GEOMETRY_DATA_TYPE_SHORT:
+    {
+	glitz_short_t *data = (glitz_short_t *) ptr;
+
+	while (nsegInit--)
+	{
+	    *data++ = (glitz_short_t) pSegInit->x1;
+	    *data++ = (glitz_short_t) pSegInit->y1;
+	    *data++ = (glitz_short_t)
+		ADJUST_END_POINT (pSegInit->x1, pSegInit->x2,
+				  pSegInit->y1 == pSegInit->y2);
+	    *data++ = (glitz_short_t)
+		ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
+
+	    pSegInit++;
+	}
+    } break;
+    case GEOMETRY_DATA_TYPE_FLOAT:
+    {
+	glitz_float_t *data = (glitz_float_t *) ptr;
+
+	while (nsegInit--)
+	{
+	    *data++ = (glitz_float_t) pSegInit->x1;
+	    *data++ = (glitz_float_t) pSegInit->y1;
+	    *data++ = (glitz_float_t)
+		ADJUST_END_POINT (pSegInit->x1, pSegInit->x2,
+				  pSegInit->y1 == pSegInit->y2);
+	    *data++ = (glitz_float_t)
+		ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
+
+	    pSegInit++;
+	}
+    } break;
+    }
+
+    UNMAP_GEOMETRY (pGeometry, offset, size);
+}
+
+void
+xglGeometryForGlyph (ScreenPtr	    pScreen,
+		     xglGeometryPtr pGeometry,
+		     unsigned int   nGlyph,
+		     CharInfoPtr    *ppciInit,
+		     pointer	    pglyphBase)
+{
+    CharInfoPtr		*ppci;
+    CharInfoPtr		pci;
+    unsigned char	*glyphbase = (pointer) ~0;
+    unsigned char	*pglyph;
+    int			x = 0;
+    int			gx, gy;
+    int			gWidth, gHeight;
+    int			n, lastX = 0, lastY = 0;
+    glitz_multi_array_t *array;
+    glitz_buffer_t	*buffer;
+
+    ppci = ppciInit;
+    n = nGlyph;
+
+    while (n--)
+    {
+	pglyph = FONTGLYPHBITS (pglyphBase, *ppci++);
+	if (pglyph < glyphbase)
+	    glyphbase = pglyph;
+    }
+
+    buffer = glitz_buffer_create_for_data (glyphbase);
+    if (!buffer)
+    {
+	pGeometry->broken = TRUE;
+	return;
+    }
+
+    GEOMETRY_SET_BUFFER (pGeometry, buffer);
+
+    array = glitz_multi_array_create (nGlyph);
+    if (!array)
+    {
+	pGeometry->broken = TRUE;
+	return;
+    }
+
+    GEOMETRY_SET_MULTI_ARRAY (pGeometry, array);
+
+    ppci = ppciInit;
+    while (nGlyph--)
+    {
+	pci = *ppci++;
+	pglyph = FONTGLYPHBITS (pglyphBase, pci);
+	gWidth = GLYPHWIDTHPIXELS (pci);
+	gHeight = GLYPHHEIGHTPIXELS (pci);
+
+	if (gWidth && gHeight)
+	{
+	    gx = x + pci->metrics.leftSideBearing;
+	    gy = -pci->metrics.ascent;
+
+	    glitz_multi_array_add (array,
+				   (pglyph - glyphbase) * 8,
+				   gWidth, gHeight,
+				   (gx - lastX) << 16, (gy - lastY) << 16);
+	    lastX = gx;
+	    lastY = gy;
+	}
+	x += pci->metrics.characterWidth;
+    }
+
+    glitz_buffer_destroy (buffer);
+    glitz_multi_array_destroy (array);
+}
+
+#define FIXED_LINE_X_TO_FLOAT(line, v)		  \
+    (((glitz_float_t)				  \
+	((line).p1.x + (xFixed_16_16)		  \
+	 (((xFixed_32_32) ((v) - (line).p1.y) *   \
+	   ((line).p2.x - (line).p1.x)) /	  \
+	  ((line).p2.y - (line).p1.y)))) / 65536)
+
+#define FIXED_LINE_X_CEIL_TO_FLOAT(line, v)	\
+  (((glitz_float_t)				\
+      ((line).p1.x + (xFixed_16_16)		\
+       (((((line).p2.y - (line).p1.y) - 1) +	\
+	 ((xFixed_32_32) ((v) - (line).p1.y) *	\
+	  ((line).p2.x - (line).p1.x))) /	\
+	((line).p2.y - (line).p1.y)))) / 65536)
+
+/*
+ * Adds a number of trapezoids as GL_QUAD primitives
+ */
+void
+xglGeometryAddTrapezoid (ScreenPtr	pScreen,
+			 xglGeometryPtr pGeometry,
+			 xTrapezoid	*pTrap,
+			 int		nTrap,
+			 int		offset)
+{
+    int  size;
+    char *ptr;
+
+    if (nTrap < 1)
+	return;
+
+    MAP_GEOMETRY (pScreen, pGeometry, offset, nTrap * 8, ptr, size);
+
+    switch (pGeometry->dataType) {
+    case GEOMETRY_DATA_TYPE_SHORT:
+	/* not supported */
+	pGeometry->broken = TRUE;
+	break;
+    case GEOMETRY_DATA_TYPE_FLOAT:
+    {
+	glitz_float_t *data = (glitz_float_t *) ptr;
+	glitz_float_t top, bottom;
+
+	while (nTrap--)
+	{
+	    top    = FIXED_TO_FLOAT (pTrap->top);
+	    bottom = FIXED_TO_FLOAT (pTrap->bottom);
+
+	    *data++ = FIXED_LINE_X_TO_FLOAT (pTrap->left, pTrap->top);
+	    *data++ = top;
+	    *data++ = FIXED_LINE_X_CEIL_TO_FLOAT (pTrap->right, pTrap->top);
+	    *data++ = top;
+	    *data++ = FIXED_LINE_X_CEIL_TO_FLOAT (pTrap->right, pTrap->bottom);
+	    *data++ = bottom;
+	    *data++ = FIXED_LINE_X_TO_FLOAT (pTrap->left, pTrap->bottom);
+	    *data++ = bottom;
+
+	    pTrap++;
+	}
+    } break;
+    }
+
+    UNMAP_GEOMETRY (pGeometry, offset, size);
+}
+
+/*
+ * Adds a number of traps as GL_QUAD primitives
+ */
+void
+xglGeometryAddTrap (ScreenPtr	   pScreen,
+		    xglGeometryPtr pGeometry,
+		    xTrap	   *pTrap,
+		    int		   nTrap,
+		    int		   offset)
+{
+    int  size;
+    char *ptr;
+
+    if (nTrap < 1)
+	return;
+
+    MAP_GEOMETRY (pScreen, pGeometry, offset, nTrap * 8, ptr, size);
+
+    switch (pGeometry->dataType) {
+    case GEOMETRY_DATA_TYPE_SHORT:
+	/* not supported */
+	pGeometry->broken = TRUE;
+	break;
+    case GEOMETRY_DATA_TYPE_FLOAT:
+    {
+	glitz_float_t *data = (glitz_float_t *) ptr;
+	glitz_float_t top, bottom;
+
+	while (nTrap--)
+	{
+	    top    = FIXED_TO_FLOAT (pTrap->top.y);
+	    bottom = FIXED_TO_FLOAT (pTrap->bot.y);
+
+	    *data++ = FIXED_TO_FLOAT (pTrap->top.l);
+	    *data++ = top;
+	    *data++ = FIXED_TO_FLOAT (pTrap->top.r);
+	    *data++ = top;
+	    *data++ = FIXED_TO_FLOAT (pTrap->bot.r);
+	    *data++ = bottom;
+	    *data++ = FIXED_TO_FLOAT (pTrap->bot.l);
+	    *data++ = bottom;
+
+	    pTrap++;
+	}
+    } break;
+    }
+
+    UNMAP_GEOMETRY (pGeometry, offset, size);
+}
+
+/* XXX: scratch geometry size never shrinks, it just gets larger when
+   required. this is not acceptable. */
+xglGeometryPtr
+xglGetScratchGeometryWithSize (ScreenPtr pScreen,
+			       int	 size)
+{
+    xglGeometryPtr pGeometry;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    pGeometry = &pScreenPriv->scratchGeometry;
+
+    if (pGeometry->broken || pGeometry->size < size)
+    {
+	GEOMETRY_UNINIT (pGeometry);
+	GEOMETRY_INIT (pScreen, pGeometry, pGeometry->type,
+		       pScreenPriv->geometryUsage, size);
+    }
+    else
+    {
+	if (pGeometry->array)
+	{
+	    glitz_multi_array_destroy (pGeometry->array);
+	    pGeometry->array = NULL;
+	}
+	pGeometry->endOffset = 0;
+	pGeometry->xOff      = 0;
+	pGeometry->yOff      = 0;
+	pGeometry->first     = 0;
+	pGeometry->count     = 0;
+	pGeometry->width     = 2;
+    }
+
+    return pGeometry;
+}
+
+xglGeometryPtr
+xglGetScratchVertexGeometryWithType (ScreenPtr pScreen,
+				     int       type,
+				     int       count)
+{
+    xglGeometryPtr pGeometry;
+    int		   stride;
+
+    stride = 2 * xglGeometryDataTypes[type].size;
+
+    pGeometry = xglGetScratchGeometryWithSize (pScreen, count * stride);
+
+    pGeometry->type	= GLITZ_GEOMETRY_TYPE_VERTEX;
+    pGeometry->dataType	= type;
+
+    pGeometry->f.vertex.primitive	 = GLITZ_PRIMITIVE_QUADS;
+    pGeometry->f.vertex.type		 = xglGeometryDataTypes[type].type;
+    pGeometry->f.vertex.bytes_per_vertex = stride;
+    pGeometry->f.vertex.attributes       = 0;
+
+    return pGeometry;
+}
+
+xglGeometryPtr
+xglGetScratchVertexGeometry (ScreenPtr pScreen,
+			     int	 count)
+{
+    xglGeometryPtr pGeometry;
+    int		   type, stride;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    type   = pScreenPriv->geometryDataType;
+    stride = 2 * xglGeometryDataTypes[type].size;
+
+    pGeometry = xglGetScratchGeometryWithSize (pScreen, count * stride);
+
+    pGeometry->type	= GLITZ_GEOMETRY_TYPE_VERTEX;
+    pGeometry->dataType	= type;
+
+    pGeometry->f.vertex.primitive	 = GLITZ_PRIMITIVE_QUADS;
+    pGeometry->f.vertex.type		 = xglGeometryDataTypes[type].type;
+    pGeometry->f.vertex.bytes_per_vertex = stride;
+    pGeometry->f.vertex.attributes       = 0;
+
+    return pGeometry;
+}
+
+Bool
+xglSetGeometry (xglGeometryPtr	pGeometry,
+		glitz_surface_t *surface)
+{
+    if (pGeometry->broken)
+	return FALSE;
+
+    glitz_set_geometry (surface, pGeometry->type, &pGeometry->f,
+			pGeometry->buffer);
+
+    if (pGeometry->array)
+	glitz_set_multi_array (surface, pGeometry->array,
+			       pGeometry->xOff, pGeometry->yOff);
+    else
+	glitz_set_array (surface,
+			 pGeometry->first, pGeometry->width, pGeometry->count,
+			 pGeometry->xOff, pGeometry->yOff);
+
+    return TRUE;
+}
diff --git a/xgl/xglget.c b/xgl/xglget.c
new file mode 100644
index 0000000..71e32b1
--- /dev/null
+++ b/xgl/xglget.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+#include "glxserver.h"
+#include "glapi.h"
+#include "glthread.h"
+#include "dispatch.h"
+
+
+#include "xgl.h"
+
+void
+xglGetImage (DrawablePtr   pDrawable,
+	     int	   x,
+	     int	   y,
+	     int	   w,
+	     int	   h,
+	     unsigned int  format,
+	     unsigned long planeMask,
+	     char	   *d)
+{
+    ScreenPtr	    pScreen = pDrawable->pScreen;
+    glitz_surface_t *surface;
+    int             xOff, yOff;
+    BoxRec	    box;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    /* Many apps use GetImage to sync with the visible frame buffer */
+    if (pDrawable->type == DRAWABLE_WINDOW)
+    {
+	if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable))
+	    FatalError (XGL_SW_FAILURE_STRING);
+
+	__glXleaveServer(FALSE);
+	glitz_surface_flush (pScreenPriv->surface);
+	glitz_drawable_finish (pScreenPriv->drawable);
+	__glXenterServer(FALSE);
+    }
+
+    XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
+
+    box.x1 = pDrawable->x + xOff + x;
+    box.y1 = pDrawable->y + yOff + y;
+    box.x2 = box.x1 + w;
+    box.y2 = box.y1 + h;
+
+    if (!xglSyncBits (pDrawable, &box))
+	FatalError (XGL_SW_FAILURE_STRING);
+
+    XGL_SCREEN_UNWRAP (GetImage);
+    (*pScreen->GetImage) (pDrawable, x, y, w, h, format, planeMask, d);
+    XGL_SCREEN_WRAP (GetImage, xglGetImage);
+}
+
+void
+xglGetSpans (DrawablePtr pDrawable,
+	     int	 wMax,
+	     DDXPointPtr ppt,
+	     int	 *pwidth,
+	     int	 nspans,
+	     char	 *pchardstStart)
+{
+    ScreenPtr pScreen = pDrawable->pScreen;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    if (!xglSyncBits (pDrawable, NullBox))
+	FatalError (XGL_SW_FAILURE_STRING);
+
+    XGL_SCREEN_UNWRAP (GetSpans);
+    (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
+    XGL_SCREEN_WRAP (GetSpans, xglGetSpans);
+}
diff --git a/xgl/xglglyph.c b/xgl/xglglyph.c
new file mode 100644
index 0000000..7a60188
--- /dev/null
+++ b/xgl/xglglyph.c
@@ -0,0 +1,1169 @@
+/*
+ * Copyright © 2005 Novell, Inc.
+ *
+ * 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
+ * Novell, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Novell, Inc. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NOVELL, INC. 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+
+#ifdef RENDER
+#include "gcstruct.h"
+#include "picturestr.h"
+
+#define BITMAP_CACHE_SIZE      256000
+#define BITMAP_CACHE_MAX_LEVEL ~0
+#define BITMAP_CACHE_MAX_SIZE  512
+
+#define TEXTURE_CACHE_SIZE	 512
+#define TEXTURE_CACHE_MAX_LEVEL	 64
+#define TEXTURE_CACHE_MAX_HEIGHT 72
+#define TEXTURE_CACHE_MAX_WIDTH  72
+
+#define NEXT_GLYPH_SERIAL_NUMBER ((++glyphSerialNumber) > MAX_SERIAL_NUM ? \
+	    (glyphSerialNumber = 1): glyphSerialNumber)
+
+#define GLYPH_GET_AREA_PRIV(pArea)		\
+    ((xglGlyphAreaPtr) (pArea)->devPrivate.ptr)
+
+#define GLYPH_AREA_PRIV(pArea)				    \
+    xglGlyphAreaPtr pAreaPriv = GLYPH_GET_AREA_PRIV (pArea)
+
+#define NEEDS_COMPONENT(f) (PICT_FORMAT_A (f) != 0 && PICT_FORMAT_RGB (f) != 0)
+
+#define WRITE_VEC2(ptr, _x, _y) \
+    *(ptr)++ = (_x);		\
+    *(ptr)++ = (_y)
+
+#define WRITE_BOX(ptr, _vx1, _vy1, _vx2, _vy2, box) \
+    WRITE_VEC2 (ptr, _vx1, _vy1);		    \
+    WRITE_VEC2 (ptr, (box).x1, (box).y2);	    \
+    WRITE_VEC2 (ptr, _vx2, _vy1);		    \
+    WRITE_VEC2 (ptr, (box).x2, (box).y2);	    \
+    WRITE_VEC2 (ptr, _vx2, _vy2);		    \
+    WRITE_VEC2 (ptr, (box).x2, (box).y1);	    \
+    WRITE_VEC2 (ptr, _vx1, _vy2);		    \
+    WRITE_VEC2 (ptr, (box).x1, (box).y1)
+
+typedef union _xglGlyphList {
+    glitz_short_t *s;
+    glitz_float_t *f;
+} xglGlyphListRec, *xglGlyphListPtr;
+
+typedef struct _xglGlyphArray {
+    int	lastX, lastY;
+} xglGlyphArrayRec, *xglGlyphArrayPtr;
+
+typedef union _xglGlyphVertexData {
+    xglGlyphArrayRec array;
+    xglGlyphListRec  list;
+} xglGlyphVertexDataRec, *xglGlyphVertexDataPtr;
+
+typedef struct _xglGlyphOp {
+    GlyphListPtr pLists;
+    int		 listLen;
+    GlyphPtr	 *ppGlyphs;
+    int		 nGlyphs;
+    int		 xOff;
+    int		 yOff;
+    Bool	 noCache;
+} xglGlyphOpRec, *xglGlyphOpPtr;
+
+unsigned long glyphSerialNumber = 0;
+
+xglAreaRec zeroSizeArea = {
+    0, 0,
+    0, 0,
+    0, 0,
+    { NULL, NULL, NULL, NULL }, NULL,
+    (pointer) 0,
+    { 0 }
+};
+
+static Bool
+xglGlyphCreate (xglAreaPtr pArea)
+{
+    return TRUE;
+}
+
+static Bool
+xglGlyphMoveIn (xglAreaPtr pArea,
+		pointer    closure)
+{
+    xglGlyphCachePtr pCache = (xglGlyphCachePtr) pArea->pRoot->closure;
+    GlyphPtr	     pGlyph = (GlyphPtr) closure;
+
+    XGL_GLYPH_PRIV (pCache->pScreen, pGlyph);
+
+    pGlyphPriv->pArea = pArea;
+
+    return TRUE;
+}
+
+static void
+xglGlyphMoveOut (xglAreaPtr pArea,
+		 pointer    closure)
+{
+    xglGlyphCachePtr pCache = (xglGlyphCachePtr) pArea->pRoot->closure;
+    GlyphPtr	     pGlyph = (GlyphPtr) closure;
+
+    XGL_GLYPH_PRIV (pCache->pScreen, pGlyph);
+
+    pGlyphPriv->pArea = NULL;
+}
+
+static int
+xglGlyphCompareScore (xglAreaPtr pArea,
+		      pointer	 closure1,
+		      pointer	 closure2)
+{
+    GLYPH_AREA_PRIV (pArea);
+
+    if (pAreaPriv->serial == glyphSerialNumber)
+	return 1;
+
+    return -1;
+}
+
+static const xglAreaFuncsRec xglGlyphAreaFuncs = {
+    xglGlyphCreate,
+    xglGlyphMoveIn,
+    xglGlyphMoveOut,
+    xglGlyphCompareScore
+};
+
+Bool
+xglRealizeGlyph (ScreenPtr pScreen,
+		 GlyphPtr  pGlyph)
+{
+    PictureScreenPtr pPictureScreen = GetPictureScreen (pScreen);
+    Bool	     ret;
+
+    XGL_SCREEN_PRIV (pScreen);
+    XGL_GLYPH_PRIV (pScreen, pGlyph);
+
+    XGL_PICTURE_SCREEN_UNWRAP (RealizeGlyph);
+    ret = (*pPictureScreen->RealizeGlyph) (pScreen, pGlyph);
+    XGL_PICTURE_SCREEN_WRAP (RealizeGlyph, xglRealizeGlyph);
+
+    pGlyphPriv->pArea = NULL;
+
+    return ret;
+}
+
+void
+xglUnrealizeGlyph (ScreenPtr pScreen,
+		   GlyphPtr  pGlyph)
+{
+    PictureScreenPtr pPictureScreen = GetPictureScreen (pScreen);
+
+    XGL_SCREEN_PRIV (pScreen);
+    XGL_GLYPH_PRIV (pScreen, pGlyph);
+
+    XGL_PICTURE_SCREEN_UNWRAP (UnrealizeGlyph);
+    (*pPictureScreen->UnrealizeGlyph) (pScreen, pGlyph);
+    XGL_PICTURE_SCREEN_WRAP (UnrealizeGlyph, xglUnrealizeGlyph);
+
+    if (pGlyphPriv->pArea && pGlyphPriv->pArea->width)
+	xglWithdrawArea (pGlyphPriv->pArea);
+}
+
+Bool
+xglInitGlyphCache (xglGlyphCachePtr pCache,
+		   ScreenPtr	    pScreen,
+		   PictFormatPtr    format)
+{
+    XGL_SCREEN_PRIV (pScreen);
+
+    pCache->depth = format->depth;
+
+    if (!pScreenPriv->pSolidAlpha)
+    {
+	xglCreateSolidAlphaPicture (pScreen);
+	if (!pScreenPriv->pSolidAlpha)
+	    return FALSE;
+    }
+
+    if (pCache->depth == 1)
+    {
+	int stride;
+
+	GEOMETRY_INIT (pScreen, &pCache->u.geometry,
+		       GLITZ_GEOMETRY_TYPE_VERTEX,
+		       GEOMETRY_USAGE_STATIC, BITMAP_CACHE_SIZE);
+	GEOMETRY_SET_VERTEX_DATA_TYPE (&pCache->u.geometry,
+				       pScreenPriv->geometryDataType);
+
+	stride = pCache->u.geometry.f.vertex.bytes_per_vertex;
+	if (!xglRootAreaInit (&pCache->rootArea,
+			      BITMAP_CACHE_MAX_LEVEL,
+			      BITMAP_CACHE_SIZE / (stride * 4),
+			      0, sizeof (xglGlyphAreaRec),
+			      (xglAreaFuncsPtr) &xglGlyphAreaFuncs,
+			      (pointer) pCache))
+	{
+	    GEOMETRY_UNINIT (&pCache->u.geometry);
+	    return FALSE;
+	}
+    }
+    else
+    {
+
+	xglGlyphTexturePtr	   pTexture = &pCache->u.texture;
+	glitz_surface_t		   *mask;
+	glitz_surface_attributes_t attr;
+	glitz_vertex_format_t	   *vertex;
+	xglVisualPtr		   pVisual;
+
+	pVisual = xglFindVisualWithDepth (pScreen, format->depth);
+	if (!pVisual)
+	    return FALSE;
+
+	if (!xglRootAreaInit (&pCache->rootArea,
+			      TEXTURE_CACHE_MAX_LEVEL,
+			      TEXTURE_CACHE_SIZE, TEXTURE_CACHE_SIZE,
+			      sizeof (xglGlyphAreaRec),
+			      (xglAreaFuncsPtr) &xglGlyphAreaFuncs,
+			      (pointer) pCache))
+	    return FALSE;
+
+	if (pScreenPriv->geometryDataType == GEOMETRY_DATA_TYPE_SHORT)
+	{
+	    attr.unnormalized = 1;
+	    mask = glitz_surface_create (pScreenPriv->drawable,
+					 pVisual->format.surface,
+					 TEXTURE_CACHE_SIZE,
+					 TEXTURE_CACHE_SIZE,
+					 GLITZ_SURFACE_UNNORMALIZED_MASK,
+					 &attr);
+	}
+	else
+	    mask = NULL;
+
+	if (!mask)
+	{
+	    mask = glitz_surface_create (pScreenPriv->drawable,
+					 pVisual->format.surface,
+					 TEXTURE_CACHE_SIZE,
+					 TEXTURE_CACHE_SIZE,
+					 0, NULL);
+	    if (!mask)
+		return FALSE;
+
+	    pTexture->geometryDataType = GEOMETRY_DATA_TYPE_FLOAT;
+	}
+	else
+	    pTexture->geometryDataType = GEOMETRY_DATA_TYPE_SHORT;
+
+	if (NEEDS_COMPONENT (format->format))
+	    glitz_surface_set_component_alpha (mask, 1);
+
+	pTexture->pMask = xglCreateDevicePicture (mask);
+	if (!pTexture->pMask)
+	    return FALSE;
+
+	vertex = &pCache->u.texture.format.vertex;
+	vertex->primitive  = GLITZ_PRIMITIVE_QUADS;
+	vertex->mask.size  = GLITZ_COORDINATE_SIZE_XY;
+	vertex->attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK;
+
+	if (pTexture->geometryDataType == GEOMETRY_DATA_TYPE_FLOAT)
+	{
+	    vertex->type	     = GLITZ_DATA_TYPE_FLOAT;
+	    vertex->bytes_per_vertex = sizeof (glitz_float_t) * 4;
+	    vertex->mask.offset	     = sizeof (glitz_float_t) * 2;
+	    vertex->mask.type	     = GLITZ_DATA_TYPE_FLOAT;
+	}
+	else
+	{
+	    vertex->type	     = GLITZ_DATA_TYPE_SHORT;
+	    vertex->bytes_per_vertex = sizeof (glitz_short_t) * 4;
+	    vertex->mask.offset	     = sizeof (glitz_short_t) * 2;
+	    vertex->mask.type	     = GLITZ_DATA_TYPE_SHORT;
+	}
+
+	pTexture->pixel.fourcc	       = GLITZ_FOURCC_RGB;
+	pTexture->pixel.masks	       = pVisual->pPixel->masks;
+	pTexture->pixel.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
+	pTexture->pixel.bytes_per_line = 0;
+	pTexture->pixel.xoffset	       = 0;
+	pTexture->pixel.skip_lines     = 0;
+    }
+
+    pCache->pScreen = pScreen;
+
+    return TRUE;
+}
+
+void
+xglFiniGlyphCache (xglGlyphCachePtr pCache)
+{
+    if (pCache->pScreen)
+    {
+	xglRootAreaFini (&pCache->rootArea);
+
+	if (pCache->depth == 1)
+	{
+	    GEOMETRY_UNINIT (&pCache->u.geometry);
+	}
+	else
+	{
+	    if (pCache->u.texture.pMask)
+		FreePicture ((pointer) pCache->u.texture.pMask, 0);
+	}
+
+	pCache->pScreen = NULL;
+    }
+}
+
+static xglAreaPtr
+xglCacheGlyph (xglGlyphCachePtr pCache,
+	       GlyphPtr		pGlyph)
+{
+    ScreenPtr pScreen = pCache->pScreen;
+
+    XGL_GLYPH_PRIV (pScreen, pGlyph);
+
+    if (pCache->depth == 1)
+    {
+	PixmapPtr pPixmap;
+	RegionPtr pRegion;
+	int	  nBox;
+
+	pPixmap = GetScratchPixmapHeader (pScreen,
+					  pGlyph->info.width,
+					  pGlyph->info.height,
+					  pCache->depth, pCache->depth, 0,
+					  (pointer) (pGlyph + 1));
+	if (!pPixmap)
+	    return NULL;
+
+	(*pScreen->ModifyPixmapHeader) (pPixmap,
+					pGlyph->info.width,
+					pGlyph->info.height,
+					0, 0, -1, (pointer) (pGlyph + 1));
+
+	pRegion = (*pScreen->BitmapToRegion) (pPixmap);
+	FreeScratchPixmapHeader (pPixmap);
+
+	if (!pRegion)
+	    return NULL;
+
+	nBox = REGION_NUM_RECTS (pRegion);
+	if (nBox > BITMAP_CACHE_MAX_SIZE)
+	{
+	    REGION_DESTROY (pScreen, pRegion);
+	    return NULL;
+	}
+
+	if (nBox > 0)
+	{
+	    /* Find available area */
+	    if (!xglFindArea (pCache->rootArea.pArea, nBox, 0,
+			      FALSE, (pointer) pGlyph))
+	    {
+		/* Kicking out area with lower score */
+		xglFindArea (pCache->rootArea.pArea, nBox, 0,
+			     TRUE, (pointer) pGlyph);
+	    }
+
+	    if (pGlyphPriv->pArea)
+	    {
+		int stride;
+
+		GLYPH_AREA_PRIV (pGlyphPriv->pArea);
+
+		pAreaPriv->serial = glyphSerialNumber;
+		pAreaPriv->u.range.first = pGlyphPriv->pArea->x * 4;
+		pAreaPriv->u.range.count = nBox * 4;
+
+		stride = pCache->u.geometry.f.vertex.bytes_per_vertex;
+		GEOMETRY_ADD_REGION_AT (pScreen, &pCache->u.geometry, pRegion,
+					pGlyphPriv->pArea->x * stride * 4);
+	    }
+	} else
+	    pGlyphPriv->pArea = &zeroSizeArea;
+
+	REGION_DESTROY (pScreen, pRegion);
+    }
+    else
+    {
+	xglGlyphTexturePtr pTexture = &pCache->u.texture;
+
+	if (pGlyph->info.width  > TEXTURE_CACHE_MAX_WIDTH ||
+	    pGlyph->info.height > TEXTURE_CACHE_MAX_HEIGHT)
+	    return NULL;
+
+	if (pGlyph->info.width > 0 && pGlyph->info.height > 0)
+	{
+	    glitz_buffer_t *buffer;
+
+	    buffer = glitz_buffer_create_for_data (pGlyph + 1);
+	    if (!buffer)
+		return NULL;
+
+	    /* Find available area */
+	    if (!xglFindArea (pCache->rootArea.pArea,
+			      pGlyph->info.width, pGlyph->info.height,
+			      FALSE, (pointer) pGlyph))
+	    {
+		/* Kicking out area with lower score */
+		xglFindArea (pCache->rootArea.pArea,
+			     pGlyph->info.width, pGlyph->info.height,
+			     TRUE, (pointer) pGlyph);
+	    }
+
+	    if (pGlyphPriv->pArea)
+	    {
+		glitz_surface_t	     *surface;
+		glitz_point_fixed_t  p1, p2;
+		glitz_pixel_format_t pixel;
+
+		GLYPH_AREA_PRIV (pGlyphPriv->pArea);
+
+		pixel = pTexture->pixel;
+		pixel.bytes_per_line =
+		    PixmapBytePad (pGlyph->info.width, pCache->depth);
+
+		surface = pTexture->pMask->pSourcePict->source.devPrivate.ptr;
+
+		glitz_set_pixels (surface,
+				  pGlyphPriv->pArea->x,
+				  pGlyphPriv->pArea->y,
+				  pGlyph->info.width,
+				  pGlyph->info.height,
+				  &pixel,
+				  buffer);
+
+		p1.x = pGlyphPriv->pArea->x << 16;
+		p1.y = pGlyphPriv->pArea->y << 16;
+		p2.x = (pGlyphPriv->pArea->x + pGlyph->info.width)  << 16;
+		p2.y = (pGlyphPriv->pArea->y + pGlyph->info.height) << 16;
+
+		glitz_surface_translate_point (surface, &p1, &p1);
+		glitz_surface_translate_point (surface, &p2, &p2);
+
+		pAreaPriv->serial = glyphSerialNumber;
+		if (pTexture->geometryDataType)
+		{
+		    pAreaPriv->u.box.fBox.x1 = FIXED_TO_FLOAT (p1.x);
+		    pAreaPriv->u.box.fBox.y1 = FIXED_TO_FLOAT (p1.y);
+		    pAreaPriv->u.box.fBox.x2 = FIXED_TO_FLOAT (p2.x);
+		    pAreaPriv->u.box.fBox.y2 = FIXED_TO_FLOAT (p2.y);
+		}
+		else
+		{
+		    pAreaPriv->u.box.sBox.x1 = p1.x >> 16;
+		    pAreaPriv->u.box.sBox.y1 = p1.y >> 16;
+		    pAreaPriv->u.box.sBox.x2 = p2.x >> 16;
+		    pAreaPriv->u.box.sBox.y2 = p2.y >> 16;
+		}
+	    }
+	    glitz_buffer_destroy (buffer);
+	} else
+	    pGlyphPriv->pArea = &zeroSizeArea;
+    }
+
+    return pGlyphPriv->pArea;
+}
+
+static void
+xglUncachedGlyphs (CARD8	 op,
+		   PicturePtr    pSrc,
+		   PicturePtr    pDst,
+		   INT16	 xSrc,
+		   INT16	 ySrc,
+		   xglGlyphOpPtr pOp)
+{
+    ScreenPtr	     pScreen = pDst->pDrawable->pScreen;
+    PicturePtr	     pPicture = NULL;
+    PixmapPtr	     pPixmap = NULL;
+    xglGlyphCachePtr pCache;
+    int		     depth = pOp->pLists->format->depth;
+    GlyphPtr	     glyph;
+    INT16	     xOff, yOff;
+    xglGlyphPtr	     pGlyphPriv;
+    xglAreaPtr	     pArea;
+    Bool	     usingCache = !pOp->noCache;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    pCache = &pScreenPriv->glyphCache[depth];
+    if (usingCache)
+    {
+	if (!pCache->pScreen)
+	{
+	    if (!xglInitGlyphCache (pCache, pScreen, pOp->pLists->format))
+		usingCache = FALSE;
+	}
+    }
+
+    while (pOp->nGlyphs)
+    {
+	glyph = *pOp->ppGlyphs;
+
+	if (!pOp->listLen)
+	{
+	    pOp->pLists++;
+	    pOp->listLen = pOp->pLists->len;
+	    pOp->xOff   += pOp->pLists->xOff;
+	    pOp->yOff   += pOp->pLists->yOff;
+	}
+
+	xOff = pOp->xOff;
+	yOff = pOp->yOff;
+
+	if (usingCache)
+	{
+	    pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, glyph);
+	    pArea = pGlyphPriv->pArea;
+	    if (pSrc)
+	    {
+		if (!pArea)
+		    pArea = xglCacheGlyph (pCache, glyph);
+
+		if (pArea)
+		    break;
+	    }
+	} else
+	    pArea = NULL;
+
+	pOp->listLen--;
+	pOp->nGlyphs--;
+	pOp->ppGlyphs++;
+
+	pOp->xOff += glyph->info.xOff;
+	pOp->yOff += glyph->info.yOff;
+
+	if (pArea)
+	    continue;
+
+	if (!pPicture)
+	{
+	    XID componentAlpha;
+	    int	error;
+
+	    pPixmap = GetScratchPixmapHeader (pScreen,
+					      glyph->info.width,
+					      glyph->info.height,
+					      depth, depth,
+					      0, (pointer) (glyph + 1));
+	    if (!pPixmap)
+		return;
+
+	    componentAlpha = NEEDS_COMPONENT (pOp->pLists->format->format);
+	    pPicture = CreatePicture (0, &pPixmap->drawable,
+				      pOp->pLists->format,
+				      CPComponentAlpha, &componentAlpha,
+				      serverClient, &error);
+	    if (!pPicture)
+	    {
+		FreeScratchPixmapHeader (pPixmap);
+		return;
+	    }
+	}
+
+	(*pScreen->ModifyPixmapHeader) (pPixmap,
+					glyph->info.width, glyph->info.height,
+					0, 0, -1, (pointer) (glyph + 1));
+	pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+	if (pSrc)
+	    CompositePicture (op,
+			      pSrc,
+			      pPicture,
+			      pDst,
+			      xSrc + (xOff - glyph->info.x),
+			      ySrc + (yOff - glyph->info.y),
+			      0, 0,
+			      xOff - glyph->info.x,
+			      yOff - glyph->info.y,
+			      glyph->info.width,
+			      glyph->info.height);
+	else
+	    CompositePicture (PictOpAdd,
+			      pPicture,
+			      NULL,
+			      pDst,
+			      0, 0,
+			      0, 0,
+			      xOff - glyph->info.x,
+			      yOff - glyph->info.y,
+			      glyph->info.width,
+			      glyph->info.height);
+    }
+
+    if (pPicture)
+    {
+	FreeScratchPixmapHeader (pPixmap);
+	FreePicture ((pointer) pPicture, 0);
+    }
+}
+
+static Bool
+xglCachedGlyphs (CARD8	       op,
+		 PicturePtr    pSrc,
+		 PicturePtr    pDst,
+		 INT16	       xSrc,
+		 INT16	       ySrc,
+		 xglGlyphOpPtr pOp)
+{
+    ScreenPtr		  pScreen = pDst->pDrawable->pScreen;
+    xglGlyphOpRec	  opSave = *pOp;
+    xglGlyphCachePtr	  pCache;
+    xglGlyphVertexDataRec vData;
+    xglGeometryPtr	  pGeometry;
+    GlyphPtr		  glyph;
+    xglGlyphPtr		  pGlyphPriv;
+    xglAreaPtr		  pArea;
+    xglGlyphAreaPtr	  pGlyphArea;
+    BoxRec		  extents;
+    INT16		  xOff, yOff, x1, x2, y1, y2;
+    int			  depth = pOp->pLists->format->depth;
+    int			  i, remaining = pOp->nGlyphs;
+    int			  nGlyph = 0;
+    PicturePtr		  pMaskPicture = NULL;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    pCache = &pScreenPriv->glyphCache[depth];
+    if (!pCache->pScreen)
+    {
+	if (!xglInitGlyphCache (pCache, pScreen, pOp->pLists->format))
+	{
+	    pOp->noCache = TRUE;
+	    return 1;
+	}
+    }
+
+    /* update serial number for all glyphs already in cache so that
+       we don't accidentally replace one. */
+    for (i = 0; i < pOp->nGlyphs; i++)
+    {
+	pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pOp->ppGlyphs[i]);
+	pArea = pGlyphPriv->pArea;
+	if (pArea && pArea->width)
+	    GLYPH_GET_AREA_PRIV (pArea)->serial = glyphSerialNumber;
+    }
+
+    for (i = 0; i < pOp->nGlyphs; i++)
+    {
+	pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pOp->ppGlyphs[i]);
+	pArea = pGlyphPriv->pArea;
+	if (!pArea)
+	    pArea = xglCacheGlyph (pCache, pOp->ppGlyphs[i]);
+
+	if (pArea)
+	{
+	    if (pArea->width)
+		nGlyph++;
+	}
+	else if (pSrc)
+	    break;
+    }
+
+    if (nGlyph)
+    {
+	if (depth == 1)
+	{
+	    glitz_multi_array_t *multiArray;
+
+	    pGeometry = &pCache->u.geometry;
+	    pGeometry->xOff = pGeometry->yOff = 0;
+
+	    multiArray = glitz_multi_array_create (nGlyph);
+	    if (!multiArray)
+		return 1;
+
+	    GEOMETRY_SET_MULTI_ARRAY (pGeometry, multiArray);
+	    glitz_multi_array_destroy (multiArray);
+
+	    vData.array.lastX = 0;
+	    vData.array.lastY = 0;
+	}
+	else
+	{
+	    i = 4 * pCache->u.texture.format.vertex.bytes_per_vertex * nGlyph;
+	    pGeometry = xglGetScratchGeometryWithSize (pScreen, i);
+
+	    pGeometry->f = pCache->u.texture.format;
+	    pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
+	    pMaskPicture = pCache->u.texture.pMask;
+
+	    vData.list.s = glitz_buffer_map (pGeometry->buffer,
+					     GLITZ_BUFFER_ACCESS_WRITE_ONLY);
+	}
+    } else
+	pGeometry = NULL;
+
+    extents.x1 = MAXSHORT;
+    extents.y1 = MAXSHORT;
+    extents.x2 = MINSHORT;
+    extents.y2 = MINSHORT;
+
+    while (pOp->nGlyphs)
+    {
+	glyph = *pOp->ppGlyphs;
+
+	if (!pOp->listLen)
+	{
+	    pOp->pLists++;
+	    pOp->listLen = pOp->pLists->len;
+	    pOp->xOff   += pOp->pLists->xOff;
+	    pOp->yOff   += pOp->pLists->yOff;
+	}
+
+	xOff = pOp->xOff;
+	yOff = pOp->yOff;
+
+	pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, glyph);
+	pArea = pGlyphPriv->pArea;
+	if (!pArea && pSrc)
+	    break;
+
+	pOp->listLen--;
+	pOp->nGlyphs--;
+	pOp->ppGlyphs++;
+
+	pOp->xOff += glyph->info.xOff;
+	pOp->yOff += glyph->info.yOff;
+
+	if (!pArea)
+	    continue;
+
+	x1 = xOff - glyph->info.x;
+	x2 = x1 + glyph->info.width;
+	if (x1 < extents.x1)
+	    extents.x1 = x1;
+	if (x2 > extents.x2)
+	    extents.x2 = x2;
+
+	y1 = yOff - glyph->info.y;
+	y2 = y1 + glyph->info.height;
+	if (y1 < extents.y1)
+	    extents.y1 = y1;
+	if (y2 > extents.y2)
+	    extents.y2 = y2;
+
+	if (pArea->width)
+	{
+	    pGlyphArea = GLYPH_GET_AREA_PRIV (pArea);
+	    if (depth == 1)
+	    {
+		glitz_multi_array_add (pGeometry->array,
+				       pGlyphArea->u.range.first, 2,
+				       pGlyphArea->u.range.count,
+				       (x1 - vData.array.lastX) << 16,
+				       (y1 - vData.array.lastY) << 16);
+		vData.array.lastX = x1;
+		vData.array.lastY = y1;
+	    }
+	    else
+	    {
+		if (pCache->u.texture.geometryDataType)
+		{
+		    WRITE_BOX (vData.list.f, x1, y1, x2, y2,
+			       pGlyphArea->u.box.fBox);
+		}
+		else
+		{
+		    WRITE_BOX (vData.list.s, x1, y1, x2, y2,
+			       pGlyphArea->u.box.sBox);
+		}
+	    }
+	}
+	remaining--;
+    }
+
+    NEXT_GLYPH_SERIAL_NUMBER;
+
+    if (nGlyph)
+    {
+	if (depth != 1)
+	{
+	    glitz_buffer_unmap (pGeometry->buffer);
+	    pGeometry->count = nGlyph * 4;
+	}
+
+	xSrc += extents.x1;
+	ySrc += extents.y1;
+
+	if (!pSrc)
+	{
+	    op = PictOpAdd;
+	    pSrc = pScreenPriv->pSolidAlpha;
+
+	    if (remaining)
+		*pOp = opSave;
+	}
+
+	GEOMETRY_TRANSLATE (pGeometry,
+			    pDst->pDrawable->x,
+			    pDst->pDrawable->y);
+
+	if (xglCompositeGeneral (op,
+				 pSrc,
+				 pMaskPicture,
+				 pDst,
+				 pGeometry,
+				 xSrc, ySrc,
+				 0, 0,
+				 pDst->pDrawable->x + extents.x1,
+				 pDst->pDrawable->y + extents.y1,
+				 extents.x2 - extents.x1,
+				 extents.y2 - extents.y1))
+	{
+	    xglAddCurrentBitDamage (pDst->pDrawable);
+	    return remaining;
+	}
+
+	remaining = ~0;
+	*pOp = opSave;
+	pOp->noCache = TRUE;
+    }
+    else
+    {
+	if (remaining)
+	{
+	    *pOp = opSave;
+	    pOp->noCache = TRUE;
+	}
+    }
+
+    return remaining;
+}
+
+static Bool
+xglGlyphExtents (PicturePtr   pDst,
+		 int	      nlist,
+		 GlyphListPtr list,
+		 GlyphPtr     *glyphs,
+		 BoxPtr	      extents)
+{
+    GlyphPtr glyph;
+    BoxRec   line;
+    int	     x1, x2, y1, y2;
+    int	     n;
+    int	     x;
+    int	     y;
+    Bool     overlap = FALSE;
+
+    x = 0;
+    y = 0;
+
+    extents->x1 = MAXSHORT;
+    extents->x2 = MINSHORT;
+    extents->y1 = MAXSHORT;
+    extents->y2 = MINSHORT;
+
+    while (!list->len)
+    {
+	if (--nlist)
+	{
+	    x += list->xOff;
+	    y += list->yOff;
+	    list++;
+	}
+	else
+	{
+	    return FALSE;
+	}
+    }
+
+    glyph = *glyphs;
+    x1 = (x + list->xOff) - glyph->info.x;
+    if (x1 < MINSHORT)
+	x1 = MINSHORT;
+    y1 = (y  + list->yOff) - glyph->info.y;
+    if (y1 < MINSHORT)
+	y1 = MINSHORT;
+
+    line.x1 = x1;
+    line.x2 = x1;
+    line.y1 = y1;
+    line.y2 = y1;
+
+    while (nlist--)
+    {
+	x += list->xOff;
+	y += list->yOff;
+	n = list->len;
+	list++;
+
+	while (n--)
+	{
+	    glyph = *glyphs++;
+	    x1 = x - glyph->info.x;
+	    if (x1 < MINSHORT)
+		x1 = MINSHORT;
+	    y1 = y - glyph->info.y;
+	    if (y1 < MINSHORT)
+		y1 = MINSHORT;
+	    x2 = x1 + glyph->info.width;
+	    if (x2 > MAXSHORT)
+		x2 = MAXSHORT;
+	    y2 = y1 + glyph->info.height;
+	    if (y2 > MAXSHORT)
+		y2 = MAXSHORT;
+
+	    if (x1 >= line.x2)
+	    {
+		line.x2 = x2;
+		if (y1 < line.y1)
+		    line.y1 = y1;
+		if (y2 > line.y2)
+		    line.y2 = y2;
+	    }
+	    else if (x2 <= line.x1)
+	    {
+		line.x1 = x1;
+		if (y1 < line.y1)
+		    line.y1 = y1;
+		if (y2 > line.y2)
+		    line.y2 = y2;
+	    }
+	    else
+	    {
+		if (line.y1 >= extents->y2)
+		{
+		    extents->y2 = line.y2;
+		    if (line.y1 < extents->y1)
+			extents->y1 = line.y1;
+		}
+		else if (line.y2 <= extents->y1)
+		{
+		    extents->y1 = line.y1;
+		    if (line.y2 > extents->y2)
+			extents->y2 = line.y2;
+		}
+		else
+		{
+		    if (line.y1 < extents->y1)
+			extents->y1 = line.y1;
+		    if (line.y2 > extents->y2)
+			extents->y2 = line.y2;
+
+		    overlap = TRUE;
+		}
+
+		if (line.x1 < extents->x1)
+		    extents->x1 = line.x1;
+		if (line.x2 > extents->x2)
+		    extents->x2 = line.x2;
+
+		line.x1 = x1;
+		line.y1 = y1;
+		line.x2 = x2;
+		line.y2 = y2;
+	    }
+
+	    x += glyph->info.xOff;
+	    y += glyph->info.yOff;
+	}
+    }
+
+    if (line.y1 >= extents->y2)
+    {
+	extents->y2 = line.y2;
+	if (line.y1 < extents->y1)
+	    extents->y1 = line.y1;
+    }
+    else if (line.y2 <= extents->y1)
+    {
+	extents->y1 = line.y1;
+	if (line.y2 > extents->y2)
+	    extents->y2 = line.y2;
+    }
+    else
+    {
+	if (line.y1 < extents->y1)
+	    extents->y1 = line.y1;
+	if (line.y2 > extents->y2)
+	    extents->y2 = line.y2;
+
+	overlap = TRUE;
+    }
+
+    if (line.x1 < extents->x1)
+	extents->x1 = line.x1;
+    if (line.x2 > extents->x2)
+	extents->x2 = line.x2;
+
+    xglPictureClipExtents (pDst, extents);
+
+    return overlap;
+}
+
+/* returns 0 if all glyph lists don't have the same format */
+static CARD32
+xglGlyphListFormatId (GlyphListPtr list,
+		      int	   nlist)
+{
+    CARD32 id = list->format->id;
+
+    nlist--;
+    list++;
+
+    while (nlist--)
+    {
+	if (list->format->id != id)
+	    return 0;
+
+	list++;
+    }
+
+    return id;
+}
+
+void
+xglGlyphs (CARD8	 op,
+	   PicturePtr	 pSrc,
+	   PicturePtr	 pDst,
+	   PictFormatPtr maskFormat,
+	   INT16	 xSrc,
+	   INT16	 ySrc,
+	   int		 nlist,
+	   GlyphListPtr	 list,
+	   GlyphPtr	 *glyphs)
+{
+    ScreenPtr	  pScreen = pDst->pDrawable->pScreen;
+    PicturePtr	  pMask = NULL, pSrcPicture, pDstPicture;
+    BoxRec	  extents;
+    xglGlyphOpRec glyphOp;
+    int		  xDst = list->xOff, yDst = list->yOff;
+    int		  overlap;
+    int		  target;
+
+    overlap = xglGlyphExtents (pDst, nlist, list, glyphs, &extents);
+    if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
+	return;
+
+    target = xglPrepareTarget (pDst->pDrawable);
+
+    if (op != PictOpAdd && maskFormat &&
+	(!target || overlap || op != PictOpOver ||
+	 xglGlyphListFormatId (list, nlist) != maskFormat->id))
+    {
+	PixmapPtr  pPixmap;
+	XID	   componentAlpha;
+	GCPtr	   pGC;
+	xRectangle rect;
+	int	   error;
+
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = extents.x2 - extents.x1;
+	rect.height = extents.y2 - extents.y1;
+
+	pPixmap = (*pScreen->CreatePixmap) (pScreen,
+					    rect.width, rect.height,
+					    maskFormat->depth);
+	if (!pPixmap)
+	    return;
+
+	componentAlpha = NEEDS_COMPONENT (maskFormat->format);
+	pMask = CreatePicture (0, &pPixmap->drawable,
+			       maskFormat, CPComponentAlpha, &componentAlpha,
+			       serverClient, &error);
+	if (!pMask)
+	{
+	    (*pScreen->DestroyPixmap) (pPixmap);
+	    return;
+	}
+
+	if (!target)
+	{
+	    /* make sure we don't do accelerated drawing to mask */
+	    xglSetPixmapVisual (pPixmap, NULL);
+	}
+
+	ValidatePicture (pMask);
+	pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+	ValidateGC (&pPixmap->drawable, pGC);
+	(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &rect);
+	FreeScratchGC (pGC);
+
+	(*pScreen->DestroyPixmap) (pPixmap);
+
+	target = xglPrepareTarget (pMask->pDrawable);
+
+	glyphOp.xOff = -extents.x1;
+	glyphOp.yOff = -extents.y1;
+	pSrcPicture = NULL;
+	pDstPicture = pMask;
+    }
+    else
+    {
+	glyphOp.xOff = 0;
+	glyphOp.yOff = 0;
+	pSrcPicture = pSrc;
+	pDstPicture = pDst;
+    }
+
+    glyphOp.ppGlyphs = glyphs;
+    glyphOp.noCache  = !target;
+
+    while (nlist--)
+    {
+	glyphOp.xOff   += list->xOff;
+	glyphOp.yOff   += list->yOff;
+	glyphOp.listLen = list->len;
+	glyphOp.nGlyphs = list->len;
+	glyphOp.pLists  = list++;
+
+	for (; nlist; nlist--, list++)
+	{
+	    if (list->format->id != glyphOp.pLists->format->id)
+		break;
+
+	    glyphOp.nGlyphs += list->len;
+	}
+
+	while (glyphOp.nGlyphs)
+	{
+	    if (glyphOp.noCache || xglCachedGlyphs (op,
+						    pSrcPicture,
+						    pDstPicture,
+						    xSrc - xDst, ySrc - yDst,
+						    &glyphOp))
+		xglUncachedGlyphs (op,
+				   pSrcPicture,
+				   pDstPicture,
+				   xSrc - xDst, ySrc - yDst,
+				   &glyphOp);
+	}
+    }
+
+    if (pMask)
+    {
+	CompositePicture (op, pSrc, pMask, pDst,
+			  xSrc + extents.x1 - xDst,
+			  ySrc + extents.y1 - yDst,
+			  0, 0,
+			  extents.x1, extents.y1,
+			  extents.x2 - extents.x1,
+			  extents.y2 - extents.y1);
+
+	FreePicture ((pointer) pMask, (XID) 0);
+    }
+}
+
+#endif
diff --git a/xgl/xglpict.c b/xgl/xglpict.c
new file mode 100644
index 0000000..36e6603
--- /dev/null
+++ b/xgl/xglpict.c
@@ -0,0 +1,787 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+#include "fb.h"
+
+#ifdef RENDER
+
+#include "fbpict.h"
+
+#define XGL_PICTURE_FALLBACK_PROLOGUE(pPicture, func) \
+    xglSyncDamageBoxBits (pPicture->pDrawable);	      \
+    XGL_PICTURE_SCREEN_UNWRAP (func)
+
+#define XGL_PICTURE_FALLBACK_EPILOGUE(pPicture, func, xglfunc) \
+    XGL_PICTURE_SCREEN_WRAP (func, xglfunc);		       \
+    xglAddCurrentSurfaceDamage (pPicture->pDrawable)
+
+void
+xglComposite (CARD8	 op,
+	      PicturePtr pSrc,
+	      PicturePtr pMask,
+	      PicturePtr pDst,
+	      INT16	 xSrc,
+	      INT16	 ySrc,
+	      INT16	 xMask,
+	      INT16	 yMask,
+	      INT16	 xDst,
+	      INT16	 yDst,
+	      CARD16	 width,
+	      CARD16	 height)
+{
+    PictureScreenPtr pPictureScreen;
+    ScreenPtr	     pScreen = pDst->pDrawable->pScreen;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    if (xglCompositeGeneral (op,
+			     pSrc, pMask, pDst, NULL,
+			     xSrc, ySrc,
+			     xMask, yMask,
+			     xDst + pDst->pDrawable->x,
+			     yDst + pDst->pDrawable->y,
+			     width, height))
+    {
+	xglAddCurrentBitDamage (pDst->pDrawable);
+	return;
+    }
+
+    pPictureScreen = GetPictureScreen (pScreen);
+
+    if (pSrc->pDrawable)
+    {
+	if (!xglSyncBits (pSrc->pDrawable, NullBox))
+	    FatalError (XGL_SW_FAILURE_STRING);
+    }
+
+    if (pMask && pMask->pDrawable)
+    {
+	if (!xglSyncBits (pMask->pDrawable, NullBox))
+	    FatalError (XGL_SW_FAILURE_STRING);
+    }
+
+    if (op == PictOpSrc)
+    {
+	XGL_DRAWABLE_PIXMAP (pDst->pDrawable);
+
+	if (!xglMapPixmapBits (pPixmap))
+	    FatalError (XGL_SW_FAILURE_STRING);
+    } else
+	xglSyncDamageBoxBits (pDst->pDrawable);
+
+    XGL_PICTURE_SCREEN_UNWRAP (Composite);
+    (*pPictureScreen->Composite) (op, pSrc, pMask, pDst,
+				  xSrc, ySrc, xMask, yMask, xDst, yDst,
+				  width, height);
+    XGL_PICTURE_SCREEN_WRAP (Composite, xglComposite);
+
+    if (op == PictOpSrc)
+    {
+	RegionRec region;
+
+	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;
+
+	xglAddSurfaceDamage (pDst->pDrawable, &region);
+	REGION_UNINIT (pDst->pDrawable->pScreen, &region);
+    } else
+	xglAddCurrentSurfaceDamage (pDst->pDrawable);
+}
+
+void
+xglAddTriangles (PicturePtr pDst,
+		 INT16	    xOff,
+		 INT16	    yOff,
+		 int	    ntri,
+		 xTriangle  *tris)
+{
+    PictureScreenPtr pPictureScreen;
+    ScreenPtr	     pScreen = pDst->pDrawable->pScreen;
+
+    XGL_SCREEN_PRIV (pScreen);
+    XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
+
+    pPictureScreen = GetPictureScreen (pScreen);
+
+    pPixmapPriv->damageBox.x1 = 0;
+    pPixmapPriv->damageBox.y1 = 0;
+    pPixmapPriv->damageBox.x2 = pDst->pDrawable->width;
+    pPixmapPriv->damageBox.y2 = pDst->pDrawable->height;
+
+    XGL_PICTURE_FALLBACK_PROLOGUE (pDst, AddTriangles);
+    (*pPictureScreen->AddTriangles) (pDst, xOff, yOff, ntri, tris);
+    XGL_PICTURE_FALLBACK_EPILOGUE (pDst, AddTriangles, xglAddTriangles);
+}
+
+
+void
+xglChangePicture (PicturePtr pPicture,
+		  Mask	     mask)
+{
+    PictureScreenPtr pPictureScreen;
+    ScreenPtr	     pScreen = pPicture->pDrawable->pScreen;
+
+    XGL_SCREEN_PRIV (pScreen);
+    XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
+
+    pPictureScreen = GetPictureScreen (pScreen);
+
+    if (pPicture->stateChanges & CPRepeat)
+	pPixmapPriv->pictureMask |= xglPCFillMask;
+
+    if (pPicture->stateChanges & CPComponentAlpha)
+	pPixmapPriv->pictureMask |= xglPCComponentAlphaMask;
+
+    if (pPicture->stateChanges & CPDither)
+	pPixmapPriv->pictureMask |= xglPCDitherMask;
+
+    XGL_PICTURE_SCREEN_UNWRAP (ChangePicture);
+    (*pPictureScreen->ChangePicture) (pPicture, mask);
+    XGL_PICTURE_SCREEN_WRAP (ChangePicture, xglChangePicture);
+}
+
+int
+xglChangePictureTransform (PicturePtr    pPicture,
+			   PictTransform *transform)
+{
+    PictureScreenPtr pPictureScreen;
+    ScreenPtr	     pScreen = pPicture->pDrawable->pScreen;
+    int		     ret;
+
+    XGL_SCREEN_PRIV (pScreen);
+    XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
+
+    pPictureScreen = GetPictureScreen (pScreen);
+
+    if (transform != pPicture->transform ||
+	(transform && memcmp (transform, &pPicture->transform,
+			      sizeof (PictTransform))))
+	pPixmapPriv->pictureMask |= xglPCTransformMask;
+
+    XGL_PICTURE_SCREEN_UNWRAP (ChangePictureTransform);
+    ret = (*pPictureScreen->ChangePictureTransform) (pPicture, transform);
+    XGL_PICTURE_SCREEN_WRAP (ChangePictureTransform,
+			     xglChangePictureTransform);
+
+    return ret;
+}
+
+int
+xglChangePictureFilter (PicturePtr pPicture,
+			int	   filter,
+			xFixed	   *params,
+			int	   nparams)
+{
+    PictureScreenPtr pPictureScreen;
+    ScreenPtr	     pScreen = pPicture->pDrawable->pScreen;
+    int		     ret;
+
+    XGL_SCREEN_PRIV (pScreen);
+    XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
+
+    pPictureScreen = GetPictureScreen (pScreen);
+
+    pPixmapPriv->pictureMask |= xglPCFilterMask;
+
+    XGL_PICTURE_SCREEN_UNWRAP (ChangePictureFilter);
+    ret = (*pPictureScreen->ChangePictureFilter) (pPicture, filter,
+						  params, nparams);
+    XGL_PICTURE_SCREEN_WRAP (ChangePictureFilter, xglChangePictureFilter);
+
+    return ret;
+}
+
+static void
+xglDestroyDevicePicture (PicturePtr pPicture)
+{
+    if (pPicture->pSourcePict->source.devPrivate.ptr)
+	glitz_surface_destroy (pPicture->pSourcePict->source.devPrivate.ptr);
+}
+
+PicturePtr
+xglCreateDevicePicture (pointer data)
+{
+    PicturePtr pPicture;
+    int	       error;
+
+    pPicture = CreateDevicePicture (0, &error);
+    if (!pPicture)
+	return 0;
+
+    pPicture->pSourcePict->source.devPrivate.ptr = data;
+    pPicture->pSourcePict->source.Destroy	 = xglDestroyDevicePicture;
+
+    return pPicture;
+}
+
+static int fillMode[] = {
+    GLITZ_FILL_TRANSPARENT, /* RepeatNone    */
+    GLITZ_FILL_REPEAT,      /* RepeatNormal  */
+    GLITZ_FILL_NEAREST,     /* RepeatPad     */
+    GLITZ_FILL_REFLECT      /* RepeatReflect */
+};
+
+static void
+xglUpdatePicture (PicturePtr pPicture)
+{
+    glitz_surface_t *surface;
+
+    XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
+
+    surface = pPixmapPriv->surface;
+
+    if (pPixmapPriv->pictureMask & xglPCFillMask)
+    {
+	glitz_surface_set_fill (surface, fillMode[pPicture->repeatType]);
+    }
+
+    if (pPixmapPriv->pictureMask & xglPCFilterMask)
+    {
+	switch (pPicture->filter) {
+	case PictFilterNearest:
+	case PictFilterFast:
+	    glitz_surface_set_filter (surface, GLITZ_FILTER_NEAREST, NULL, 0);
+	    break;
+	case PictFilterGood:
+	case PictFilterBest:
+	case PictFilterBilinear:
+	    glitz_surface_set_filter (surface, GLITZ_FILTER_BILINEAR, NULL, 0);
+	    break;
+	case PictFilterConvolution:
+	    glitz_surface_set_filter (surface, GLITZ_FILTER_CONVOLUTION,
+				      (glitz_fixed16_16_t *)
+				      pPicture->filter_params,
+				      pPicture->filter_nparams);
+	    break;
+	}
+    }
+
+    if (pPixmapPriv->pictureMask & xglPCTransformMask)
+    {
+	glitz_surface_set_transform (surface, (glitz_transform_t *)
+				     pPicture->transform);
+    }
+
+    if (pPixmapPriv->pictureMask & xglPCComponentAlphaMask)
+    {
+	glitz_surface_set_component_alpha (surface, pPicture->componentAlpha);
+    }
+
+    if (pPixmapPriv->pictureMask & xglPCDitherMask)
+    {
+	glitz_surface_set_dither (surface, pPicture->dither);
+    }
+
+    pPixmapPriv->pictureMask &= ~XGL_PICTURE_CHANGES (~0);
+}
+
+#define N_STACK_PARAM 256
+
+static int gradientNParam[] = {
+    0, /* SourcePictTypeSolidFill */
+    4, /* SourcePictTypeLinear    */
+    6, /* SourcePictTypeRadial    */
+    4, /* SourcePictTypeConical   */
+};
+
+Bool
+xglSyncPicture (ScreenPtr  pScreen,
+		PicturePtr pPicture,
+		INT16	   x,
+		INT16	   y,
+		CARD16	   width,
+		CARD16	   height,
+		INT16	   *xOff,
+		INT16	   *yOff)
+{
+    xglPixmapPtr pPixmapPriv;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    *xOff = *yOff = 0;
+
+    if (pPicture->pSourcePict)
+    {
+	if (pPicture->pSourcePict->source.devPrivate.ptr)
+	    return TRUE;
+
+	if (pPicture->pDrawable)
+	{
+	    (*pScreen->DestroyPixmap) ((PixmapPtr) pPicture->pDrawable);
+	    pPicture->pDrawable = (DrawablePtr) 0;
+	}
+
+	switch (pPicture->pSourcePict->source.type) {
+	case SourcePictTypeSolidFill:
+	    x = y = 0;
+	    width = height = 1;
+	    break;
+	case SourcePictTypeLinear:
+	case SourcePictTypeRadial: {
+	    glitz_fixed16_16_t		stackParam[N_STACK_PARAM];
+	    glitz_fixed16_16_t		*param;
+	    int				nParam, nStop, size, i;
+	    CARD32			*pixel;
+	    PictGradientStopPtr		pStop;
+	    glitz_buffer_t		*buffer;
+	    glitz_format_t		*format;
+	    glitz_surface_t		*surface;
+	    static glitz_pixel_format_t pixelFormat = {
+		GLITZ_FOURCC_RGB,
+		{
+		    32,
+		    0xff000000,
+		    0x00ff0000,
+		    0x0000ff00,
+		    0x000000ff
+		},
+		0, 0, 0,
+		GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
+	    };
+
+	    if (!(pScreenPriv->features & GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK))
+		break;
+
+	    format = glitz_find_standard_format (pScreenPriv->drawable,
+						 GLITZ_STANDARD_ARGB32);
+	    if (!format)
+		break;
+
+	    nParam = gradientNParam[pPicture->pSourcePict->gradient.type];
+	    pStop  = pPicture->pSourcePict->gradient.stops;
+	    nStop  = pPicture->pSourcePict->gradient.nstops;
+
+	    size = nParam + nStop * 4;
+	    if (size > N_STACK_PARAM)
+	    {
+		param = malloc (sizeof (xFixed) * size);
+		if (!param)
+		    break;
+	    }
+	    else
+	    {
+		param = stackParam;
+	    }
+
+	    pixel = (CARD32 *) (param + nParam + nStop * 3);
+
+	    buffer = glitz_buffer_create_for_data (pixel);
+	    if (!buffer)
+	    {
+		if (size > N_STACK_PARAM)
+		    free (param);
+
+		break;
+	    }
+
+	    surface = glitz_surface_create (pScreenPriv->drawable,
+					    format, nStop, 1, 0, NULL);
+	    if (!surface)
+	    {
+		glitz_buffer_destroy (buffer);
+		if (size > N_STACK_PARAM)
+		    free (param);
+
+		break;
+	    }
+
+	    for (i = 0; i < nStop; i++)
+	    {
+		pixel[i] = pStop[i].color;
+
+		param[nParam + 3 * i + 0] = pStop[i].x;
+		param[nParam + 3 * i + 1] = i << 16;
+		param[nParam + 3 * i + 2] = 0;
+	    }
+
+	    glitz_set_pixels (surface, 0, 0, nStop, 1, &pixelFormat, buffer);
+
+	    glitz_buffer_destroy (buffer);
+
+	    switch (pPicture->pSourcePict->source.type) {
+	    case SourcePictTypeLinear:
+		param[0] = pPicture->pSourcePict->linear.p1.x;
+		param[1] = pPicture->pSourcePict->linear.p1.y;
+		param[2] = pPicture->pSourcePict->linear.p2.x;
+		param[3] = pPicture->pSourcePict->linear.p2.y;
+
+		glitz_surface_set_filter (surface,
+					  GLITZ_FILTER_LINEAR_GRADIENT,
+					  param, nParam + nStop * 3);
+		break;
+	    case SourcePictTypeRadial:
+		param[0] = pPicture->pSourcePict->radial.c1.x;
+		param[1] = pPicture->pSourcePict->radial.c1.y;
+		param[2] = pPicture->pSourcePict->radial.c1.radius;
+		param[3] = pPicture->pSourcePict->radial.c2.x;
+		param[4] = pPicture->pSourcePict->radial.c2.y;
+		param[5] = pPicture->pSourcePict->radial.c2.radius;
+
+		glitz_surface_set_filter (surface,
+					  GLITZ_FILTER_RADIAL_GRADIENT,
+					  param, nParam + nStop * 3);
+		break;
+	    }
+
+	    glitz_surface_set_fill (surface, fillMode[pPicture->repeatType]);
+	    glitz_surface_set_transform (surface, (glitz_transform_t *)
+					 pPicture->transform);
+
+	    pPicture->pSourcePict->gradient.devPrivate.ptr = surface;
+	    pPicture->pSourcePict->gradient.Destroy = xglDestroyDevicePicture;
+
+	    if (size > N_STACK_PARAM)
+		free (param);
+
+	    return TRUE;
+	} break;
+	case SourcePictTypeConical:
+	default:
+	    break;
+	}
+
+	if (!pPicture->pDrawable)
+	{
+	    PictFormatPtr pFormat;
+	    PixmapPtr	  pPixmap;
+	    PicturePtr	  pTmp;
+	    RegionRec	  region;
+	    BoxRec	  box;
+	    int		  error;
+
+	    pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
+	    if (!pFormat)
+		return FALSE;
+
+	    pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
+						pFormat->depth);
+	    if (!pPixmap)
+		return FALSE;
+
+	    pTmp = CreatePicture (0, &pPixmap->drawable, pFormat, 0, NULL,
+				  serverClient, &error);
+	    if (!pTmp)
+	    {
+		(*pScreen->DestroyPixmap) (pPixmap);
+		return FALSE;
+	    }
+
+	    ValidatePicture (pTmp);
+
+	    if (!xglSyncBits (pTmp->pDrawable, NullBox))
+		FatalError (XGL_SW_FAILURE_STRING);
+
+	    fbCompositeGeneral (PictOpSrc,
+				pPicture, 0, pTmp,
+				x, y, 0, 0, 0, 0,
+				width, height);
+
+	    FreePicture ((pointer) pTmp, (XID) 0);
+
+	    box.x1 = 0;
+	    box.y1 = 0;
+	    box.x2 = width;
+	    box.y2 = height;
+
+	    REGION_INIT (pScreen, &region, &box, 1);
+	    xglAddSurfaceDamage (&pPixmap->drawable, &region);
+	    REGION_UNINIT (pDrawable->pScreen, &region);
+
+	    pPicture->pDrawable = &pPixmap->drawable;
+
+	    *xOff = x;
+	    *yOff = y;
+
+	    XGL_GET_PIXMAP_PRIV (pPixmap)->pictureMask &=
+		~(xglPCFillMask | xglPCFilterMask | xglPCTransformMask);
+	}
+    }
+
+#ifdef XV
+    switch (pPicture->format) {
+    case PICT_yuy2:
+	xglSetPixmapVisual ((PixmapPtr) pPicture->pDrawable,
+			    &pScreenPriv->pXvVisual[XGL_XV_FORMAT_YUY2]);
+	break;
+    case PICT_yv12:
+	xglSetPixmapVisual ((PixmapPtr) pPicture->pDrawable,
+			    &pScreenPriv->pXvVisual[XGL_XV_FORMAT_YV12]);
+    default:
+	break;
+    }
+#endif
+
+    if (!xglSyncSurface (pPicture->pDrawable))
+	return FALSE;
+
+    pPixmapPriv = XGL_GET_PIXMAP_PRIV ((PixmapPtr) pPicture->pDrawable);
+    if (XGL_PICTURE_CHANGES (pPixmapPriv->pictureMask))
+	xglUpdatePicture (pPicture);
+
+    return TRUE;
+}
+
+static int
+xglVisualDepth (ScreenPtr pScreen, VisualPtr pVisual)
+{
+    DepthPtr pDepth;
+    int	     d, v;
+
+    for (d = 0; d < pScreen->numDepths; d++)
+    {
+	pDepth = &pScreen->allowedDepths[d];
+	for (v = 0; v < pDepth->numVids; v++)
+	    if (pDepth->vids[v] == pVisual->vid)
+		return pDepth->depth;
+    }
+
+    return 0;
+}
+
+typedef struct _xglformatInit {
+    CARD32 format;
+    CARD8  depth;
+} xglFormatInitRec, *xglFormatInitPtr;
+
+static int
+xglAddFormat (xglFormatInitPtr formats,
+	      int	       nformat,
+	      CARD32	       format,
+	      CARD8	       depth)
+{
+    int	n;
+
+    for (n = 0; n < nformat; n++)
+	if (formats[n].format == format && formats[n].depth == depth)
+	    return nformat;
+
+    formats[nformat].format = format;
+    formats[nformat].depth = depth;
+
+    return ++nformat;
+}
+
+#define Mask(n)	((n) == 32 ? 0xffffffff : ((1 << (n)) - 1))
+
+Bool
+xglPictureInit (ScreenPtr pScreen)
+{
+    int		     f, nformats = 0;
+    PictFormatPtr    pFormats;
+    xglFormatInitRec formats[64];
+    CARD32	     format;
+    CARD8	     depth;
+    VisualPtr	     pVisual;
+    int		     v;
+    int		     bpp;
+    int		     r, g, b;
+    int		     d;
+    DepthPtr	     pDepth;
+
+    /* formats required by protocol */
+    formats[nformats].format = PICT_a1;
+    formats[nformats].depth = 1;
+    nformats++;
+    formats[nformats].format = PICT_a4;
+    formats[nformats].depth = 4;
+    nformats++;
+    formats[nformats].format = PICT_a8;
+    formats[nformats].depth = 8;
+    nformats++;
+    formats[nformats].format = PICT_a8r8g8b8;
+    formats[nformats].depth = 32;
+    nformats++;
+
+    /* now look through the depths and visuals adding other formats */
+    for (v = 0; v < pScreen->numVisuals; v++)
+    {
+	pVisual = &pScreen->visuals[v];
+	depth = xglVisualDepth (pScreen, pVisual);
+	if (!depth)
+	    continue;
+
+	bpp = BitsPerPixel (depth);
+	switch (pVisual->class) {
+	case DirectColor:
+	case TrueColor:
+	    r = Ones (pVisual->redMask);
+	    g = Ones (pVisual->greenMask);
+	    b = Ones (pVisual->blueMask);
+	    if (pVisual->offsetBlue == 0 &&
+		pVisual->offsetGreen == b &&
+		pVisual->offsetRed == b + g)
+	    {
+		format = PICT_FORMAT (bpp, PICT_TYPE_ARGB, 0, r, g, b);
+		nformats = xglAddFormat (formats, nformats, format, depth);
+	    }
+	    break;
+	case StaticColor:
+	case PseudoColor:
+	case StaticGray:
+	case GrayScale:
+	    break;
+	}
+    }
+
+    /* walk supported depths and add missing Direct formats */
+    for (d = 0; d < pScreen->numDepths; d++)
+    {
+	pDepth = &pScreen->allowedDepths[d];
+	bpp = BitsPerPixel (pDepth->depth);
+	format = 0;
+	switch (bpp) {
+	case 16:
+	    if (pDepth->depth == 15)
+		nformats = xglAddFormat (formats, nformats,
+					 PICT_x1r5g5b5, pDepth->depth);
+	    if (pDepth->depth == 16)
+		nformats = xglAddFormat (formats, nformats,
+					 PICT_r5g6b5, pDepth->depth);
+	    break;
+	case 24:
+	    if (pDepth->depth == 24)
+		nformats = xglAddFormat (formats, nformats,
+					 PICT_r8g8b8, pDepth->depth);
+	    break;
+	case 32:
+	    if (pDepth->depth == 24)
+		nformats = xglAddFormat (formats, nformats,
+					 PICT_x8r8g8b8, pDepth->depth);
+	    break;
+	}
+    }
+
+    /* add YUV formats */
+    nformats = xglAddFormat (formats, nformats, PICT_yuy2, 16);
+    nformats = xglAddFormat (formats, nformats, PICT_yv12, 12);
+
+    pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec));
+    if (!pFormats)
+	return 0;
+
+    memset (pFormats, '\0', nformats * sizeof (PictFormatRec));
+    for (f = 0; f < nformats; f++)
+    {
+	pFormats[f].id = FakeClientID (0);
+	pFormats[f].depth = formats[f].depth;
+	format = formats[f].format;
+	pFormats[f].format = format;
+	switch (PICT_FORMAT_TYPE (format)) {
+	case PICT_TYPE_ARGB:
+	    pFormats[f].type = PictTypeDirect;
+	    pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format));
+	    if (pFormats[f].direct.alphaMask)
+		pFormats[f].direct.alpha = (PICT_FORMAT_R (format) +
+					    PICT_FORMAT_G (format) +
+					    PICT_FORMAT_B (format));
+
+	    pFormats[f].direct.redMask = Mask (PICT_FORMAT_R (format));
+	    pFormats[f].direct.red = (PICT_FORMAT_G (format) +
+				      PICT_FORMAT_B (format));
+
+	    pFormats[f].direct.greenMask = Mask (PICT_FORMAT_G (format));
+	    pFormats[f].direct.green = PICT_FORMAT_B (format);
+
+	    pFormats[f].direct.blueMask = Mask (PICT_FORMAT_B (format));
+	    pFormats[f].direct.blue = 0;
+	    break;
+	case PICT_TYPE_A:
+	    pFormats[f].type = PictTypeDirect;
+	    pFormats[f].direct.alpha = 0;
+	    pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format));
+	    break;
+	case PICT_TYPE_COLOR:
+	case PICT_TYPE_GRAY:
+	    pFormats[f].type = PictTypeDirect;
+	    break;
+	case PICT_TYPE_YUY2:
+	case PICT_TYPE_YV12:
+	    pFormats[f].type = PictTypeOther;
+	    break;
+	}
+    }
+
+    if (!fbPictureInit (pScreen, pFormats, nformats))
+	return FALSE;
+
+    return TRUE;
+}
+
+void
+xglPictureClipExtents (PicturePtr pPicture,
+		       BoxPtr     extents)
+{
+    if (pPicture->clientClipType != CT_NONE)
+    {
+	BoxPtr clip = REGION_EXTENTS (pPicture->pDrawable->pScreen,
+				      (RegionPtr) pPicture->clientClip);
+
+	if (extents->x1 < pPicture->clipOrigin.x + clip->x1)
+	    extents->x1 = pPicture->clipOrigin.x + clip->x1;
+
+	if (extents->y1 < pPicture->clipOrigin.y + clip->y1)
+	    extents->y1 = pPicture->clipOrigin.y + clip->y1;
+
+	if (extents->x2 > pPicture->clipOrigin.x + clip->x2)
+	    extents->x2 = pPicture->clipOrigin.x + clip->x2;
+
+	if (extents->y2 > pPicture->clipOrigin.y + clip->y2)
+	    extents->y2 = pPicture->clipOrigin.y + clip->y2;
+    }
+    else
+    {
+	if (extents->x1 < 0)
+	    extents->x1 = 0;
+
+	if (extents->y1 < 0)
+	    extents->y1 = 0;
+
+	if (extents->x2 > pPicture->pDrawable->width)
+	    extents->x2 = pPicture->pDrawable->width;
+
+	if (extents->y2 > pPicture->pDrawable->height)
+	    extents->y2 = pPicture->pDrawable->height;
+    }
+}
+
+#endif
diff --git a/xgl/xglpixmap.c b/xgl/xglpixmap.c
new file mode 100644
index 0000000..56c7ecd
--- /dev/null
+++ b/xgl/xglpixmap.c
@@ -0,0 +1,747 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+#include "fb.h"
+
+static glitz_buffer_hint_t xglPixmapUsageHints[] = {
+    (glitz_buffer_hint_t) 0,	    /* reserved for system memory */
+    GLITZ_BUFFER_HINT_STREAM_DRAW,
+    GLITZ_BUFFER_HINT_STREAM_READ,
+    GLITZ_BUFFER_HINT_STREAM_COPY,
+    GLITZ_BUFFER_HINT_STATIC_DRAW,
+    GLITZ_BUFFER_HINT_STATIC_READ,
+    GLITZ_BUFFER_HINT_STATIC_COPY,
+    GLITZ_BUFFER_HINT_DYNAMIC_DRAW,
+    GLITZ_BUFFER_HINT_DYNAMIC_READ,
+    GLITZ_BUFFER_HINT_DYNAMIC_COPY
+};
+
+#define NUM_XGL_PIXMAP_USAGE_HINTS				     \
+    (sizeof (xglPixmapUsageHints) / sizeof (xglPixmapUsageHints[0]))
+
+#define XGL_PIXMAP_USAGE_HINT(hint) (xglPixmapUsageHints[hint])
+
+static void
+xglPixmapDamageReport (DamagePtr pDamage,
+		       RegionPtr pRegion,
+		       void	 *closure)
+{
+    PixmapPtr pPixmap = (PixmapPtr) closure;
+    BoxPtr    pExt;
+
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    pExt = REGION_EXTENTS (pPixmap->drawable.pScreen, pRegion);
+
+    if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
+    {
+	if (pExt->x1 < pPixmapPriv->damageBox.x1)
+	    pPixmapPriv->damageBox.x1 = pExt->x1;
+
+	if (pExt->y1 < pPixmapPriv->damageBox.y1)
+	    pPixmapPriv->damageBox.y1 = pExt->y1;
+
+	if (pExt->x2 > pPixmapPriv->damageBox.x2)
+	    pPixmapPriv->damageBox.x2 = pExt->x2;
+
+	if (pExt->y2 > pPixmapPriv->damageBox.y2)
+	    pPixmapPriv->damageBox.y2 = pExt->y2;
+    }
+    else
+	pPixmapPriv->damageBox = *pExt;
+}
+
+
+Bool
+xglPixmapCreateDamage (PixmapPtr pPixmap)
+{
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    pPixmapPriv->pDamage =
+	DamageCreate (xglPixmapDamageReport, (DamageDestroyFunc) 0,
+		      DamageReportRawRegion, TRUE,
+		      pPixmap->drawable.pScreen,
+		      (void *) pPixmap);
+    if (!pPixmapPriv->pDamage)
+	return FALSE;
+
+    DamageRegister (&pPixmap->drawable, pPixmapPriv->pDamage);
+
+    return TRUE;
+}
+
+void
+xglSetPixmapVisual (PixmapPtr    pPixmap,
+		    xglVisualPtr pVisual)
+{
+    xglVisualPtr pOldVisual;
+
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    pOldVisual = pPixmapPriv->pVisual;
+    if (pOldVisual && pVisual)
+    {
+	glitz_surface_t *surface;
+
+	if (pOldVisual->vid != pVisual->vid)
+	{
+	    surface = pPixmapPriv->surface;
+	    if (surface)
+	    {
+		glitz_drawable_t *drawable;
+
+		drawable = glitz_surface_get_attached_drawable (surface);
+		if (drawable)
+		{
+		    if (pOldVisual->format.drawable->id !=
+			pVisual->format.drawable->id)
+		    {
+			glitz_surface_detach (pPixmapPriv->surface);
+			pPixmapPriv->target = xglPixmapTargetOut;
+		    }
+		}
+
+		if (pOldVisual->format.surface->id != pVisual->format.surface->id)
+		{
+		    xglSyncBits (&pPixmap->drawable, NULL);
+		    glitz_surface_destroy (pPixmapPriv->surface);
+		    pPixmapPriv->surface = 0;
+		}
+	    }
+	}
+    }
+    else if (pOldVisual)
+    {
+	if (pPixmapPriv->surface)
+	{
+	    xglSyncBits (&pPixmap->drawable, NULL);
+	    glitz_surface_destroy (pPixmapPriv->surface);
+	    pPixmapPriv->surface = 0;
+	}
+	pPixmapPriv->target = xglPixmapTargetNo;
+    }
+
+    pPixmapPriv->pVisual = pVisual;
+
+    if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
+    {
+	if (!pPixmapPriv->pDamage)
+	{
+	    if (!xglPixmapCreateDamage (pPixmap))
+		FatalError (XGL_SW_FAILURE_STRING);
+	}
+    }
+}
+
+Bool
+xglPixmapSurfaceInit (PixmapPtr	    pPixmap,
+		      unsigned long features,
+		      int	    width,
+		      int	    height)
+{
+    BoxRec box;
+
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    pPixmapPriv->surface = NULL;
+    pPixmapPriv->drawable = NULL;
+    pPixmapPriv->acceleratedTile = FALSE;
+    pPixmapPriv->pictureMask = ~0;
+    pPixmapPriv->target = xglPixmapTargetNo;
+
+    box.x1 = 0;
+    box.y1 = 0;
+    box.x2 = width;
+    box.y2 = height;
+
+    REGION_INIT (pScreen, &pPixmapPriv->bitRegion, &box, 1);
+
+    pPixmapPriv->pVisual = xglFindVisualWithDepth (pPixmap->drawable.pScreen,
+						   pPixmap->drawable.depth);
+    if (pPixmapPriv->pVisual)
+    {
+	XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
+
+	/* general pixmap acceleration */
+	if (pPixmapPriv->pVisual->format.drawable &&
+	    pScreenPriv->accel.pixmap.enabled &&
+	    xglCheckPixmapSize (pPixmap, &pScreenPriv->accel.pixmap.size))
+	    pPixmapPriv->target = xglPixmapTargetOut;
+    }
+
+    if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
+    {
+	if (!pPixmapPriv->pDamage)
+	{
+	    if (!xglPixmapCreateDamage (pPixmap))
+		FatalError (XGL_SW_FAILURE_STRING);
+	}
+
+	if (width && height)
+	{
+	    if (width == 1 && height == 1)
+	    {
+		pPixmapPriv->acceleratedTile = TRUE;
+	    }
+	    else if (features & GLITZ_FEATURE_TEXTURE_BORDER_CLAMP_MASK)
+	    {
+		if ((features & GLITZ_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK) ||
+		    (POWER_OF_TWO (width) && POWER_OF_TWO (height)))
+		    pPixmapPriv->acceleratedTile = TRUE;
+	    }
+	}
+    }
+
+    return TRUE;
+}
+
+PixmapPtr
+xglCreatePixmap (ScreenPtr  pScreen,
+		 int	    width,
+		 int	    height,
+		 int	    depth)
+{
+    xglPixmapPtr pPixmapPriv;
+    PixmapPtr	 pPixmap;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    pPixmap = AllocatePixmap (pScreen, 0);
+    if (!pPixmap)
+	return NullPixmap;
+
+    pPixmap->drawable.type = DRAWABLE_PIXMAP;
+    pPixmap->drawable.class = 0;
+    pPixmap->drawable.pScreen = pScreen;
+    pPixmap->drawable.depth = depth;
+    pPixmap->drawable.bitsPerPixel = BitsPerPixel (depth);
+    pPixmap->drawable.id = 0;
+    pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+    pPixmap->drawable.x = 0;
+    pPixmap->drawable.y = 0;
+    pPixmap->drawable.width = width;
+    pPixmap->drawable.height = height;
+
+#ifdef COMPOSITE
+    pPixmap->screen_x = 0;
+    pPixmap->screen_y = 0;
+#endif
+
+    pPixmap->devKind = 0;
+    pPixmap->refcnt = 1;
+    pPixmap->devPrivate.ptr = 0;
+
+    pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
+
+    pPixmapPriv->pVisual = NULL;
+    pPixmapPriv->pDamage = NULL;
+
+    if (!xglPixmapSurfaceInit (pPixmap, pScreenPriv->features, width, height))
+	return NullPixmap;
+
+    pPixmapPriv->buffer = NULL;
+    pPixmapPriv->bits = (pointer) 0;
+    pPixmapPriv->stride = 0;
+    pPixmapPriv->pGeometry = NULL;
+    pPixmapPriv->allBits = TRUE;
+
+    pPixmapPriv->damageBox = miEmptyBox;
+
+    return pPixmap;
+}
+
+void
+xglFiniPixmap (PixmapPtr pPixmap)
+{
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    if (pPixmap->devPrivate.ptr)
+    {
+	if (pPixmapPriv->buffer)
+	    glitz_buffer_unmap (pPixmapPriv->buffer);
+    }
+
+    if (pPixmapPriv->pGeometry)
+	GEOMETRY_UNINIT (pPixmapPriv->pGeometry);
+
+    if (pPixmapPriv->buffer)
+	glitz_buffer_destroy (pPixmapPriv->buffer);
+
+    if (pPixmapPriv->bits)
+	xfree (pPixmapPriv->bits);
+
+    REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
+
+    if (pPixmapPriv->drawable)
+	glitz_drawable_destroy (pPixmapPriv->drawable);
+
+    if (pPixmapPriv->surface) {
+    	/* leaving because texture destruction can occur and flush primitives */
+        __glXleaveServer(FALSE);
+	glitz_surface_destroy (pPixmapPriv->surface);
+        __glXenterServer(FALSE);
+    }
+}
+
+Bool
+xglDestroyPixmap (PixmapPtr pPixmap)
+{
+    if (--pPixmap->refcnt)
+	return TRUE;
+
+    xglFiniPixmap (pPixmap);
+
+    xfree (pPixmap);
+
+    return TRUE;
+}
+
+Bool
+xglModifyPixmapHeader (PixmapPtr pPixmap,
+		       int	 width,
+		       int	 height,
+		       int	 depth,
+		       int	 bitsPerPixel,
+		       int	 devKind,
+		       pointer	 pPixData)
+{
+    xglScreenPtr pScreenPriv;
+    xglPixmapPtr pPixmapPriv;
+    int		 oldWidth, oldHeight;
+
+    if (!pPixmap)
+	return FALSE;
+
+    pScreenPriv = XGL_GET_SCREEN_PRIV (pPixmap->drawable.pScreen);
+    pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
+
+    oldWidth  = pPixmap->drawable.width;
+    oldHeight = pPixmap->drawable.height;
+
+    if ((width > 0) && (height > 0) && (depth > 0) && (bitsPerPixel > 0) &&
+	(devKind > 0) && pPixData)
+    {
+	pPixmap->drawable.depth = depth;
+	pPixmap->drawable.bitsPerPixel = bitsPerPixel;
+	pPixmap->drawable.id = 0;
+	pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+	pPixmap->drawable.x = 0;
+	pPixmap->drawable.y = 0;
+	pPixmap->drawable.width = width;
+	pPixmap->drawable.height = height;
+	pPixmapPriv->stride = devKind;
+	pPixmap->refcnt = 1;
+    }
+    else
+    {
+	if (width > 0)
+	    pPixmap->drawable.width = width;
+
+	if (height > 0)
+	    pPixmap->drawable.height = height;
+
+	if (depth > 0)
+	    pPixmap->drawable.depth = depth;
+
+	if (bitsPerPixel > 0)
+	    pPixmap->drawable.bitsPerPixel = bitsPerPixel;
+	else if ((bitsPerPixel < 0) && (depth > 0))
+	    pPixmap->drawable.bitsPerPixel = BitsPerPixel (depth);
+
+	if (devKind > 0)
+	    pPixmapPriv->stride = devKind;
+	else if ((devKind < 0) && ((width > 0) || (depth > 0)))
+	    pPixmapPriv->stride = PixmapBytePad (pPixmap->drawable.width,
+						 pPixmap->drawable.depth);
+    }
+
+    if (pPixmap->drawable.width  != oldWidth ||
+	pPixmap->drawable.height != oldHeight)
+    {
+	pPixmapPriv->pVisual = NULL;
+	pPixmapPriv->target  = xglPixmapTargetNo;
+
+	if (pPixmapPriv->drawable)
+	    glitz_drawable_destroy (pPixmapPriv->drawable);
+
+	if (pPixmapPriv->surface)
+	    glitz_surface_destroy (pPixmapPriv->surface);
+
+	REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
+
+	if (!xglPixmapSurfaceInit (pPixmap,
+				   pScreenPriv->features,
+				   pPixmap->drawable.width,
+				   pPixmap->drawable.height))
+	    return FALSE;
+    }
+
+    if (pPixData)
+    {
+	BoxRec box;
+
+	if (pPixmap->devPrivate.ptr)
+	{
+	    if (pPixmapPriv->buffer)
+		glitz_buffer_unmap (pPixmapPriv->buffer);
+
+	    pPixmap->devPrivate.ptr = 0;
+	}
+
+	if (pPixmapPriv->pGeometry)
+	{
+	    GEOMETRY_UNINIT (pPixmapPriv->pGeometry);
+	    pPixmapPriv->pGeometry = NULL;
+	}
+
+	if (pPixmapPriv->buffer)
+	    glitz_buffer_destroy (pPixmapPriv->buffer);
+
+	if (pPixmapPriv->bits)
+	    xfree (pPixmapPriv->bits);
+
+	pPixmapPriv->bits = (pointer) 0;
+	pPixmapPriv->buffer = glitz_buffer_create_for_data (pPixData);
+	if (!pPixmapPriv->buffer)
+	    return FALSE;
+
+	pPixmapPriv->allBits = TRUE;
+
+	box.x1 = 0;
+	box.y1 = 0;
+	box.x2 = pPixmap->drawable.width;
+	box.y2 = pPixmap->drawable.height;
+
+	REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
+	REGION_INIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion,
+		     &box, 1);
+
+	if (pPixmapPriv->pDamage)
+	{
+	    RegionPtr pRegion;
+
+	    pRegion = DamageRegion (pPixmapPriv->pDamage);
+
+	    REGION_UNINIT (pPixmap->drawable.pScreen, pRegion);
+	    REGION_INIT (pPixmap->drawable.pScreen, pRegion, NullBox, 0);
+	    REGION_SUBTRACT (pPixmap->drawable.pScreen, pRegion,
+			     &pPixmapPriv->bitRegion, pRegion);
+
+	}
+    }
+
+    /*
+     * Screen pixmap
+     */
+    if (!pScreenPriv->pScreenPixmap || pScreenPriv->pScreenPixmap == pPixmap)
+    {
+	if (!pPixmapPriv->drawable)
+	{
+	    glitz_drawable_reference (pScreenPriv->drawable);
+	    pPixmapPriv->drawable = pScreenPriv->drawable;
+	}
+
+	if (!pPixmapPriv->surface)
+	{
+	    glitz_surface_reference (pScreenPriv->surface);
+	    pPixmapPriv->surface = pScreenPriv->surface;
+	}
+
+	pPixmapPriv->pVisual = pScreenPriv->rootVisual;
+	pPixmapPriv->target  = xglPixmapTargetIn;
+
+	if (!pScreenPriv->pScreenPixmap)
+	    pScreenPriv->pScreenPixmap = pPixmap;
+    }
+
+    return TRUE;
+}
+
+RegionPtr
+xglPixmapToRegion (PixmapPtr pPixmap)
+{
+    ScreenPtr pScreen = pPixmap->drawable.pScreen;
+    RegionPtr pRegion;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    if (!xglSyncBits (&pPixmap->drawable, NullBox))
+	FatalError (XGL_SW_FAILURE_STRING);
+
+    XGL_SCREEN_UNWRAP (BitmapToRegion);
+    pRegion = (*pScreen->BitmapToRegion) (pPixmap);
+    XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion);
+
+    return pRegion;
+}
+
+xglGeometryPtr
+xglPixmapToGeometry (PixmapPtr pPixmap,
+		     int       xOff,
+		     int       yOff)
+{
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    if (pPixmap->devPrivate.ptr)
+	xglUnmapPixmapBits (pPixmap);
+
+    if (!pPixmapPriv->pGeometry)
+    {
+	xglGeometryPtr pGeometry;
+
+	if (!pPixmapPriv->buffer)
+	{
+	    if (!xglAllocatePixmapBits (pPixmap,
+					XGL_PIXMAP_USAGE_HINT_DEFAULT))
+		return NULL;
+	}
+
+	pGeometry = xalloc (sizeof (xglGeometryRec));
+	if (!pGeometry)
+	    return NULL;
+
+	GEOMETRY_INIT (pPixmap->drawable.pScreen, pGeometry,
+		       GLITZ_GEOMETRY_TYPE_BITMAP,
+		       GEOMETRY_USAGE_DYNAMIC, 0);
+
+	GEOMETRY_SET_BUFFER (pGeometry, pPixmapPriv->buffer);
+
+	if (pPixmapPriv->stride < 0)
+	{
+	    pGeometry->f.bitmap.bytes_per_line = -pPixmapPriv->stride;
+	    pGeometry->f.bitmap.scanline_order =
+		GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
+	}
+	else
+	{
+	    pGeometry->f.bitmap.bytes_per_line = pPixmapPriv->stride;
+	    pGeometry->f.bitmap.scanline_order =
+		GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
+	}
+
+	pGeometry->f.bitmap.pad = ((1 + FB_MASK) >> FB_SHIFT) *
+	    sizeof (FbBits);
+	pGeometry->width = pPixmap->drawable.width;
+	pGeometry->count = pPixmap->drawable.height;
+
+	pPixmapPriv->pGeometry = pGeometry;
+    }
+
+    pPixmapPriv->pGeometry->xOff = xOff << 16;
+    pPixmapPriv->pGeometry->yOff = yOff << 16;
+
+    return pPixmapPriv->pGeometry;
+}
+
+Bool
+xglCreatePixmapSurface (PixmapPtr pPixmap)
+{
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    if (!pPixmapPriv->surface)
+    {
+	XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
+
+	if (!pPixmapPriv->pVisual || !pPixmapPriv->pVisual->format.surface)
+	    return FALSE;
+
+	__glXleaveServer(FALSE);
+	pPixmapPriv->surface =
+	    glitz_surface_create (pScreenPriv->drawable,
+				  pPixmapPriv->pVisual->format.surface,
+				  pPixmap->drawable.width,
+				  pPixmap->drawable.height,
+				  0, NULL);
+	__glXenterServer(FALSE);
+	if (!pPixmapPriv->surface)
+	{
+	    pPixmapPriv->pVisual = NULL;
+	    pPixmapPriv->target  = xglPixmapTargetNo;
+
+	    return FALSE;
+	}
+    }
+
+    return TRUE;
+}
+
+Bool
+xglAllocatePixmapBits (PixmapPtr pPixmap, int hint)
+{
+    int width, height, bpp, stride;
+
+    XGL_PIXMAP_PRIV (pPixmap);
+    XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
+
+    width  = pPixmap->drawable.width;
+    height = pPixmap->drawable.height;
+    bpp    = pPixmap->drawable.bitsPerPixel;
+
+    stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * (int) sizeof (FbBits);
+
+    if (stride)
+    {
+	glitz_buffer_t *buffer;
+
+	if ((pScreenPriv->pboMask & bpp) && hint)
+	{
+	    buffer = glitz_pixel_buffer_create (pScreenPriv->drawable,
+						NULL, height * stride,
+						XGL_PIXMAP_USAGE_HINT (hint));
+	}
+	else
+	{
+	    pPixmapPriv->bits = xalloc (height * stride);
+	    if (!pPixmapPriv->bits)
+		return FALSE;
+
+	    buffer = glitz_buffer_create_for_data (pPixmapPriv->bits);
+	}
+
+	if (!buffer)
+	{
+	    if (pPixmapPriv->bits)
+		xfree (pPixmapPriv->bits);
+	    pPixmapPriv->bits = NULL;
+	    return FALSE;
+	}
+	pPixmapPriv->buffer = buffer;
+    }
+
+    if (pScreenPriv->yInverted)
+	pPixmapPriv->stride = stride;
+    else
+	pPixmapPriv->stride = -stride;
+
+    return TRUE;
+}
+
+Bool
+xglMapPixmapBits (PixmapPtr pPixmap)
+{
+    if (!pPixmap->devPrivate.ptr)
+    {
+	CARD8 *bits;
+
+	XGL_PIXMAP_PRIV (pPixmap);
+
+	if (!pPixmapPriv->buffer)
+	    if (!xglAllocatePixmapBits (pPixmap,
+					XGL_PIXMAP_USAGE_HINT_DEFAULT))
+		return FALSE;
+
+	bits = glitz_buffer_map (pPixmapPriv->buffer,
+				 GLITZ_BUFFER_ACCESS_READ_WRITE);
+	if (!bits)
+	    return FALSE;
+
+	pPixmap->devKind = pPixmapPriv->stride;
+	if (pPixmapPriv->stride < 0)
+	{
+	    pPixmap->devPrivate.ptr = bits +
+		(pPixmap->drawable.height - 1) * -pPixmapPriv->stride;
+	}
+	else
+	{
+	    pPixmap->devPrivate.ptr = bits;
+	}
+    }
+
+    return TRUE;
+}
+
+Bool
+xglUnmapPixmapBits (PixmapPtr pPixmap)
+{
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    pPixmap->devKind = 0;
+    pPixmap->devPrivate.ptr = 0;
+
+    if (pPixmapPriv->buffer)
+	if (glitz_buffer_unmap (pPixmapPriv->buffer))
+	    return FALSE;
+
+    return TRUE;
+}
+
+Bool
+xglCheckPixmapSize (PixmapPtr		 pPixmap,
+		    xglSizeConstraintPtr pSize)
+{
+    if (pPixmap->drawable.width  < pSize->minWidth ||
+	pPixmap->drawable.height < pSize->minHeight)
+	return FALSE;
+
+    if (pPixmap->drawable.width  > pSize->aboveWidth ||
+	pPixmap->drawable.height > pSize->aboveHeight)
+	return TRUE;
+
+    return FALSE;
+}
+
+void
+xglEnablePixmapAccel (PixmapPtr	      pPixmap,
+		      xglAccelInfoPtr pAccel)
+{
+    XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    if (pAccel->enabled && xglCheckPixmapSize (pPixmap, &pAccel->size))
+    {
+	xglVisualPtr v;
+
+	if (pAccel->pbuffer)
+	{
+	    for (v = pScreenPriv->pVisual; v; v = v->next)
+	    {
+		if (v->pPixel->depth != pPixmap->drawable.depth)
+		    continue;
+
+		if (v->format.drawable && v->pbuffer)
+		    break;
+	    }
+	}
+	else
+	{
+	    for (v = pScreenPriv->pVisual; v; v = v->next)
+	    {
+		if (v->pPixel->depth != pPixmap->drawable.depth)
+		    continue;
+
+		if (v->format.drawable && !v->pbuffer)
+		    break;
+	    }
+	}
+
+	if (v)
+	{
+	    xglSetPixmapVisual (pPixmap, v);
+	    if (!pPixmapPriv->target)
+		pPixmapPriv->target = xglPixmapTargetOut;
+	}
+    }
+}
diff --git a/xgl/xglshm.c b/xgl/xglshm.c
new file mode 100644
index 0000000..52a8aab
--- /dev/null
+++ b/xgl/xglshm.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright © 2005 Novell, Inc.
+ *
+ * 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
+ * Novell, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Novell, Inc. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NOVELL, INC. 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+#include "gcstruct.h"
+
+#ifdef MITSHM
+
+void
+xglShmPutImage (DrawablePtr  pDrawable,
+		GCPtr	     pGC,
+		int	     depth,
+		unsigned int format,
+		int	     w,
+		int	     h,
+		int	     sx,
+		int	     sy,
+		int	     sw,
+		int	     sh,
+		int	     dx,
+		int	     dy,
+		char	     *data)
+{
+    ScreenPtr pScreen = pDrawable->pScreen;
+    PixmapPtr pPixmapHeader = NULL;
+    PixmapPtr pPixmap;
+    int	      saveTarget;
+
+    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
+
+    if ((format == ZPixmap) || (depth == 1))
+    {
+	pPixmap = pPixmapHeader =
+	    GetScratchPixmapHeader (pScreen, w, h, depth,
+				    BitsPerPixel (depth),
+				    PixmapBytePad (w, depth),
+				    (pointer) data);
+
+	/* disable any possible acceleration of this pixmap */
+	if (pPixmap)
+	    xglSetPixmapVisual (pPixmap, 0);
+    }
+    else
+    {
+	pPixmap = (*pScreen->CreatePixmap) (pScreen, sw, sh, depth);
+	if (pPixmap)
+	{
+	    GCPtr pScratchGC;
+
+	    if (!xglAllocatePixmapBits (pPixmap,
+					XGL_PIXMAP_USAGE_HINT_DEFAULT))
+	    {
+		(*pScreen->DestroyPixmap) (pPixmap);
+		return;
+	    }
+
+	    xglSetPixmapVisual (pPixmap, 0);
+
+	    pScratchGC = GetScratchGC (depth, pScreen);
+	    if (!pScratchGC)
+	    {
+		(*pScreen->DestroyPixmap) (pPixmap);
+		return;
+	    }
+
+	    ValidateGC ((DrawablePtr) pPixmap, pScratchGC);
+	    (*pGC->ops->PutImage) ((DrawablePtr) pPixmap, pScratchGC, depth,
+				   -sx, -sy, w, h, 0,
+				   (format == XYPixmap) ? XYPixmap : ZPixmap,
+				   data);
+
+	    FreeScratchGC (pScratchGC);
+
+	    sx = sy = 0;
+	}
+    }
+
+    if (!pPixmap)
+	return;
+
+    /* CopyArea should always be done in software */
+    saveTarget = pPixmapPriv->target;
+    pPixmapPriv->target = xglPixmapTargetNo;
+
+    if (format == XYBitmap)
+	(*pGC->ops->CopyPlane) ((DrawablePtr) pPixmap, pDrawable, pGC,
+				sx, sy, sw, sh, dx, dy, 1L);
+    else
+	(*pGC->ops->CopyArea) ((DrawablePtr) pPixmap, pDrawable, pGC,
+			       sx, sy, sw, sh, dx, dy);
+
+    pPixmapPriv->target = saveTarget;
+
+    if (pPixmapHeader)
+	FreeScratchPixmapHeader (pPixmapHeader);
+    else
+	(*pScreen->DestroyPixmap) (pPixmap);
+}
+
+#endif
diff --git a/xgl/xglsolid.c b/xgl/xglsolid.c
new file mode 100644
index 0000000..a3dc281
--- /dev/null
+++ b/xgl/xglsolid.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+#include "glxserver.h"
+#include "glapi.h"
+#include "glthread.h"
+#include "dispatch.h"
+
+#include "xgl.h"
+#include "gcstruct.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+
+Bool
+xglSolid (DrawablePtr	   pDrawable,
+	  glitz_operator_t op,
+	  glitz_surface_t  *solid,
+	  xglGeometryPtr   pGeometry,
+	  int		   x,
+	  int		   y,
+	  int		   width,
+	  int		   height,
+	  BoxPtr	   pBox,
+	  int		   nBox)
+{
+    glitz_surface_t *surface;
+    int		    xOff, yOff;
+
+    if (nBox < 1)
+	return TRUE;
+
+    if (!xglPrepareTarget (pDrawable))
+	return FALSE;
+
+    XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
+
+    if (pGeometry)
+    {
+	glitz_surface_set_clip_region (surface, xOff, yOff,
+				       (glitz_box_t *) pBox, nBox);
+    }
+    else
+    {
+	pGeometry = xglGetScratchVertexGeometry (pDrawable->pScreen, 4 * nBox);
+	GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox);
+    }
+
+    GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
+
+    if (!GEOMETRY_ENABLE (pGeometry, surface))
+	return FALSE;
+
+    __glXleaveServer(FALSE);
+    glitz_composite (op,
+		     solid, NULL, surface,
+		     0, 0,
+		     0, 0,
+		     x + xOff,
+		     y + yOff,
+		     width, height);
+    __glXenterServer(FALSE);
+
+    glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
+
+    if (glitz_surface_get_status (surface))
+	return FALSE;
+
+    return TRUE;
+}
+
+Bool
+xglSolidGlyph (DrawablePtr  pDrawable,
+	       GCPtr	    pGC,
+	       int	    x,
+	       int	    y,
+	       unsigned int nGlyph,
+	       CharInfoPtr  *ppci,
+	       pointer      pglyphBase)
+{
+    xglGeometryRec geometry;
+    int		   xBack, widthBack;
+    int		   yBack, heightBack;
+
+    XGL_GC_PRIV (pGC);
+
+    x += pDrawable->x;
+    y += pDrawable->y;
+
+    GEOMETRY_INIT (pDrawable->pScreen, &geometry,
+		   GLITZ_GEOMETRY_TYPE_BITMAP,
+		   GEOMETRY_USAGE_SYSMEM, 0);
+
+    GEOMETRY_FOR_GLYPH (pDrawable->pScreen,
+			&geometry,
+			nGlyph,
+			ppci,
+			pglyphBase);
+
+    GEOMETRY_TRANSLATE (&geometry, x, y);
+
+    widthBack = 0;
+    while (nGlyph--)
+	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 (xglSolid (pDrawable,
+		  pGCPriv->op,
+		  pGCPriv->bg,
+		  NULL,
+		  xBack,
+		  yBack,
+		  widthBack,
+		  heightBack,
+		  REGION_RECTS (pGC->pCompositeClip),
+		  REGION_NUM_RECTS (pGC->pCompositeClip)))
+    {
+	if (xglSolid (pDrawable,
+		      pGCPriv->op,
+		      pGCPriv->fg,
+		      &geometry,
+		      xBack,
+		      yBack,
+		      widthBack,
+		      heightBack,
+		      REGION_RECTS (pGC->pCompositeClip),
+		      REGION_NUM_RECTS (pGC->pCompositeClip)))
+	{
+	    GEOMETRY_UNINIT (&geometry);
+	    xglAddCurrentBitDamage (pDrawable);
+	    return TRUE;
+	}
+    }
+
+    GEOMETRY_UNINIT (&geometry);
+    return FALSE;
+}
diff --git a/xgl/xglsync.c b/xgl/xglsync.c
new file mode 100644
index 0000000..2daef6e
--- /dev/null
+++ b/xgl/xglsync.c
@@ -0,0 +1,497 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+
+Bool
+xglSyncBits (DrawablePtr pDrawable,
+	     BoxPtr	 pExtents)
+{
+    RegionRec region;
+    BoxRec    box;
+
+    XGL_DRAWABLE_PIXMAP (pDrawable);
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    if (pPixmapPriv->allBits)
+	return xglMapPixmapBits (pPixmap);
+
+    if (pPixmapPriv->target == xglPixmapTargetIn && pExtents)
+    {
+	box.x1 = 0;
+	box.y1 = 0;
+	box.x2 = pPixmap->drawable.width;
+	box.y2 = pPixmap->drawable.height;
+	if (pExtents->x1 > box.x1)
+	    box.x1 = pExtents->x1;
+	if (pExtents->y1 > box.y1)
+	    box.y1 = pExtents->y1;
+	if (pExtents->x2 < box.x2)
+	    box.x2 = pExtents->x2;
+	if (pExtents->y2 < box.y2)
+	    box.y2 = pExtents->y2;
+
+	if (box.x2 <= box.x1 || box.y2 <= box.y1)
+	    return xglMapPixmapBits (pPixmap);
+
+	if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
+	{
+	    switch (RECT_IN_REGION (pDrawable->pScreen,
+				    &pPixmapPriv->bitRegion,
+				    &box)) {
+	    case rgnIN:
+		REGION_INIT (pDrawable->pScreen, &region, NullBox, 0);
+		break;
+	    case rgnOUT:
+		REGION_INIT (pDrawable->pScreen, &region, &box, 1);
+		REGION_UNION (pDrawable->pScreen,
+			      &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
+			      &region);
+		break;
+	    case rgnPART:
+		REGION_INIT (pDrawable->pScreen, &region, &box, 1);
+		REGION_SUBTRACT (pDrawable->pScreen, &region, &region,
+				 &pPixmapPriv->bitRegion);
+		REGION_UNION (pDrawable->pScreen,
+			      &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
+			      &region);
+		break;
+	    }
+	}
+	else
+	{
+	    REGION_INIT (pDrawable->pScreen, &region, &box, 1);
+	    REGION_SUBTRACT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
+			     &region, &pPixmapPriv->bitRegion);
+	}
+
+	if (REGION_NUM_RECTS (&pPixmapPriv->bitRegion) == 1)
+	{
+	    BoxPtr pBox;
+
+	    pBox = REGION_RECTS (&pPixmapPriv->bitRegion);
+
+	    if (pBox->x1 <= 0			    &&
+		pBox->y1 <= 0			    &&
+		pBox->x2 >= pPixmap->drawable.width &&
+		pBox->y2 >= pPixmap->drawable.height)
+		pPixmapPriv->allBits = TRUE;
+	}
+    }
+    else
+    {
+	box.x1 = 0;
+	box.y1 = 0;
+	box.x2 = pPixmap->drawable.width;
+	box.y2 = pPixmap->drawable.height;
+
+	REGION_INIT (pDrawable->pScreen, &region, &box, 1);
+	REGION_SUBTRACT (pDrawable->pScreen, &region, &region,
+			 &pPixmapPriv->bitRegion);
+
+	pPixmapPriv->allBits = TRUE;
+    }
+
+    if (!pPixmapPriv->buffer)
+	if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
+	    return FALSE;
+
+    if (REGION_NOTEMPTY (pDrawable->pScreen, &region) && pPixmapPriv->surface)
+    {
+	glitz_pixel_format_t format;
+	BoxPtr		     pBox;
+	BoxPtr		     pExt;
+	int		     nBox;
+
+	if (!xglSyncSurface (pDrawable))
+	    FatalError (XGL_SW_FAILURE_STRING);
+
+	xglUnmapPixmapBits (pPixmap);
+
+	pBox = REGION_RECTS (&region);
+	nBox = REGION_NUM_RECTS (&region);
+	pExt = REGION_EXTENTS (pDrawable->pScreen, &region);
+
+	format.fourcc  = GLITZ_FOURCC_RGB;
+	format.masks   = pPixmapPriv->pVisual->pPixel->masks;
+	format.xoffset = pExt->x1;
+
+	if (pPixmapPriv->stride < 0)
+	{
+	    format.skip_lines	  = pPixmap->drawable.height - pExt->y2;
+	    format.bytes_per_line = -pPixmapPriv->stride;
+	    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
+	}
+	else
+	{
+	    format.skip_lines	  = pExt->y1;
+	    format.bytes_per_line = pPixmapPriv->stride;
+	    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
+	}
+
+	glitz_surface_set_clip_region (pPixmapPriv->surface,
+				       0, 0, (glitz_box_t *) pBox, nBox);
+
+	__glXleaveServer(FALSE);
+	glitz_get_pixels (pPixmapPriv->surface,
+			  pExt->x1,
+			  pExt->y1,
+			  pExt->x2 - pExt->x1,
+			  pExt->y2 - pExt->y1,
+			  &format,
+			  pPixmapPriv->buffer);
+	__glXenterServer(FALSE);
+
+	glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, NULL, 0);
+    }
+
+    REGION_UNINIT (pDrawable->pScreen, &region);
+
+    if (pPixmapPriv->allBits)
+    {
+	box.x1 = 0;
+	box.y1 = 0;
+	box.x2 = pPixmap->drawable.width;
+	box.y2 = pPixmap->drawable.height;
+
+	REGION_UNINIT (pDrawable->pScreen, &pPixmapPriv->bitRegion);
+	REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion, &box, 1);
+    }
+
+    return xglMapPixmapBits (pPixmap);
+}
+
+void
+xglSyncDamageBoxBits (DrawablePtr pDrawable)
+{
+    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
+
+    if (!xglSyncBits (pDrawable, &pPixmapPriv->damageBox))
+	FatalError (XGL_SW_FAILURE_STRING);
+}
+
+Bool
+xglSyncSurface (DrawablePtr pDrawable)
+{
+    RegionPtr pRegion;
+
+    XGL_DRAWABLE_PIXMAP (pDrawable);
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    if (!pPixmapPriv->surface)
+    {
+	if (!xglCreatePixmapSurface (pPixmap))
+	    return FALSE;
+    }
+
+    pRegion = DamageRegion (pPixmapPriv->pDamage);
+
+    if (pPixmapPriv->surface && REGION_NOTEMPTY (pDrawable->pScreen, pRegion))
+    {
+	glitz_pixel_format_t format;
+	BoxPtr		     pBox;
+	BoxPtr		     pExt;
+	int		     nBox;
+
+	xglUnmapPixmapBits (pPixmap);
+
+	nBox = REGION_NUM_RECTS (pRegion);
+	pBox = REGION_RECTS (pRegion);
+	pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
+
+	format.fourcc  = pPixmapPriv->pVisual->format.surface->color.fourcc;
+	format.masks   = pPixmapPriv->pVisual->pPixel->masks;
+	format.xoffset = pExt->x1;
+
+	if (pPixmapPriv->stride < 0)
+	{
+	    format.skip_lines	  = pPixmap->drawable.height - pExt->y2;
+	    format.bytes_per_line = -pPixmapPriv->stride;
+	    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
+	}
+	else
+	{
+	    format.skip_lines	  = pExt->y1;
+	    format.bytes_per_line = pPixmapPriv->stride;
+	    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
+	}
+
+	/* If all bits are up to date we can avoid transferring a large set
+	   of boxes by transferring the extents box instead. */
+	if (pPixmapPriv->allBits && nBox != 1)
+	{
+	    /* This many boxes. It is likely more efficient to always transfer
+	       the extents box instead. */
+	    if (nBox > 64)
+	    {
+		pBox = pExt;
+		nBox = 1;
+	    }
+	    else
+	    {
+		int i, w, e, r = 0;
+
+		for (i = 0; i < nBox; i++)
+		    r += (pBox[i].x2 - pBox[i].x1) * (pBox[i].y2 - pBox[i].y1);
+
+		e = (pExt->x2 - pExt->x1) * (pExt->y2 - pExt->y1);
+		w = e - r;
+
+		/* r, is the area of all boxes. e, is the are for the
+		   extents. w, is the area that doesn't need to be
+		   transferred.
+
+		   If w per box is less than 2 times the area of all
+		   boxes, transferring the extents has been proved more
+		   efficient. */
+		if ((w / nBox) < (r << 1))
+		{
+		    pBox = pExt;
+		    nBox = 1;
+		}
+	    }
+	}
+
+	glitz_surface_set_clip_region (pPixmapPriv->surface,
+				       0, 0, (glitz_box_t *) pBox, nBox);
+
+	__glXleaveServer(FALSE);
+	glitz_set_pixels (pPixmapPriv->surface,
+			  pExt->x1,
+			  pExt->y1,
+			  pExt->x2 - pExt->x1,
+			  pExt->y2 - pExt->y1,
+			  &format,
+			  pPixmapPriv->buffer);
+	__glXenterServer(FALSE);
+
+	glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, NULL, 0);
+
+	REGION_EMPTY (pDrawable->pScreen, pRegion);
+    }
+
+    return TRUE;
+}
+
+Bool
+xglPrepareTarget (DrawablePtr pDrawable)
+{
+    XGL_DRAWABLE_PIXMAP (pDrawable);
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    switch (pPixmapPriv->target) {
+    case xglPixmapTargetNo:
+	break;
+    case xglPixmapTargetOut:
+	if (xglSyncSurface (pDrawable))
+	{
+	    glitz_drawable_format_t *format;
+
+	    XGL_SCREEN_PRIV (pDrawable->pScreen);
+
+	    if (!pPixmapPriv->drawable)
+	    {
+		unsigned int width, height;
+
+		format = pPixmapPriv->pVisual->format.drawable;
+		width  = pPixmap->drawable.width;
+		height = pPixmap->drawable.height;
+
+		if (pPixmapPriv->pVisual->pbuffer)
+		{
+		    pPixmapPriv->drawable =
+			glitz_create_pbuffer_drawable (pScreenPriv->drawable,
+						       format, width, height);
+		}
+		else
+		{
+		    pPixmapPriv->drawable =
+			glitz_create_drawable (pScreenPriv->drawable,
+					       format, width, height);
+		}
+	    }
+
+	    if (pPixmapPriv->drawable)
+	    {
+		glitz_surface_attach (pPixmapPriv->surface,
+				      pPixmapPriv->drawable,
+				      GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
+
+		pPixmapPriv->target = xglPixmapTargetIn;
+
+		return TRUE;
+	    }
+	}
+	pPixmapPriv->target = xglPixmapTargetNo;
+	break;
+    case xglPixmapTargetIn:
+	if (xglSyncSurface (pDrawable))
+	    return TRUE;
+	break;
+    }
+
+    return FALSE;
+}
+
+void
+xglAddSurfaceDamage (DrawablePtr pDrawable,
+		     RegionPtr   pRegion)
+{
+    glitz_surface_t *surface;
+    int		    xOff, yOff;
+
+#if 0
+    miPrintRegion(pRegion);
+#endif
+
+    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
+
+    pPixmapPriv->damageBox = miEmptyBox;
+
+    XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
+
+    if (xOff || yOff)
+	REGION_TRANSLATE (pDrawable->pScreen, pRegion, xOff, yOff);
+
+    if (pPixmapPriv->pDamage)
+    {
+	RegionPtr pDamageRegion;
+
+	pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
+
+	REGION_UNION (pDrawable->pScreen,
+		      pDamageRegion, pDamageRegion,
+		      pRegion);
+    }
+
+    REGION_UNION (pDrawable->pScreen,
+		  &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
+		  pRegion);
+
+    if (xOff || yOff)
+	REGION_TRANSLATE (pDrawable->pScreen, pRegion, -xOff, -yOff);
+}
+
+void
+xglAddCurrentSurfaceDamage (DrawablePtr pDrawable)
+{
+    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
+
+    if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
+    {
+	RegionRec region;
+
+	REGION_INIT (pDrawable->pScreen, &region, &pPixmapPriv->damageBox, 1);
+
+	if (pPixmapPriv->pDamage)
+	{
+	    RegionPtr pDamageRegion;
+
+	    pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
+
+	    REGION_UNION (pDrawable->pScreen,
+			  pDamageRegion, pDamageRegion,
+			  &region);
+	}
+
+	REGION_UNION (pDrawable->pScreen,
+		      &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
+		      &region);
+
+	REGION_UNINIT (pDrawable->pScreen, &region);
+
+	pPixmapPriv->damageBox = miEmptyBox;
+    }
+}
+
+void
+xglAddBitDamage (DrawablePtr pDrawable,
+		 RegionPtr   pRegion)
+{
+    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
+
+    if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
+    {
+	BoxPtr pBox;
+	BoxPtr pExt, pBitExt;
+	int    nBox;
+
+	pBox = REGION_RECTS (pRegion);
+	pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
+	nBox = REGION_NUM_RECTS (pRegion);
+
+	pBitExt = REGION_EXTENTS (pDrawable->pScreen, &pPixmapPriv->bitRegion);
+
+	if (pExt->x1 < pBitExt->x2 &&
+	    pExt->y1 < pBitExt->y2 &&
+	    pExt->x2 > pBitExt->x1 &&
+	    pExt->y2 > pBitExt->y1)
+	{
+	    while (nBox--)
+	    {
+		if (pBox->x1 < pBitExt->x2 &&
+		    pBox->y1 < pBitExt->y2 &&
+		    pBox->x2 > pBitExt->x1 &&
+		    pBox->y2 > pBitExt->y1)
+		{
+		    REGION_UNINIT (pDrawable->pScreen,
+				   &pPixmapPriv->bitRegion);
+		    REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
+				 NullBox, 0);
+		    pPixmapPriv->allBits = FALSE;
+		    return;
+		}
+
+		pBox++;
+	    }
+	}
+    }
+}
+
+void
+xglAddCurrentBitDamage (DrawablePtr pDrawable)
+{
+    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
+
+    if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
+    {
+	BoxPtr pBitExt;
+
+	pBitExt = REGION_EXTENTS (pDrawable->pScreen, &pPixmapPriv->bitRegion);
+
+	if (pPixmapPriv->damageBox.x1 < pBitExt->x2 &&
+	    pPixmapPriv->damageBox.y1 < pBitExt->y2 &&
+	    pPixmapPriv->damageBox.x2 > pBitExt->x1 &&
+	    pPixmapPriv->damageBox.y2 > pBitExt->y1)
+	{
+	    REGION_UNINIT (pDrawable->pScreen, &pPixmapPriv->bitRegion);
+	    REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
+			 NullBox, 0);
+	    pPixmapPriv->allBits = FALSE;
+	}
+    }
+
+    pPixmapPriv->damageBox = miEmptyBox;
+}
diff --git a/xgl/xgltile.c b/xgl/xgltile.c
new file mode 100644
index 0000000..200b381
--- /dev/null
+++ b/xgl/xgltile.c
@@ -0,0 +1,277 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+#include "glxserver.h"
+#include "glapi.h"
+#include "glthread.h"
+#include "dispatch.h"
+
+
+#include "xgl.h"
+
+static glitz_geometry_format_t tileGeometryFormat = {
+    {
+	GLITZ_PRIMITIVE_QUADS,
+	GLITZ_DATA_TYPE_FLOAT,
+	sizeof (glitz_float_t) * 4,
+	GLITZ_VERTEX_ATTRIBUTE_SRC_COORD_MASK, {
+	    GLITZ_DATA_TYPE_FLOAT,
+	    GLITZ_COORDINATE_SIZE_XY,
+	    sizeof (glitz_float_t) * 2,
+	}, {
+	    0, 0, 0
+	}
+    }
+};
+
+xglGeometryPtr
+xglTiledBoxGeometry (PixmapPtr pTile,
+		     int       tileX,
+		     int       tileY,
+		     BoxPtr    pBox,
+		     int       nBox)
+{
+    ScreenPtr		pScreen = pTile->drawable.pScreen;
+    glitz_point_fixed_t p1, p2;
+    xglGeometryPtr	pGeometry;
+    glitz_float_t	x1, x2, y1, y2;
+    int			x, y, width, height, i;
+    int			xTile, yTile;
+    int			widthTile, heightTile;
+    int			widthTmp, xTmp, yTmp, xTileTmp;
+    int			tileWidth, tileHeight;
+    int			size = 0;
+    glitz_float_t	*data;
+
+    XGL_PIXMAP_PRIV (pTile);
+
+    tileWidth  = pTile->drawable.width;
+    tileHeight = pTile->drawable.height;
+
+    for (i = 0; i < nBox; i++)
+	size +=
+	    (((pBox[i].x2 - pBox[i].x1) / tileWidth) + 2) *
+	    (((pBox[i].y2 - pBox[i].y1) / tileHeight) + 2);
+
+    pGeometry = xglGetScratchVertexGeometryWithType (pScreen,
+						     GEOMETRY_DATA_TYPE_FLOAT,
+						     8 * size);
+
+    data = glitz_buffer_map (pGeometry->buffer,
+			     GLITZ_BUFFER_ACCESS_WRITE_ONLY);
+
+    while (nBox--)
+    {
+	x = pBox->x1;
+	y = pBox->y1;
+	width = pBox->x2 - pBox->x1;
+	height = pBox->y2 - pBox->y1;
+
+	xTile = MOD (tileX + x, tileWidth);
+	yTile = MOD (tileY + y, tileHeight);
+
+	yTmp = y;
+
+	while (height)
+	{
+	    heightTile = MIN (tileHeight - yTile, height);
+
+	    xTileTmp = xTile;
+	    widthTmp = width;
+	    xTmp     = x;
+
+	    while (widthTmp)
+	    {
+		widthTile = MIN (tileWidth - xTileTmp, widthTmp);
+
+		p1.x = xTileTmp << 16;
+		p1.y = yTile << 16;
+		p2.x = (xTileTmp + widthTile) << 16;
+		p2.y = (yTile + heightTile) << 16;
+
+		glitz_surface_translate_point (pPixmapPriv->surface, &p1, &p1);
+		glitz_surface_translate_point (pPixmapPriv->surface, &p2, &p2);
+
+		x1 = FIXED_TO_FLOAT (p1.x);
+		y1 = FIXED_TO_FLOAT (p1.y);
+		x2 = FIXED_TO_FLOAT (p2.x);
+		y2 = FIXED_TO_FLOAT (p2.y);
+
+		*data++ = (glitz_float_t) xTmp;
+		*data++ = (glitz_float_t) yTmp;
+		*data++ = x1;
+		*data++ = y1;
+
+		*data++ = (glitz_float_t) (xTmp + widthTile);
+		*data++ = (glitz_float_t) yTmp;
+		*data++ = x2;
+		*data++ = y1;
+
+		*data++ = (glitz_float_t) (xTmp + widthTile);
+		*data++ = (glitz_float_t) (yTmp + heightTile);
+		*data++ = x2;
+		*data++ = y2;
+
+		*data++ = (glitz_float_t) xTmp;
+		*data++ = (glitz_float_t) (yTmp + heightTile);
+		*data++ = x1;
+		*data++ = y2;
+
+		pGeometry->endOffset += sizeof (glitz_float_t) * 16;
+
+		xTileTmp  = 0;
+		xTmp     += widthTile;
+		widthTmp -= widthTile;
+	    }
+
+	    yTile   = 0;
+	    yTmp   += heightTile;
+	    height -= heightTile;
+	}
+
+	pBox++;
+    }
+
+    if (glitz_buffer_unmap (pGeometry->buffer))
+	return NULL;
+
+    pGeometry->f     = tileGeometryFormat;
+    pGeometry->count =
+	pGeometry->endOffset / tileGeometryFormat.vertex.bytes_per_vertex;
+
+    pPixmapPriv->pictureMask |= xglPCFillMask;
+    glitz_surface_set_fill (pPixmapPriv->surface, GLITZ_FILL_TRANSPARENT);
+
+    return pGeometry;
+}
+
+Bool
+xglTile (DrawablePtr	  pDrawable,
+	 glitz_operator_t op,
+	 PixmapPtr	  pTile,
+	 int		  tileX,
+	 int		  tileY,
+	 xglGeometryPtr	  pGeometry,
+	 int		  x,
+	 int		  y,
+	 int		  width,
+	 int		  height,
+	 BoxPtr		  pBox,
+	 int		  nBox)
+{
+    xglPixmapPtr    pTilePriv;
+    glitz_surface_t *surface;
+    int		    xOff, yOff;
+
+    if (nBox < 1)
+	return TRUE;
+
+    if (!xglPrepareTarget (pDrawable))
+	return FALSE;
+
+    if (!xglSyncSurface (&pTile->drawable))
+	return FALSE;
+
+    XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
+
+    pTilePriv = XGL_GET_PIXMAP_PRIV (pTile);
+
+    pTilePriv->pictureMask |= xglPCFilterMask | xglPCTransformMask;
+    glitz_surface_set_filter (pTilePriv->surface,
+			      GLITZ_FILTER_NEAREST,
+			      NULL, 0);
+    glitz_surface_set_transform (pTilePriv->surface, NULL);
+
+    if (pTilePriv->acceleratedTile)
+    {
+	if (pGeometry)
+	{
+	    glitz_surface_set_clip_region (surface, xOff, yOff,
+					   (glitz_box_t *) pBox, nBox);
+	    nBox = 0;
+	}
+	else
+	{
+	    pGeometry = xglGetScratchVertexGeometry (pDrawable->pScreen,
+						     4 * nBox);
+	    GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox);
+	}
+
+	GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
+
+	if (!GEOMETRY_ENABLE (pGeometry, surface))
+	    return FALSE;
+
+	pTilePriv->pictureMask |= xglPCFillMask;
+	glitz_surface_set_fill (pTilePriv->surface, GLITZ_FILL_REPEAT);
+
+	__glXleaveServer(FALSE);
+	glitz_composite (op,
+			 pTilePriv->surface, NULL, surface,
+			 x + tileX,
+			 y + tileY,
+			 0, 0,
+			 x + xOff,
+			 y + yOff,
+			 width, height);
+	__glXenterServer(FALSE);
+
+	glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
+
+	if (!glitz_surface_get_status (surface))
+	    return TRUE;
+
+	if (!nBox)
+	    return FALSE;
+    }
+    else
+    {
+	if (pGeometry)
+	    return FALSE;
+    }
+
+    pGeometry = xglTiledBoxGeometry (pTile, tileX, tileY, pBox, nBox);
+    if (!pGeometry)
+	return FALSE;
+
+    GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
+
+    if (!GEOMETRY_ENABLE (pGeometry, surface))
+	return FALSE;
+
+    __glXleaveServer(FALSE);
+    glitz_composite (op,
+		     pTilePriv->surface, NULL, surface,
+		     0, 0,
+		     0, 0,
+		     x + xOff,
+		     y + yOff,
+		     width, height);
+    __glXenterServer(FALSE);
+
+    if (glitz_surface_get_status (surface))
+	return FALSE;
+
+    return TRUE;
+}
diff --git a/xgl/xgltrap.c b/xgl/xgltrap.c
new file mode 100644
index 0000000..26e2bc4
--- /dev/null
+++ b/xgl/xgltrap.c
@@ -0,0 +1,480 @@
+/*
+ * Copyright © 2005 Novell, Inc.
+ *
+ * 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
+ * Novell, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Novell, Inc. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NOVELL, INC. 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+#include "gcstruct.h"
+#include "damage.h"
+
+#ifdef RENDER
+
+#define XGL_TRAP_FALLBACK_PROLOGUE(pPicture, func) \
+    xglSyncDamageBoxBits (pPicture->pDrawable);	   \
+    XGL_PICTURE_SCREEN_UNWRAP (func)
+
+#define XGL_TRAP_FALLBACK_EPILOGUE(pPicture, func, xglfunc) \
+    XGL_PICTURE_SCREEN_WRAP (func, xglfunc);		    \
+    xglAddCurrentSurfaceDamage (pPicture->pDrawable)
+
+/* just a guess */
+#define SMOOTH_TRAPS_ESTIMATE_RECTS(nTrap) (30 * nTrap)
+
+#define LINE_FIXED_X(l, _y, v)			 \
+    dx = (l)->p2.x - (l)->p1.x;			 \
+    ex = (xFixed_32_32) ((_y) - (l)->p1.y) * dx; \
+    dy = (l)->p2.y - (l)->p1.y;			 \
+    (v) = (l)->p1.x + (xFixed) (ex / dy)
+
+#define LINE_FIXED_X_CEIL(l, _y, v)		      \
+    dx = (l)->p2.x - (l)->p1.x;			      \
+    ex = (xFixed_32_32) ((_y) - (l)->p1.y) * dx;      \
+    dy = (l)->p2.y - (l)->p1.y;			      \
+    (v) = (l)->p1.x + (xFixed) ((ex + (dy - 1)) / dy)
+
+static Bool
+xglTrapezoidExtents (PicturePtr pDst,
+		     int        ntrap,
+		     xTrapezoid *traps,
+		     BoxPtr     extents)
+{
+    Bool	 x_overlap, overlap = FALSE;
+    xFixed	 dx, dy, top, bottom;
+    xFixed_32_32 ex;
+
+    if (!ntrap)
+    {
+	extents->x1 = MAXSHORT;
+	extents->x2 = MINSHORT;
+	extents->y1 = MAXSHORT;
+	extents->y2 = MINSHORT;
+
+	return FALSE;
+    }
+
+    extents->y1 = xFixedToInt (traps->top);
+    extents->y2 = xFixedToInt (xFixedCeil (traps->bottom));
+
+    LINE_FIXED_X (&traps->left, traps->top, top);
+    LINE_FIXED_X (&traps->left, traps->bottom, bottom);
+    extents->x1 = xFixedToInt (MIN (top, bottom));
+
+    LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
+    LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
+    extents->x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
+
+    ntrap--;
+    traps++;
+
+    for (; ntrap; ntrap--, traps++)
+    {
+	INT16 x1, y1, x2, y2;
+
+	if (!xTrapezoidValid (traps))
+	    continue;
+
+	y1 = xFixedToInt (traps->top);
+	y2 = xFixedToInt (xFixedCeil (traps->bottom));
+
+	LINE_FIXED_X (&traps->left, traps->top, top);
+	LINE_FIXED_X (&traps->left, traps->bottom, bottom);
+	x1 = xFixedToInt (MIN (top, bottom));
+
+	LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
+	LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
+	x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
+
+	x_overlap = FALSE;
+	if (x1 >= extents->x2)
+	    extents->x2 = x2;
+	else if (x2 <= extents->x1)
+	    extents->x1 = x1;
+	else
+	{
+	    x_overlap = TRUE;
+	    if (x1 < extents->x1)
+		extents->x1 = x1;
+	    if (x2 > extents->x2)
+		extents->x2 = x2;
+	}
+
+	if (y1 >= extents->y2)
+	    extents->y2 = y2;
+	else if (y2 <= extents->y1)
+	    extents->y1 = y1;
+	else
+	{
+	    if (y1 < extents->y1)
+		extents->y1 = y1;
+	    if (y2 > extents->y2)
+		extents->y2 = y2;
+
+	    if (x_overlap)
+		overlap = TRUE;
+	}
+    }
+
+    xglPictureClipExtents (pDst, extents);
+
+    return overlap;
+}
+
+void
+xglTrapezoids (CARD8	     op,
+	       PicturePtr    pSrc,
+	       PicturePtr    pDst,
+	       PictFormatPtr maskFormat,
+	       INT16	     xSrc,
+	       INT16	     ySrc,
+	       int	     nTrap,
+	       xTrapezoid    *traps)
+{
+    ScreenPtr	    pScreen = pDst->pDrawable->pScreen;
+    PicturePtr	    pMask = NULL, pSrcPicture, pDstPicture;
+    PicturePtr	    pMaskPicture = NULL;
+    xglGeometryPtr  pGeometry = NULL;
+    unsigned int    polyEdge = pDst->polyEdge;
+    INT16	    xDst, yDst;
+    INT16	    xOff, yOff;
+    BoxRec	    extents;
+    Bool	    overlap;
+    Bool	    target;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    xDst = traps[0].left.p1.x >> 16;
+    yDst = traps[0].left.p1.y >> 16;
+
+    overlap = xglTrapezoidExtents (pDst, nTrap, traps, &extents);
+    if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
+	return;
+
+    target = xglPrepareTarget (pDst->pDrawable);
+
+    if (nTrap > 1 && op != PictOpAdd && maskFormat &&
+	(!target || overlap || op != PictOpOver))
+    {
+	PixmapPtr  pPixmap;
+	GCPtr	   pGC;
+	xRectangle rect;
+	int	   error;
+	int	   area;
+
+	if (!pScreenPriv->pSolidAlpha)
+	{
+	    xglCreateSolidAlphaPicture (pScreen);
+	    if (!pScreenPriv->pSolidAlpha)
+		return;
+	}
+
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = extents.x2 - extents.x1;
+	rect.height = extents.y2 - extents.y1;
+
+	pPixmap = (*pScreen->CreatePixmap) (pScreen,
+					    rect.width, rect.height,
+					    maskFormat->depth);
+	if (!pPixmap)
+	    return;
+
+	pMask = CreatePicture (0, &pPixmap->drawable, maskFormat,
+			       0, 0, serverClient, &error);
+	if (!pMask)
+	{
+	    (*pScreen->DestroyPixmap) (pPixmap);
+	    return;
+	}
+
+	if (!target)
+	{
+	    /* make sure we don't do accelerated drawing to mask */
+	    xglSetPixmapVisual (pPixmap, NULL);
+	}
+
+	area = rect.width * rect.height;
+	if ((SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > area)
+	    XGL_GET_PIXMAP_PRIV (pPixmap)->target = xglPixmapTargetNo;
+
+	ValidatePicture (pMask);
+	pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+	ValidateGC (&pPixmap->drawable, pGC);
+	(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &rect);
+	FreeScratchGC (pGC);
+
+	(*pScreen->DestroyPixmap) (pPixmap);
+
+	target = xglPrepareTarget (pMask->pDrawable);
+
+	xOff = -extents.x1;
+	yOff = -extents.y1;
+	pSrcPicture = pScreenPriv->pSolidAlpha;
+	pDstPicture = pMask;
+    }
+    else
+    {
+	if (maskFormat)
+	{
+	    if (maskFormat->depth == 1)
+		polyEdge = PolyEdgeSharp;
+	    else
+		polyEdge = PolyEdgeSmooth;
+	}
+
+	xOff = 0;
+	yOff = 0;
+	pSrcPicture = pSrc;
+	pDstPicture = pDst;
+    }
+
+    if (target)
+    {
+	if (maskFormat || polyEdge == PolyEdgeSmooth)
+	{
+	    glitz_vertex_format_t *format;
+	    glitz_surface_t	  *mask;
+	    xTrapezoid		  *pTrap = traps;
+	    int			  nAddedTrap, n = nTrap;
+	    int			  offset = 0;
+	    int			  size = SMOOTH_TRAPS_ESTIMATE_RECTS (n);
+
+	    pMaskPicture = pScreenPriv->trapInfo.pMask;
+	    format = &pScreenPriv->trapInfo.format.vertex;
+	    mask = pMaskPicture->pSourcePict->source.devPrivate.ptr;
+
+	    size *= format->bytes_per_vertex;
+	    pGeometry = xglGetScratchGeometryWithSize (pScreen, size);
+
+	    while (n)
+	    {
+		if (pGeometry->size < size)
+		    GEOMETRY_RESIZE (pScreen, pGeometry, size);
+
+		if (!pGeometry->buffer)
+		{
+		    if (pMask)
+			FreePicture (pMask, 0);
+
+		    return;
+		}
+
+		offset +=
+		    glitz_add_trapezoids (pGeometry->buffer,
+					  offset, size - offset, format->type,
+					  mask, (glitz_trapezoid_t *) pTrap, n,
+					  &nAddedTrap);
+
+		n     -= nAddedTrap;
+		pTrap += nAddedTrap;
+		size  *= 2;
+	    }
+
+	    pGeometry->f     = pScreenPriv->trapInfo.format;
+	    pGeometry->count = offset / format->bytes_per_vertex;
+	}
+	else
+	{
+	    pGeometry =
+		xglGetScratchVertexGeometryWithType (pScreen,
+						     GEOMETRY_DATA_TYPE_FLOAT,
+						     4 * nTrap);
+	    if (!pGeometry->buffer)
+	    {
+		if (pMask)
+		    FreePicture (pMask, 0);
+
+		return;
+	    }
+
+	    GEOMETRY_ADD_TRAPEZOID (pScreen, pGeometry, traps, nTrap);
+	}
+
+	GEOMETRY_TRANSLATE (pGeometry,
+			    pDstPicture->pDrawable->x + xOff,
+			    pDstPicture->pDrawable->y + yOff);
+    }
+
+    if (pGeometry &&
+	xglCompositeGeneral (pMask ? PictOpAdd : op,
+			     pSrcPicture,
+			     pMaskPicture,
+			     pDstPicture,
+			     pGeometry,
+			     extents.x1 + xOff + xSrc - xDst,
+			     extents.y1 + yOff + ySrc - yDst,
+			     0, 0,
+			     pDstPicture->pDrawable->x + extents.x1 + xOff,
+			     pDstPicture->pDrawable->y + extents.y1 + yOff,
+			     extents.x2 - extents.x1,
+			     extents.y2 - extents.y1))
+    {
+	/* no intermediate mask? we need to register damage from here as
+	   CompositePicture will never be called. */
+	if (!pMask)
+	{
+	    RegionRec region;
+
+	    REGION_INIT (pScreen, &region, &extents, 1);
+	    REGION_TRANSLATE (pScreen, &region,
+			      pDst->pDrawable->x, pDst->pDrawable->y);
+
+	    DamageDamageRegion (pDst->pDrawable, &region);
+
+	    REGION_UNINIT (pScreen, &region);
+	}
+
+	xglAddCurrentBitDamage (pDstPicture->pDrawable);
+    }
+    else
+    {
+	XGL_DRAWABLE_PIXMAP_PRIV (pDstPicture->pDrawable);
+
+	pPixmapPriv->damageBox.x1 = extents.x1 + xOff;
+	pPixmapPriv->damageBox.y1 = extents.y1 + yOff;
+	pPixmapPriv->damageBox.x2 = extents.x2 + xOff;
+	pPixmapPriv->damageBox.y2 = extents.y2 + yOff;
+
+	xglSyncDamageBoxBits (pDstPicture->pDrawable);
+
+	if (pMask || (polyEdge == PolyEdgeSmooth &&
+		      op == PictOpAdd && miIsSolidAlpha (pSrc)))
+	{
+	    PictureScreenPtr ps = GetPictureScreen (pScreen);
+
+	    for (; nTrap; nTrap--, traps++)
+		(*ps->RasterizeTrapezoid) (pDstPicture, traps, xOff, yOff);
+
+	    xglAddCurrentSurfaceDamage (pDstPicture->pDrawable);
+	}
+	else
+	    miTrapezoids (op, pSrc, pDstPicture, maskFormat,
+			  xSrc, ySrc, nTrap, traps);
+    }
+
+    if (pMask)
+    {
+	CompositePicture (op, pSrc, pMask, pDst,
+			  extents.x1 + xSrc - xDst,
+			  extents.y1 + ySrc - yDst,
+			  0, 0,
+			  extents.x1, extents.y1,
+			  extents.x2 - extents.x1,
+			  extents.y2 - extents.y1);
+
+	FreePicture (pMask, 0);
+    }
+}
+
+void
+xglAddTraps (PicturePtr pDst,
+	     INT16	xOff,
+	     INT16	yOff,
+	     int	nTrap,
+	     xTrap	*traps)
+{
+    PictureScreenPtr pPictureScreen;
+    ScreenPtr	     pScreen = pDst->pDrawable->pScreen;
+
+    XGL_SCREEN_PRIV (pScreen);
+    XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
+
+    if (!pScreenPriv->pSolidAlpha)
+    {
+	xglCreateSolidAlphaPicture (pScreen);
+	if (!pScreenPriv->pSolidAlpha)
+	    return;
+    }
+
+    pPixmapPriv->damageBox.x1 = 0;
+    pPixmapPriv->damageBox.y1 = 0;
+    pPixmapPriv->damageBox.x2 = pDst->pDrawable->width;
+    pPixmapPriv->damageBox.y2 = pDst->pDrawable->height;
+
+    if (xglPrepareTarget (pDst->pDrawable))
+    {
+	PicturePtr	      pMask;
+	glitz_vertex_format_t *format;
+	glitz_surface_t	      *mask;
+	xglGeometryPtr	      pGeometry;
+	xTrap		      *pTrap = traps;
+	int		      nAddedTrap, n = nTrap;
+	int		      offset = 0;
+	int		      size = SMOOTH_TRAPS_ESTIMATE_RECTS (n);
+
+	pMask = pScreenPriv->trapInfo.pMask;
+	format = &pScreenPriv->trapInfo.format.vertex;
+	mask = pMask->pSourcePict->source.devPrivate.ptr;
+
+	size *= format->bytes_per_vertex;
+	pGeometry = xglGetScratchGeometryWithSize (pScreen, size);
+
+	while (n)
+	{
+	    if (pGeometry->size < size)
+		GEOMETRY_RESIZE (pScreen, pGeometry, size);
+
+	    if (!pGeometry->buffer)
+		return;
+
+	    offset +=
+		glitz_add_traps (pGeometry->buffer,
+				 offset, size - offset, format->type, mask,
+				 (glitz_trap_t *) pTrap, n,
+				 &nAddedTrap);
+
+	    n     -= nAddedTrap;
+	    pTrap += nAddedTrap;
+	    size  *= 2;
+	}
+
+	pGeometry->f     = pScreenPriv->trapInfo.format;
+	pGeometry->count = offset / format->bytes_per_vertex;
+
+	GEOMETRY_TRANSLATE (pGeometry,
+			    pDst->pDrawable->x + xOff,
+			    pDst->pDrawable->y + yOff);
+
+	if (xglCompositeGeneral (PictOpAdd,
+				 pScreenPriv->pSolidAlpha,
+				 pMask,
+				 pDst,
+				 pGeometry,
+				 0, 0,
+				 0, 0,
+				 pDst->pDrawable->x, pDst->pDrawable->y,
+				 pDst->pDrawable->width,
+				 pDst->pDrawable->height))
+	{
+	    xglAddCurrentBitDamage (pDst->pDrawable);
+	    return;
+	}
+    }
+
+    pPictureScreen = GetPictureScreen (pScreen);
+
+    XGL_TRAP_FALLBACK_PROLOGUE (pDst, AddTraps);
+    (*pPictureScreen->AddTraps) (pDst, xOff, yOff, nTrap, traps);
+    XGL_TRAP_FALLBACK_EPILOGUE (pDst, AddTraps, xglAddTraps);
+}
+
+#endif
diff --git a/xgl/xglwindow.c b/xgl/xglwindow.c
new file mode 100644
index 0000000..393f01d
--- /dev/null
+++ b/xgl/xglwindow.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright © 2004 David Reveman
+ *
+ * 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
+ * David Reveman not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * David Reveman makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr at novell.com>
+ */
+
+#include "xgl.h"
+#include "fb.h"
+
+#define XGL_WINDOW_FALLBACK_PROLOGUE(pWin, func)		       \
+    if (!xglMapPixmapBits (XGL_GET_DRAWABLE_PIXMAP (&pWin->drawable))) \
+	FatalError (XGL_SW_FAILURE_STRING);			       \
+    XGL_SCREEN_UNWRAP (func)
+
+#define XGL_WINDOW_FALLBACK_EPILOGUE(pWin, pRegion, func, xglfunc) \
+    XGL_SCREEN_WRAP (func, xglfunc);				   \
+    xglAddSurfaceDamage (&pWin->drawable, pRegion)
+
+Bool
+xglCreateWindow (WindowPtr pWin)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    Bool      ret;
+
+    XGL_SCREEN_PRIV (pScreen);
+    XGL_WINDOW_PRIV (pWin);
+
+    XGL_SCREEN_UNWRAP (CreateWindow);
+    ret = (*pScreen->CreateWindow) (pWin);
+    XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
+
+    pWinPriv->pPixmap = pWin->drawable.pScreen->devPrivate;
+
+    return ret;
+}
+
+Bool
+xglDestroyWindow (WindowPtr pWin)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    Bool      ret;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    XGL_SCREEN_UNWRAP (DestroyWindow);
+    ret = (*pScreen->DestroyWindow) (pWin);
+    XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
+
+    return ret;
+}
+
+Bool
+xglChangeWindowAttributes (WindowPtr	 pWin,
+			   unsigned long mask)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    PixmapPtr pPixmap;
+    Bool      ret;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    if (mask & CWBackPixmap)
+    {
+	if (pWin->backgroundState == BackgroundPixmap)
+	{
+	    pPixmap = pWin->background.pixmap;
+
+	    if (FbEvenTile (pPixmap->drawable.width *
+			    pPixmap->drawable.bitsPerPixel))
+		xglSyncBits (&pPixmap->drawable, NULL);
+	}
+    }
+
+    if (mask & CWBorderPixmap)
+    {
+	if (pWin->borderIsPixel == FALSE)
+	{
+	    pPixmap = pWin->border.pixmap;
+
+	    if (FbEvenTile (pPixmap->drawable.width *
+			    pPixmap->drawable.bitsPerPixel))
+		xglSyncBits (&pPixmap->drawable, NULL);
+	}
+    }
+
+    XGL_SCREEN_UNWRAP (ChangeWindowAttributes);
+    ret = (*pScreen->ChangeWindowAttributes) (pWin, mask);
+    XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
+
+    return ret;
+}
+
+void
+xglCopyWindow (WindowPtr   pWin,
+	       DDXPointRec ptOldOrg,
+	       RegionPtr   prgnSrc)
+{
+    PixmapPtr pPixmap;
+    RegionRec rgnDst;
+    int	      dx, dy;
+    BoxPtr    pExtent = REGION_EXTENTS (pWin->drawable.pScreen, prgnSrc);
+    BoxRec    box;
+
+    pPixmap = XGL_GET_WINDOW_PIXMAP (pWin);
+
+    box.x1 = pExtent->x1;
+    box.y1 = pExtent->y1;
+    box.x2 = pExtent->x2;
+    box.y2 = pExtent->y2;
+
+    dx = ptOldOrg.x - pWin->drawable.x;
+    dy = ptOldOrg.y - pWin->drawable.y;
+
+    REGION_TRANSLATE (pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+    REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
+    REGION_INTERSECT (pWin->drawable.pScreen,
+		      &rgnDst, &pWin->borderClip, prgnSrc);
+
+    fbCopyRegion (&pWin->drawable, &pWin->drawable,
+		  0, &rgnDst, dx, dy, xglCopyProc, 0, (void *) &box);
+
+    REGION_UNINIT (pWin->drawable.pScreen, &rgnDst);
+}
+
+PixmapPtr
+xglGetWindowPixmap (WindowPtr pWin)
+{
+    return XGL_GET_WINDOW_PIXMAP (pWin);
+}
+
+void
+xglSetWindowPixmap (WindowPtr pWin,
+		    PixmapPtr pPixmap)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    XGL_SCREEN_UNWRAP (SetWindowPixmap);
+    (*pScreen->SetWindowPixmap) (pWin, pPixmap);
+    XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap);
+
+    XGL_GET_WINDOW_PRIV (pWin)->pPixmap = pPixmap;
+
+    if (pPixmap != pScreenPriv->pScreenPixmap)
+	xglEnablePixmapAccel (pPixmap, &pScreenPriv->accel.window);
+}
diff --git a/xgl/xglxv.c b/xgl/xglxv.c
new file mode 100644
index 0000000..b9f96f3
--- /dev/null
+++ b/xgl/xglxv.c
@@ -0,0 +1,722 @@
+/*
+ * Copyright © 2005 Novell, Inc.
+ *
+ * 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
+ * Novell, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Novell, Inc. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NOVELL, INC. 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.
+ *
+ * Authors: David Reveman <davidr at novell.com>
+ *          Matthias Hopf <mhopf at suse.de>
+ */
+
+#include "xgl.h"
+
+#ifdef XV
+
+#include "xvdix.h"
+#include "gcstruct.h"
+#include "dixstruct.h"
+
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+
+static unsigned int  xglXvScreenIndex = 0;
+static unsigned long portResource = 0;
+
+#define XGL_GET_XV_SCREEN(pScreen)				   \
+    ((XvScreenPtr) ((pScreen)->devPrivates[xglXvScreenIndex].ptr))
+
+#define XGL_XV_SCREEN(pScreen)				\
+    XvScreenPtr pXvScreen = XGL_GET_XV_SCREEN (pScreen)
+
+#define XGL_GET_XV_SCREEN_PRIV(pScreen)			      \
+    ((xglXvScreenPtr) (GET_XV_SCREEN (pScreen)->devPriv.ptr))
+
+#define XGL_XV_SCREEN_PRIV(pScreen)				    \
+    xglXvScreenPtr pXvScreenPriv = XGL_GET_XV_SCREEN_PRIV (pScreen)
+
+#define XGL_GET_XV_PORT_PRIV(pPort)	    \
+    ((xglXvPortPtr) ((pPort)->devPriv.ptr))
+
+#define XGL_XV_PORT_PRIV(pPort)				  \
+    xglXvPortPtr pPortPriv = XGL_GET_XV_PORT_PRIV (pPort)
+
+#define XGL_XV_NUM_PORTS 32
+
+#define XGL_XV_IMAGE_MAX_WIDTH  2048
+#define XGL_XV_IMAGE_MAX_HEIGHT 2048
+
+static XvImageRec xvImages[] = {
+    {
+	GLITZ_FOURCC_YUY2, XvYUV, BITMAP_BIT_ORDER,
+	{
+	    'Y','U','Y','2',
+	    0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
+	    0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
+	},
+	16, XvPacked, 1,
+	0, 0, 0, 0,
+	8, 8, 8,  1, 2, 2,  1, 1, 1,
+	{
+	    'Y', 'U', 'Y', 'V',
+	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	},
+	XvTopToBottom
+    }, {
+	GLITZ_FOURCC_YV12, XvYUV, BITMAP_BIT_ORDER,
+	{
+	    'Y', 'V', '1', '2',
+	    0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
+	    0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
+	},
+	12, XvPlanar, 3,
+	0, 0, 0, 0,
+	8, 8, 8,  1, 2, 2,  1, 2, 2,
+	{
+	    'Y', 'V', 'U', 0,
+	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	},
+	XvTopToBottom
+    }, {
+	GLITZ_FOURCC_RGB, XvRGB, BITMAP_BIT_ORDER,
+	{
+	    0x03, 0x00, 0x00, 0x00,
+	    0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
+	    0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
+	},
+	32, XvPacked, 1,
+	24, 0xff0000, 0xff00, 0xff,
+	0, 0, 0,  0, 0, 0,  0, 0, 0,
+	{
+	    0, 0, 0, 0,
+	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	},
+	XvTopToBottom
+    }
+};
+
+static struct _xglXvFormat {
+    CARD32	      format;
+    glitz_fourcc_t    fourcc;
+    xglPixelFormatRec pixel;
+} xglXvFormat[XGL_XV_FORMAT_NUM] = {
+    {
+	PICT_yuy2,
+	GLITZ_FOURCC_YUY2,
+	{
+	    16, 6,
+	    {
+		16,
+		0x00000000,
+		0x00000000,
+		0x00000000,
+		0x00000000,
+	    }
+	}
+    }, {
+	PICT_yv12,
+	GLITZ_FOURCC_YV12,
+	{
+	    12, 4,
+	    {
+		12,
+		0x00000000,
+		0x00000000,
+		0x00000000,
+		0x00000000,
+	    }
+	}
+    }, {
+	PICT_x8r8g8b8,
+	GLITZ_FOURCC_RGB,
+	{
+	    24, 8,
+	    {
+		32,
+		0x00000000,
+		0x00ff0000,
+		0x0000ff00,
+		0x000000ff,
+	    }
+	}
+    }
+};
+
+static int
+xglXvQueryAdaptors (ScreenPtr	 pScreen,
+		    XvAdaptorPtr *pAdaptors,
+		    int		 *nAdaptors)
+{
+    XGL_XV_SCREEN (pScreen);
+
+    *nAdaptors = pXvScreen->nAdaptors;
+    *pAdaptors = pXvScreen->pAdaptors;
+
+    return Success;
+}
+
+static int
+xglXvAllocatePort (unsigned long port,
+		   XvPortPtr	 pPort,
+		   XvPortPtr	 *ppPort)
+{
+    *ppPort = pPort;
+
+    return Success;
+}
+
+static int
+xglXvFreePort (XvPortPtr pPort)
+{
+    XGL_XV_PORT_PRIV (pPort);
+
+    if (pPortPriv->pDst)
+    {
+	FreePicture ((pointer) pPortPriv->pDst, 0);
+	pPortPriv->pDst = (PicturePtr) 0;
+    }
+
+    if (pPortPriv->pSrc)
+    {
+	FreePicture ((pointer) pPortPriv->pSrc, 0);
+	pPortPriv->pSrc = (PicturePtr) 0;
+    }
+
+    if (pPortPriv->pTmp)
+    {
+	FreePicture ((pointer) pPortPriv->pTmp, 0);
+	pPortPriv->pTmp = (PicturePtr) 0;
+    }
+
+    if (pPortPriv->pPixmap)
+    {
+	ScreenPtr pScreen;
+
+	pScreen = pPortPriv->pPixmap->drawable.pScreen;
+	(*pScreen->DestroyPixmap) (pPortPriv->pPixmap);
+	pPortPriv->pPixmap = (PixmapPtr) 0;
+    }
+
+    return Success;
+}
+
+static int
+xglXvQueryBestSize (ClientPtr	 client,
+		    XvPortPtr	 pPort,
+		    CARD8	 motion,
+		    CARD16	 srcWidth,
+		    CARD16	 srcHeight,
+		    CARD16	 dstWidth,
+		    CARD16	 dstHeight,
+		    unsigned int *pWidth,
+		    unsigned int *pHeight)
+{
+    *pWidth  = dstWidth;
+    *pHeight = dstHeight;
+
+    return Success;
+}
+
+static int
+xglXvStopVideo (ClientPtr   client,
+		XvPortPtr   pPort,
+		DrawablePtr pDrawable)
+{
+    xglXvFreePort (pPort);
+
+    return Success;
+}
+
+static PicturePtr
+xglXvCreateDstPict (DrawablePtr pDrawable,
+		    Mask	vmask,
+		    XID		*vlist,
+		    int		*error)
+{
+    ScreenPtr     pScreen = pDrawable->pScreen;
+    PictFormatPtr pFormat = 0;
+    int		  i;
+
+    for (i = 0; i < pScreen->numVisuals; i++)
+    {
+	if (pScreen->visuals[i].nplanes == pDrawable->depth)
+	{
+	    pFormat = PictureMatchVisual (pScreen, pDrawable->depth,
+					  &pScreen->visuals[i]);
+	    break;
+	}
+    }
+
+    if (!pFormat)
+    {
+	*error = BadImplementation;
+	return (PicturePtr) 0;
+    }
+
+    return CreatePicture (0, pDrawable,
+			  pFormat, vmask, vlist, serverClient,
+			  error);
+}
+
+static int
+xglXvPutImage (ClientPtr     client,
+	       DrawablePtr   pDrawable,
+	       XvPortPtr     pPort,
+	       GCPtr	     pGC,
+	       INT16	     srcX,
+	       INT16	     srcY,
+	       CARD16	     srcWidth,
+	       CARD16	     srcHeight,
+	       INT16	     dstX,
+	       INT16	     dstY,
+	       CARD16	     dstWidth,
+	       CARD16	     dstHeight,
+	       XvImagePtr    pImage,
+	       unsigned char *data,
+	       Bool	     sync,
+	       CARD16	     width,
+	       CARD16	     height)
+{
+    ScreenPtr	  pScreen = pDrawable->pScreen;
+    PicturePtr	  pSrc;
+    PictTransform transform;
+    int		  depth, bpp, stride, noVisual = FALSE;
+    CARD32	  format;
+
+    XGL_SCREEN_PRIV (pScreen);
+    XGL_XV_PORT_PRIV (pPort);
+    XGL_DRAWABLE_PIXMAP (pDrawable);
+    XGL_PIXMAP_PRIV (pPixmap);
+
+    stride = ((width + 7) & ~7);
+
+    switch (pImage->id) {
+    case GLITZ_FOURCC_YUY2:
+	bpp = depth = 16;
+	format = PICT_yuy2;
+	noVisual = !pScreenPriv->pXvVisual[XGL_XV_FORMAT_YUY2].format.surface;
+	stride *= 2;
+	break;
+    case GLITZ_FOURCC_YV12:
+	depth = bpp = 12;
+	format = PICT_yv12;
+	noVisual = !pScreenPriv->pXvVisual[XGL_XV_FORMAT_YV12].format.surface;
+	break;
+    case GLITZ_FOURCC_RGB:
+	depth = 24;
+	bpp = 32;
+	format = PICT_x8r8g8b8;
+	stride *= 4;
+	break;
+    default:
+	return BadImplementation;
+    }
+
+    pPort->pDraw = pDrawable;
+
+    if (!pPortPriv->pPixmap)
+    {
+	pPortPriv->pPixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth);
+	if (!pPortPriv->pPixmap)
+	    return BadAlloc;
+    }
+
+    (*pScreen->ModifyPixmapHeader) (pPortPriv->pPixmap,
+				    srcWidth, srcHeight,
+				    depth, bpp, -1, (pointer) data);
+
+    XGL_GET_PIXMAP_PRIV (pPortPriv->pPixmap)->stride = -stride;
+
+    pPortPriv->pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+    if (!pPortPriv->pSrc || pPortPriv->pSrc->format != format)
+    {
+	PictFormatPtr pFormat;
+	int	      error;
+	static XID    value = RepeatPad;
+
+	pFormat = PictureMatchFormat (pScreen, depth, format);
+	if (!pFormat)
+	    return BadImplementation;
+
+	if (pPortPriv->pSrc)
+	    FreePicture ((pointer) pPortPriv->pSrc, 0);
+
+	pPortPriv->pSrc = CreatePicture (0, &pPortPriv->pPixmap->drawable,
+					 pFormat, CPRepeat, &value,
+					 serverClient, &error);
+	if (!pPortPriv->pSrc)
+	{
+	    xglXvFreePort (pPort);
+	    return error;
+	}
+
+	SetPictureFilter (pPortPriv->pSrc,
+			  pScreenPriv->xvFilter,
+			  strlen (pScreenPriv->xvFilter),
+			  0, 0);
+    }
+
+    pSrc = pPortPriv->pSrc;
+
+    if (!pPortPriv->pDst || pPortPriv->pDst->pDrawable != pDrawable)
+    {
+	int error;
+
+	if (pPortPriv->pDst)
+	    FreePicture ((pointer) pPortPriv->pDst, 0);
+
+	pPortPriv->pDst = xglXvCreateDstPict (pDrawable, 0, NULL, &error);
+	if (!pPortPriv->pDst)
+	{
+	    xglXvFreePort (pPort);
+	    return error;
+	}
+    }
+
+    if (pPixmap != pScreenPriv->pScreenPixmap && !pPixmapPriv->target)
+	xglEnablePixmapAccel (pPixmap, &pScreenPriv->accel.xv);
+
+    /* software color-space conversion */
+    if (pPixmapPriv->target && (noVisual || pScreenPriv->noYuv))
+    {
+	if (!pPortPriv->pTmp				   ||
+	    srcWidth  != pPortPriv->pTmp->pDrawable->width ||
+	    srcHeight != pPortPriv->pTmp->pDrawable->height)
+	{
+	    static XID value = RepeatPad;
+	    int	       error;
+
+	    if (pPortPriv->pTmp)
+		FreePicture ((pointer) pPortPriv->pTmp, 0);
+
+	    pPixmap = (*pScreen->CreatePixmap) (pScreen,
+						srcWidth, srcHeight,
+						pDrawable->depth);
+	    if (!pPixmap)
+	    {
+		xglXvFreePort (pPort);
+		return BadAlloc;
+	    }
+
+	    pPortPriv->pTmp = xglXvCreateDstPict (&pPixmap->drawable,
+						  CPRepeat, &value,
+						  &error);
+	    if (!pPortPriv->pTmp)
+	    {
+		(*pScreen->DestroyPixmap) (pPixmap);
+		xglXvFreePort (pPort);
+		return error;
+	    }
+
+	    /* no accelerated drawing */
+	    XGL_GET_PIXMAP_PRIV (pPixmap)->target = xglPixmapTargetNo;
+
+	    (*pScreen->DestroyPixmap) (pPixmap);
+
+	    SetPictureFilter (pPortPriv->pTmp,
+			      pScreenPriv->xvFilter,
+			      strlen (pScreenPriv->xvFilter),
+			      0, 0);
+	}
+
+	SetPictureTransform (pSrc, 0);
+
+	CompositePicture (PictOpSrc,
+			  pSrc,
+			  (PicturePtr) 0,
+			  pPortPriv->pTmp,
+			  0, 0,
+			  0, 0,
+			  0, 0,
+			  srcWidth, srcHeight);
+
+	pSrc = pPortPriv->pTmp;
+    }
+
+    transform.matrix[0][0] = ((srcWidth << 16) + (dstWidth >> 1))
+			     / dstWidth;
+    transform.matrix[0][1] = 0;
+    transform.matrix[0][2] = 0;
+
+    /* flip Y */
+    transform.matrix[1][0] = 0;
+    transform.matrix[1][1] = -((srcHeight << 16) + (dstHeight >> 1))
+			     / dstHeight;
+    transform.matrix[1][2] = (srcHeight << 16);
+
+    transform.matrix[2][0] = 0;
+    transform.matrix[2][1] = 0;
+    transform.matrix[2][2] = 1 << 16;
+
+    SetPictureTransform (pSrc, &transform);
+
+    CompositePicture (PictOpSrc,
+		      pSrc,
+		      (PicturePtr) 0,
+		      pPortPriv->pDst,
+		      srcX, srcY,
+		      0, 0,
+		      dstX, dstY,
+		      dstWidth, dstHeight);
+
+    return Success;
+}
+
+static int
+xglXvQueryImageAttributes (ClientPtr  client,
+			   XvPortPtr  pPort,
+			   XvImagePtr pImage,
+			   CARD16     *width,
+			   CARD16     *height,
+			   int	      *pitches,
+			   int	      *offsets)
+{
+    if (*width > XGL_XV_IMAGE_MAX_WIDTH)
+	*width = XGL_XV_IMAGE_MAX_WIDTH;
+
+    if (*height > XGL_XV_IMAGE_MAX_HEIGHT)
+	*height = XGL_XV_IMAGE_MAX_HEIGHT;
+
+    *width = (*width + 7) & ~7;
+
+    switch (pImage->id) {
+    case GLITZ_FOURCC_YUY2:
+	if (offsets)
+	    offsets[0] = 0;
+
+	if (pitches)
+	    pitches[0] = *width * 2;
+
+	return *width * *height * 2;
+    case GLITZ_FOURCC_YV12:
+	*height = (*height + 1) & ~1;
+
+	if (offsets)
+	{
+	    offsets[0] = 0;
+	    offsets[1] = *width * *height;
+	    offsets[2] = *width * *height + (*width >> 1) * (*height >> 1);
+	}
+
+	if (pitches)
+	{
+	    pitches[0] = *width;
+	    pitches[1] = pitches[2] = *width >> 1;
+	}
+
+	return *width * *height + (*width >> 1) * *height;
+    case GLITZ_FOURCC_RGB:
+	if (offsets)
+	    offsets[0] = 0;
+
+	if (pitches)
+	    pitches[0] = *width * 4;
+
+	return *width * *height * 4;
+    default:
+	return 0;
+    }
+}
+
+static void
+xglXvFreeAdaptor (XvAdaptorPtr pAdaptor)
+{
+    xfree (pAdaptor->pEncodings);
+    xfree (pAdaptor->pFormats);
+
+    if (pAdaptor->pPorts)
+	xfree (pAdaptor->pPorts);
+}
+
+static Bool
+xglXvInitAdaptors (ScreenPtr pScreen)
+{
+    XvAdaptorPtr  pAdaptor;
+    xglXvPortPtr  pPortPriv;
+    XvPortPtr     pPort;
+    XvFormatPtr   pFormat;
+    XvEncodingPtr pEncoding;
+    int		  i;
+
+    XGL_XV_SCREEN (pScreen);
+
+    pXvScreen->nAdaptors = 0;
+    pXvScreen->pAdaptors = NULL;
+
+    pAdaptor = xcalloc (1, sizeof (XvAdaptorRec));
+    if (!pAdaptor)
+	return FALSE;
+
+    pAdaptor->type    = XvInputMask | XvImageMask;
+    pAdaptor->pScreen = pScreen;
+
+    pAdaptor->ddAllocatePort	     = xglXvAllocatePort;
+    pAdaptor->ddFreePort	     = xglXvFreePort;
+    pAdaptor->ddStopVideo	     = xglXvStopVideo;
+    pAdaptor->ddPutImage	     = xglXvPutImage;
+    pAdaptor->ddQueryBestSize	     = xglXvQueryBestSize;
+    pAdaptor->ddQueryImageAttributes = xglXvQueryImageAttributes;
+
+    pAdaptor->name = "Xgl Generic Texture Video";
+
+    pEncoding = xcalloc (1, sizeof (XvEncodingRec));
+    if (!pEncoding)
+	return FALSE;
+
+    pEncoding->id      = 0;
+    pEncoding->pScreen = pScreen;
+    pEncoding->name    = "XV_IMAGE";
+
+    pEncoding->width  = XGL_XV_IMAGE_MAX_WIDTH;
+    pEncoding->height = XGL_XV_IMAGE_MAX_HEIGHT;
+
+    pEncoding->rate.numerator	= 1;
+    pEncoding->rate.denominator = 1;
+
+    pAdaptor->nEncodings = 1;
+    pAdaptor->pEncodings = pEncoding;
+
+    pAdaptor->nImages = sizeof (xvImages) / sizeof (XvImageRec);
+    pAdaptor->pImages = xvImages;
+
+    /* TODO: Currently no attributes */
+    pAdaptor->nAttributes = 0;
+    pAdaptor->pAttributes = 0;
+
+    pFormat = xcalloc (pScreen->numVisuals, sizeof (XvFormatRec));
+    if (!pFormat)
+	return FALSE;
+
+    for (i = 0; i < pScreen->numVisuals; i++)
+    {
+	pFormat[i].depth  = pScreen->visuals[i].nplanes;
+	pFormat[i].visual = pScreen->visuals[i].vid;
+    }
+
+    /* All visuals allowed */
+    pAdaptor->nFormats = pScreen->numVisuals;
+    pAdaptor->pFormats = pFormat;
+
+    pPort = xcalloc (XGL_XV_NUM_PORTS,
+		     sizeof (XvPortRec) + sizeof (xglXvPortRec));
+    pPortPriv = (xglXvPortPtr) (pPort + XGL_XV_NUM_PORTS);
+    if (!pPort)
+	return FALSE;
+
+    for (i = 0; i < XGL_XV_NUM_PORTS; i++)
+    {
+	pPort[i].id = FakeClientID (0);
+	if (!pPort[i].id)
+	    return FALSE;
+
+	if (!AddResource (pPort[i].id, portResource, &pPort[i]))
+	    return FALSE;
+
+	pPort[i].pAdaptor    = pAdaptor;
+	pPort[i].pNotify     = (XvPortNotifyPtr) 0;
+	pPort[i].pDraw	     = (DrawablePtr) 0;
+	pPort[i].client      = (ClientPtr) 0;
+	pPort[i].grab.client = (ClientPtr) 0;
+	pPort[i].time	     = currentTime;
+	pPort[i].devPriv.ptr = pPortPriv + i;
+    }
+
+    pAdaptor->nPorts  = XGL_XV_NUM_PORTS;
+    pAdaptor->pPorts  = pPort;
+    pAdaptor->base_id = pPort->id;
+
+    pXvScreen->pAdaptors = pAdaptor;
+    pXvScreen->nAdaptors = 1;
+
+    return TRUE;
+}
+
+static Bool
+xglXvCloseScreen (int i, ScreenPtr pScreen)
+{
+    int	j;
+
+    XGL_XV_SCREEN (pScreen);
+
+    for (j = 0; j < pXvScreen->nAdaptors; j++)
+	xglXvFreeAdaptor (&pXvScreen->pAdaptors[j]);
+
+    if (pXvScreen->pAdaptors)
+	xfree (pXvScreen->pAdaptors);
+
+    return TRUE;
+}
+
+Bool
+xglXvScreenInit (ScreenPtr pScreen)
+{
+    XvScreenPtr  pXvScreen;
+    xglVisualPtr v;
+    int		 i, status, vid = 0;
+
+    XGL_SCREEN_PRIV (pScreen);
+
+    status = XvScreenInit (pScreen);
+    if (status != Success)
+	return FALSE;
+
+    xglXvScreenIndex = XvGetScreenIndex ();
+    portResource = XvGetRTPort ();
+
+    pXvScreen = XGL_GET_XV_SCREEN (pScreen);
+
+    /* Anyone initializing the Xv layer must provide these two.
+       The Xv di layer calls them without even checking if they exist! */
+    pXvScreen->ddCloseScreen   = xglXvCloseScreen;
+    pXvScreen->ddQueryAdaptors = xglXvQueryAdaptors;
+
+    pXvScreen->devPriv.ptr = (pointer) 0;
+
+    if (!xglXvInitAdaptors (pScreen))
+	return FALSE;
+
+    for (v = pScreenPriv->pVisual; v; v = v->next)
+    {
+	if (v->vid > vid)
+	    vid = v->vid;
+    }
+
+    memset (pScreenPriv->pXvVisual, 0, sizeof (pScreenPriv->pXvVisual));
+
+    for (i = 0; i < XGL_XV_FORMAT_NUM; i++)
+    {
+	glitz_format_t templ;
+
+	templ.color.fourcc = xglXvFormat[i].fourcc;
+
+	pScreenPriv->pXvVisual[i].vid = ++vid;
+	pScreenPriv->pXvVisual[i].pPixel = &xglXvFormat[i].pixel;
+	pScreenPriv->pXvVisual[i].format.surface =
+	    glitz_find_format (pScreenPriv->drawable,
+			       GLITZ_FORMAT_FOURCC_MASK,
+			       &templ, 0);
+    }
+
+    return TRUE;
+}
+
+#endif
diff-tree 051d68415635282a246ec7e5f5d6b0f9c4de71aa (from dd474d95d094ae4494708a87d968a933337241fa)
Author: José Fonseca <jfonseca at titan.(none)>
Date:   Wed Sep 26 14:18:06 2007 +0000

    Fix undeclared function call warnings.

diff --git a/glucose/glucose_context.c b/glucose/glucose_context.c
index 7e6c71b..1f6c452 100644
--- a/glucose/glucose_context.c
+++ b/glucose/glucose_context.c
@@ -33,6 +33,7 @@
 #endif
 
 #include "glxserver.h"
+#include "glxutil.h"
 #include "glcontextmodes.h"
 #include "glitz.h"
 #include "glitz_glucose.h"
diff --git a/glucose/glucose_drawable.c b/glucose/glucose_drawable.c
index c35dfa9..01194c4 100644
--- a/glucose/glucose_drawable.c
+++ b/glucose/glucose_drawable.c
@@ -33,6 +33,7 @@
 #endif
 
 #include "glxserver.h"
+#include "glxutil.h"
 #include "glitz_glucose.h"
 
 extern __GLXcontext *__glXLastContext;
diff-tree dd474d95d094ae4494708a87d968a933337241fa (from 25363e5b83ab8a63150a0b6ca5e98c9e36760beb)
Author: José Fonseca <jfonseca at titan.(none)>
Date:   Wed Sep 26 14:17:34 2007 +0000

    Point __pGlxClient to serverClient when creating/destroying the root drawable.

diff --git a/glucose/glucose.c b/glucose/glucose.c
index 076bb7e..e3fe990 100644
--- a/glucose/glucose.c
+++ b/glucose/glucose.c
@@ -122,6 +122,8 @@ glucoseCreateScreenResources(ScreenPtr p
     PixmapPtr pPixmap = pScreen->GetScreenPixmap(pScreen);
     xglScreenPtr xglScreenPriv = XGL_GET_SCREEN_PRIV (pScreen);
 
+    __pGlxClient = serverClient;
+    
     /* track root pixmap */
     if (pPixmap)
     {
@@ -750,6 +752,8 @@ glucoseCloseScreen (int	  index,
     {
     	GlucoseScreenPrivPtr pScreenPriv = GlucoseGetScreenPriv(pScreen);
 
+        __pGlxClient = serverClient;        
+
     	pScreenPriv->rootContext->destroy(pScreenPriv->rootContext);
     	pScreenPriv->rootDrawable->destroy(pScreenPriv->rootDrawable);
 
diff-tree 25363e5b83ab8a63150a0b6ca5e98c9e36760beb (from dd80dbf49724ac8b54cfbb663d0724af4e89e7e6)
Author: José Fonseca <jrfonseca at tungstengraphics.com>
Date:   Fri Sep 21 12:48:57 2007 +0100

    Don't include compint.h when COMPOSITE is not defined.

diff --git a/hw/xgl/glxext/xglglxext.c b/hw/xgl/glxext/xglglxext.c
index f96c069..e997bb1 100644
--- a/hw/xgl/glxext/xglglxext.c
+++ b/hw/xgl/glxext/xglglxext.c
@@ -41,7 +41,9 @@
 #include "glapitable.h"
 #include "glxext.h"
 #include "micmap.h"
+#ifdef COMPOSITE
 #include "compint.h"
+#endif
 
 #define XGL_MAX_TEXTURE_UNITS      8
 #define XGL_MAX_ATTRIB_STACK_DEPTH 16
diff-tree dd80dbf49724ac8b54cfbb663d0724af4e89e7e6 (from e72b8dd7c0fad14414ca76931c3f7f9aee3e027d)
Author: José Fonseca <jrfonseca at tungstengraphics.com>
Date:   Fri Sep 21 12:48:21 2007 +0100

    Port last changes from master into glucose code.

diff --git a/glucose/glucose.c b/glucose/glucose.c
index b75a1d3..076bb7e 100644
--- a/glucose/glucose.c
+++ b/glucose/glucose.c
@@ -423,8 +423,6 @@ glucoseScreenInit (ScreenPtr pScreen, in
     XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
     XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
     XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
-    XGL_SCREEN_WRAP (PaintWindowBackground, xglPaintWindowBackground);
-    XGL_SCREEN_WRAP (PaintWindowBorder, xglPaintWindowBorder);
 
     XGL_SCREEN_WRAP (CreateGC, xglCreateGC);
 
diff-tree e72b8dd7c0fad14414ca76931c3f7f9aee3e027d (from parents)
Merge: a2cf3609094be42c9a576aebe147df2c5ecfb3a6 50fa8722d35c12e5f0322cebe25faf99c39d4f50
Author: José Fonseca <jrfonseca at tungstengraphics.com>
Date:   Thu Sep 20 23:38:28 2007 +0100

    Merge commit 'origin/master' into glucose-2

diff-tree 50fa8722d35c12e5f0322cebe25faf99c39d4f50 (from c140d20f4ade973496dcbbd06453402ef0c0e85c)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Thu Sep 20 14:00:33 2007 -0700

    Set noCompositeExtension to TRUE when failing to initialize the extension (e.g. when Xinerama is enabled).

diff --git a/composite/compext.c b/composite/compext.c
index 944f8d8..ece51d0 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -674,6 +674,9 @@ CompositeExtensionInit (void)
     ExtensionEntry  *extEntry;
     int		    s;
 
+    /* Assume initialization is going to fail */
+    noCompositeExtension = TRUE;
+
     for (s = 0; s < screenInfo.numScreens; s++) {
 	ScreenPtr pScreen = screenInfo.screens[s];
 	VisualPtr vis;
@@ -731,4 +734,7 @@ CompositeExtensionInit (void)
 	    return;
     miRegisterRedirectBorderClipProc (compSetRedirectBorderClip,
 				      compGetRedirectBorderClip);
+
+    /* Initialization succeeded */
+    noCompositeExtension = FALSE;
 }
diff-tree c140d20f4ade973496dcbbd06453402ef0c0e85c (from bcb5e3e6276ce9ae7a4dae7434cf2247764da078)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Sep 19 05:58:22 2007 -0700

    XDarwin:  mass change from using xorg-config.h to dix-config.h cuz we're not using the X.org ddx anymore

diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index 0b22141..1c18cd2 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -31,9 +31,7 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
 
 #include <X11/X.h>
 #include <X11/Xproto.h>
diff --git a/hw/darwin/iokit/xfIOKit.c b/hw/darwin/iokit/xfIOKit.c
index 9de33c0..0feb8cc 100644
--- a/hw/darwin/iokit/xfIOKit.c
+++ b/hw/darwin/iokit/xfIOKit.c
@@ -34,9 +34,7 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#if HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
 
 #include <X11/X.h>
 #include <X11/Xproto.h>
diff --git a/hw/darwin/iokit/xfIOKitCursor.c b/hw/darwin/iokit/xfIOKitCursor.c
index 8388513..e9c78c1 100644
--- a/hw/darwin/iokit/xfIOKitCursor.c
+++ b/hw/darwin/iokit/xfIOKitCursor.c
@@ -58,9 +58,8 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#if HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "scrnintstr.h"
 #include "cursorstr.h"
 #include "mipointrst.h"
diff --git a/hw/darwin/iokit/xfIOKitStartup.c b/hw/darwin/iokit/xfIOKitStartup.c
index 07e8c21..ad8e05b 100644
--- a/hw/darwin/iokit/xfIOKitStartup.c
+++ b/hw/darwin/iokit/xfIOKitStartup.c
@@ -29,10 +29,7 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-
-#if HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
 
 #include "darwin.h"
 #include "darwinKeyboard.h"
diff --git a/hw/darwin/quartz/Preferences.m b/hw/darwin/quartz/Preferences.m
index a79454b..6fca3b6 100644
--- a/hw/darwin/quartz/Preferences.m
+++ b/hw/darwin/quartz/Preferences.m
@@ -31,9 +31,9 @@
  * authorization.
  */
 /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #import "quartzCommon.h"
 
 #define BOOL xBOOL
diff --git a/hw/darwin/quartz/XServer.m b/hw/darwin/quartz/XServer.m
index 32bfbf5..14776f8 100644
--- a/hw/darwin/quartz/XServer.m
+++ b/hw/darwin/quartz/XServer.m
@@ -35,10 +35,8 @@
  * authorization.
  */
 /* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.3 2004/07/30 19:12:17 torrey Exp $ */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.19 2003/11/24 05:39:01 torrey Exp $ */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
 #include "quartzCommon.h"
 
 #define BOOL xBOOL
diff --git a/hw/darwin/quartz/applewm.c b/hw/darwin/quartz/applewm.c
index cc11cfa..d3c26ed 100644
--- a/hw/darwin/quartz/applewm.c
+++ b/hw/darwin/quartz/applewm.c
@@ -24,9 +24,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF 
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "quartzCommon.h"
 
 #define NEED_REPLIES
diff --git a/hw/darwin/quartz/cr/XView.m b/hw/darwin/quartz/cr/XView.m
index 8bcd1a7..0cea250 100644
--- a/hw/darwin/quartz/cr/XView.m
+++ b/hw/darwin/quartz/cr/XView.m
@@ -30,11 +30,10 @@
  * use or other dealings in this Software without prior written authorization.
  */
 /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/XView.m,v 1.1 2003/06/07 05:49:07 torrey Exp $ */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#import "XView.h"
 
+#include <dix-config.h>
+
+#import "XView.h"
 
 @implementation XView
 
diff --git a/hw/darwin/quartz/cr/crAppleWM.m b/hw/darwin/quartz/cr/crAppleWM.m
index 0741d4e..a583581 100644
--- a/hw/darwin/quartz/cr/crAppleWM.m
+++ b/hw/darwin/quartz/cr/crAppleWM.m
@@ -27,9 +27,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.2 2003/06/30 01:45:13 torrey Exp $ */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "quartz/quartzCommon.h"
 #include "quartz/cr/cr.h"
 
diff --git a/hw/darwin/quartz/cr/crFrame.m b/hw/darwin/quartz/cr/crFrame.m
index 2b8e57d..3c1f0bb 100644
--- a/hw/darwin/quartz/cr/crFrame.m
+++ b/hw/darwin/quartz/cr/crFrame.m
@@ -28,10 +28,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 /* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.2 2004/04/23 19:15:51 eich Exp $ */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.9 2004/03/19 02:05:29 torrey Exp $ */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "quartz/quartzCommon.h"
 #include "quartz/cr/cr.h"
 
diff --git a/hw/darwin/quartz/cr/crScreen.m b/hw/darwin/quartz/cr/crScreen.m
index 9dd130e..8c09665 100644
--- a/hw/darwin/quartz/cr/crScreen.m
+++ b/hw/darwin/quartz/cr/crScreen.m
@@ -29,9 +29,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/crScreen.m,v 1.5 2003/11/12 20:21:52 torrey Exp $ */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "quartz/quartzCommon.h"
 #include "quartz/cr/cr.h"
 
diff --git a/hw/darwin/quartz/fullscreen/fullscreen.c b/hw/darwin/quartz/fullscreen/fullscreen.c
index 02f6e89..2021ea2 100644
--- a/hw/darwin/quartz/fullscreen/fullscreen.c
+++ b/hw/darwin/quartz/fullscreen/fullscreen.c
@@ -25,9 +25,9 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "quartz/quartzCommon.h"
 #include "darwin.h"
 #include "quartz/quartz.h"
diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.c b/hw/darwin/quartz/fullscreen/quartzCursor.c
index 77fa008..a97a36d 100644
--- a/hw/darwin/quartz/fullscreen/quartzCursor.c
+++ b/hw/darwin/quartz/fullscreen/quartzCursor.c
@@ -29,9 +29,9 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "quartz/quartzCommon.h"
 #include "quartz/quartzCursor.h"
 #include "darwin.h"
diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c
index e65be69..787601b 100644
--- a/hw/darwin/quartz/pseudoramiX.c
+++ b/hw/darwin/quartz/pseudoramiX.c
@@ -34,9 +34,9 @@ Equipment Corporation.
 ******************************************************************/
 
 #include "pseudoramiX.h"
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "extnsionst.h"
 #include "dixstruct.h"
 #include "window.h"
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index b309b7b..374f365 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -29,9 +29,9 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "quartzCommon.h"
 #include "quartz.h"
 #include "darwin.h"
diff --git a/hw/darwin/quartz/quartzAudio.c b/hw/darwin/quartz/quartzAudio.c
index 16b9c2b..8a337da 100644
--- a/hw/darwin/quartz/quartzAudio.c
+++ b/hw/darwin/quartz/quartzAudio.c
@@ -35,9 +35,9 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "quartzCommon.h"
 #include "quartzAudio.h"
 
diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m
index 42eabcb..5bc1501 100644
--- a/hw/darwin/quartz/quartzCocoa.m
+++ b/hw/darwin/quartz/quartzCocoa.m
@@ -35,9 +35,7 @@
  * use or other dealings in this Software without prior written authorization.
  */
 /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
 
 #include "quartzCommon.h"
 
diff --git a/hw/darwin/quartz/quartzCursor.c b/hw/darwin/quartz/quartzCursor.c
index 6ed6a76..0fa04e6 100644
--- a/hw/darwin/quartz/quartzCursor.c
+++ b/hw/darwin/quartz/quartzCursor.c
@@ -30,9 +30,8 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "quartzCommon.h"
 #include "quartzCursor.h"
 #include "darwin.h"
diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index bdd5416..b498c77 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -32,11 +32,9 @@
    prior written authorization.
 */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#include "quartzCommon.h"
+#include <dix-config.h>
 
+#include "quartzCommon.h"
 #include <CoreServices/CoreServices.h>
 #include <Carbon/Carbon.h>
 
diff --git a/hw/darwin/quartz/quartzPasteboard.c b/hw/darwin/quartz/quartzPasteboard.c
index a3536fc..af25fc8 100644
--- a/hw/darwin/quartz/quartzPasteboard.c
+++ b/hw/darwin/quartz/quartzPasteboard.c
@@ -30,11 +30,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#include "quartzPasteboard.h"
+#include <dix-config.h>
 
+#include "quartzPasteboard.h"
 #include <X11/Xatom.h>
 #include "windowstr.h"
 #include "propertyst.h"
diff --git a/hw/darwin/quartz/xpr/appledri.c b/hw/darwin/quartz/xpr/appledri.c
index ef68c86..70b7400 100644
--- a/hw/darwin/quartz/xpr/appledri.c
+++ b/hw/darwin/quartz/xpr/appledri.c
@@ -35,9 +35,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
  *
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #define NEED_REPLIES
 #define NEED_EVENTS
 #include <X11/X.h>
diff --git a/hw/darwin/quartz/xpr/dri.c b/hw/darwin/quartz/xpr/dri.c
index 08ee382..acc1f45 100644
--- a/hw/darwin/quartz/xpr/dri.c
+++ b/hw/darwin/quartz/xpr/dri.c
@@ -33,9 +33,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
  *   Rickard E. (Rik) Faith <faith at valinux.com>
  *
  */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
 
 #include <sys/time.h>
 #include <unistd.h>
diff --git a/hw/darwin/quartz/xpr/x-hash.c b/hw/darwin/quartz/xpr/x-hash.c
index 6bbeacf..d24e05c 100644
--- a/hw/darwin/quartz/xpr/x-hash.c
+++ b/hw/darwin/quartz/xpr/x-hash.c
@@ -26,9 +26,9 @@
    copyright holders shall not be used in advertising or otherwise to
    promote the sale, use or other dealings in this Software without
    prior written authorization. */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "x-hash.h"
 #include "x-list.h"
 #include <stdlib.h>
diff --git a/hw/darwin/quartz/xpr/x-hook.c b/hw/darwin/quartz/xpr/x-hook.c
index 42915db..92c174e 100644
--- a/hw/darwin/quartz/xpr/x-hook.c
+++ b/hw/darwin/quartz/xpr/x-hook.c
@@ -26,9 +26,9 @@
    copyright holders shall not be used in advertising or otherwise to
    promote the sale, use or other dealings in this Software without
    prior written authorization. */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "x-hook.h"
 #include <stdlib.h>
 #include <assert.h>
diff --git a/hw/darwin/quartz/xpr/x-list.c b/hw/darwin/quartz/xpr/x-list.c
index a5f835d..356bb79 100644
--- a/hw/darwin/quartz/xpr/x-list.c
+++ b/hw/darwin/quartz/xpr/x-list.c
@@ -26,9 +26,9 @@
    copyright holders shall not be used in advertising or otherwise to
    promote the sale, use or other dealings in this Software without
    prior written authorization. */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "x-list.h"
 #include <stdlib.h>
 #include <assert.h>
diff --git a/hw/darwin/quartz/xpr/xprAppleWM.c b/hw/darwin/quartz/xpr/xprAppleWM.c
index fdf404c..1573d21 100644
--- a/hw/darwin/quartz/xpr/xprAppleWM.c
+++ b/hw/darwin/quartz/xpr/xprAppleWM.c
@@ -27,9 +27,9 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "xpr.h"
 #include "quartz/applewmExt.h"
 #include "rootless.h"
diff --git a/hw/darwin/quartz/xpr/xprCursor.c b/hw/darwin/quartz/xpr/xprCursor.c
index e7f23b7..d5a1180 100644
--- a/hw/darwin/quartz/xpr/xprCursor.c
+++ b/hw/darwin/quartz/xpr/xprCursor.c
@@ -30,9 +30,9 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "quartz/quartzCommon.h"
 #include "xpr.h"
 #include "darwin.h"
diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
index b71b2a6..76c719e 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -27,9 +27,9 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "xpr.h"
 #include "rootlessCommon.h"
 #include "Xplugin.h"
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index 034cbac..b0ddece 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -27,9 +27,9 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "quartz/quartzCommon.h"
 #include "quartz/quartz.h"
 #include "xpr.h"
diff-tree bcb5e3e6276ce9ae7a4dae7434cf2247764da078 (from 5e209b21f3d6b3268fa7dab1e8df892d8352cc08)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Sep 19 04:46:10 2007 -0700

    XDARWIN: More fixes to Makefile.am
    
    At least on my system (10.5 with the latest and greatest modules),
    Xquartz now builds out of the box.  It doesn't quite work yet, but
    hey -- you have to start somewhere. ;)

diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 1a2fa21..72bee4a 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -8,14 +8,20 @@ INCLUDES = @XORG_INCS@ -I../../miext/roo
 DEFS = @DEFS@ -DUSE_NEW_CLUT
 
 if XQUARTZ
-XQUARTZ_SUBDIRS = bundle quartz
+XQUARTZ_SUBDIRS = quartz
 XQUARTZ_PROGS = Xquartz
-HOOK_TARGETS = xquartz-install-hook
+XQUARTZ_HOOK = xquartz-install-hook
+endif
+
+if XDARWINAPP
+XDARWINAPP_SUBDIRS = bundle
+XDARWINAPP_HOOK = xdarwinapp-install-hook
 endif
 
 SUBDIRS = \
 	  iokit \
 	  $(XQUARTZ_SUBDIRS) \
+	  $(XDARWINAPP_SUBDIRS) \
 	  utils \
 	  .
 
@@ -260,17 +266,19 @@ glxAGL_la_DEPENDENCIES = XDarwinApp	
 endif
 endif
 
-man1_MANS = XDarwin.man
+#man1_MANS = XDarwin.man
 
-uninstall-hook:
-	rm -rf $(DESTDIR)$(macosdir)/XDarwin
+#uninstall-hook:
+#	rm -rf $(DESTDIR)$(macosdir)/XDarwin
 
-install-data-hook: $(HOOK_TARGETS)
+install-data-hook: $(XQUARTZ_HOOK) $(XDARWINAPP_HOOK)
 
-xquartz-install-hook:
-	mv $(DESTDIR)$(macosdir)/XDarwinApp $(DESTDIR)$(macosdir)/XDarwin
+xquartz-install-hook::
 	cd apple && xcodebuild install
 
+xdarwinapp-install hook:
+	mv $(DESTDIR)$(macosdir)/XDarwinApp $(DESTDIR)$(macosdir)/XDarwin
+
 EXTRA_DIST = \
 	darwin.c \
 	darwinClut8.h \
diff-tree 5e209b21f3d6b3268fa7dab1e8df892d8352cc08 (from 378c7ebef444cdc9ae62ebf05c7111088a0c4bc1)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Sep 19 03:44:46 2007 -0700

    XNEST: removed obsolete hack to build under Darwin

diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c
index 5bf0300..4699111 100644
--- a/hw/xnest/Init.c
+++ b/hw/xnest/Init.c
@@ -129,22 +129,6 @@ void
 DarwinHandleGUI(int argc, char *argv[])
 {
 }
-
-void GlxExtensionInit();
-void GlxWrapInitVisuals(void *procPtr);
-
-void
-DarwinGlxExtensionInit()
-{
-    GlxExtensionInit();
-}
-
-void
-DarwinGlxWrapInitVisuals(
-    void *procPtr)
-{
-    GlxWrapInitVisuals(procPtr);
-}
 #endif
 
 void OsVendorInit()
diff-tree 378c7ebef444cdc9ae62ebf05c7111088a0c4bc1 (from 7813392d1c9a38d01cfff17732278bb7798eee5d)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Sep 19 03:43:40 2007 -0700

    XVFB: Removed obsolete hack to build on Darwin

diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index a2d8661..812326a 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -225,22 +225,6 @@ void
 DarwinHandleGUI(int argc, char *argv[])
 {
 }
-
-void GlxExtensionInit();
-void GlxWrapInitVisuals(void *procPtr);
-
-void
-DarwinGlxExtensionInit()
-{
-    GlxExtensionInit();
-}
-
-void
-DarwinGlxWrapInitVisuals(
-    void *procPtr)
-{
-    GlxWrapInitVisuals(procPtr);
-}
 #endif
 
 void
diff-tree 7813392d1c9a38d01cfff17732278bb7798eee5d (from 170fc77d9e73151f5c1c1f0f04598b3497db4284)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Sep 19 01:52:58 2007 -0700

    XDarwin: changes to Makefile.am to use new conditionals

diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index a6f84ee..1a2fa21 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -9,6 +9,8 @@ DEFS = @DEFS@ -DUSE_NEW_CLUT
 
 if XQUARTZ
 XQUARTZ_SUBDIRS = bundle quartz
+XQUARTZ_PROGS = Xquartz
+HOOK_TARGETS = xquartz-install-hook
 endif
 
 SUBDIRS = \
@@ -17,18 +19,18 @@ SUBDIRS = \
 	  utils \
 	  .
 
-darwinappdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app
-
 libdarwinShared_a_SOURCES = darwin.c \
 			  darwinEvents.c \
 			  darwinKeyboard.c \
 			  $(darwin_XINPUT_SRCS) 
 
-bin_PROGRAMS = XDarwin Xquartz
-XDarwin_SOURCES = \
-                  $(top_srcdir)/fb/fbcmap_mi.c \
-                  $(top_srcdir)/mi/miinitext.c \
-                  $(top_srcdir)/Xi/stubs.c
+# bin_PROGRAMS = XDarwin Xquartz
+bin_PROGRAMS = $(XQUARTZ_PROGS)
+
+#XDarwin_SOURCES = \
+#                  $(top_srcdir)/fb/fbcmap_mi.c \
+#                  $(top_srcdir)/mi/miinitext.c \
+#                  $(top_srcdir)/Xi/stubs.c
 
 Xquartz_SOURCES = \
                   $(top_srcdir)/fb/fbcmap_mi.c \
@@ -68,22 +70,22 @@ DARWIN_LIBS = \
 	./libdarwinShared.a \
 	$(XSERVER_LIBS)
 
-XDARWIN_LIBS = \
-	$(DARWIN_LIBS) \
-	./iokit/libiokit.a
+#XDARWIN_LIBS = \
+#	$(DARWIN_LIBS) \
+#	./iokit/libiokit.a
 XQUARTZ_LIBS = \
 	$(DARWIN_LIBS)
 
-XDarwin_DEPENDENCIES = $(XDARWIN_LIBS)
-XDarwin_LDADD = $(XDARWIN_LIBS) $(XSERVER_SYS_LIBS)
+#XDarwin_DEPENDENCIES = $(XDARWIN_LIBS)
+#XDarwin_LDADD = $(XDARWIN_LIBS) $(XSERVER_SYS_LIBS)
 
 Xquartz_DEPENDENCIES = $(XQUARTZ_LIBS)
 Xquartz_LDADD = $(XQUARTZ_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
 
-XDarwin_LDFLAGS =  \
-                 -XCClinker -Objc \
-                 -Wl,-u,_miDCInitialize \
-                 -Wl,-framework,IOKit
+#XDarwin_LDFLAGS =  \
+#                 -XCClinker -Objc \
+#                 -Wl,-u,_miDCInitialize \
+#                 -Wl,-framework,IOKit
 
 Xquartz_LDFLAGS =  \
                  -XCClinker -Objc \
@@ -95,19 +97,23 @@ Xquartz_LDFLAGS =  \
                  -Wl,-framework,CoreAudio \
                  -Wl,-framework,IOKit
 
-XDarwin_CFLAGS = -DINXDARWIN
+#XDarwin_CFLAGS = -DINXDARWIN
 Xquartz_CFLAGS = -DINXQUARTZ -DHAS_CG_MACH_PORT -DHAS_KL_API  -DHAVE_XORG_CONFIG_H
 
 if XQUARTZ
-macosdir = $(darwinappdir)/Contents/MacOS
-
 DEFS += -DDARWIN_WITH_QUARTZ -DXFree86Server
 
-macos_PROGRAMS = XDarwinApp
-macos_SCRIPTS = x11app
+bin_SCRIPTS = x11app
 
 x11app:
 	cd apple && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)"
+endif
+
+if XDARWINAPP
+macosdir = $(darwinappdir)/Contents/MacOS
+
+macos_PROGRAMS = XDarwinApp
+darwinappdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app
 
 XDarwinApp_SOURCES = \
                 $(top_srcdir)/fb/fbcmap_mi.c \
@@ -134,8 +140,6 @@ XDarwinApp_LDFLAGS =  \
 		 -Wl,-framework,IOKit
 
 XDarwinApp_CFLAGS = -DINXDARWINAPP
-HOOK_TARGETS = xquartz-install-hook
-
 
 crplugindir = $(darwinappdir)/Contents/Resources/cr.bundle/Contents/MacOS
 crplugin_LTLIBRARIES = cr.la
@@ -190,7 +194,6 @@ glxMesa_la_LDFLAGS = -shrext '' \
 glxMesa_la_DEPENDENCIES = XDarwinApp	
 endif
 
-endif
 if HAVE_XPLUGIN
 
 xprplugindir = $(darwinappdir)/Contents/Resources/xpr.bundle/Contents/MacOS
@@ -255,6 +258,7 @@ glxAGL_la_DEPENDENCIES = XDarwinApp	
 
 
 endif
+endif
 
 man1_MANS = XDarwin.man
 
diff-tree 170fc77d9e73151f5c1c1f0f04598b3497db4284 (from 9b4f5157179a0d20756c16ea1f5130b171f72bb1)
Author: Dodji Seketeli <dodji at openedhand.com>
Date:   Wed Sep 19 09:54:09 2007 +0200

    xserver: don't force DTRACE detection by default
    
            this fixes a breakage caused by 7a4ec34e256bf36b041c011a083916ad75a1d8bc.
            When running a non DTRACE aware system that is not darwin*, DTRACE was getting
            required. Now it is not anymore.

diff --git a/configure.ac b/configure.ac
index 4f08d71..de30430 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,7 +73,6 @@ dnl Darwin 9 has dtrace, but it doesn't 
 if test "x$WDTRACE" = xauto; then
 	case $host_os in
 		darwin*) WDTRACE="no" ;;
-		*) WDTRACE="yes" ;;
 	esac
 fi
 if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then
diff-tree 9b4f5157179a0d20756c16ea1f5130b171f72bb1 (from 7a4ec34e256bf36b041c011a083916ad75a1d8bc)
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Tue Sep 18 21:40:32 2007 -0700

    XDarwin:  We build many many different targets, let's break them out into autoconf conditionals

diff --git a/configure.ac b/configure.ac
index 6e7ed05..4f08d71 100644
--- a/configure.ac
+++ b/configure.ac
@@ -500,7 +500,6 @@ AC_ARG_ENABLE(xres,           AS_HELP_ST
 AC_ARG_ENABLE(xtrap,          AS_HELP_STRING([--disable-xtrap], [Build XTrap extension (default: enabled)]), [XTRAP=$enableval], [XTRAP=yes])
 AC_ARG_ENABLE(record,         AS_HELP_STRING([--disable-record], [Build Record extension (default: enabled)]), [RECORD=$enableval], [RECORD=yes])
 AC_ARG_ENABLE(xv,             AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
-AC_ARG_ENABLE(quartz,         AS_HELP_STRING([--enable-quartz], [Build with darwin quartz support (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
 AC_ARG_ENABLE(xvmc,           AS_HELP_STRING([--disable-xvmc], [Build XvMC extension (default: enabled)]), [XVMC=$enableval], [XVMC=yes])
 AC_ARG_ENABLE(dga,            AS_HELP_STRING([--disable-dga], [Build DGA extension (default: auto)]), [DGA=$enableval], [DGA=auto])
 AC_ARG_ENABLE(screensaver,    AS_HELP_STRING([--disable-screensaver], [Build ScreenSaver extension (default: enabled)]), [SCREENSAVER=$enableval], [SCREENSAVER=yes])
@@ -534,6 +533,9 @@ AC_ARG_ENABLE(dmx,    	      AS_HELP_STR
 AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
 AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
 AC_ARG_ENABLE(xdarwin, 	      AS_HELP_STRING([--enable-xdarwin], [Build XDarwin server (default: auto)]), [XDARWIN=$enableval], [XDARWIN=auto])
+AC_ARG_ENABLE(xdarwinapp,     AS_HELP_STRING([--enable-xdarwinapp], [Build XDarwin.app server (default: no)]), [XDARWINAPP=$enableval], [XDARWINAPP=no])
+AC_ARG_ENABLE(xquartz,        AS_HELP_STRING([--disable-xquartz], [Build Xquartz server on Darwin (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
+AC_ARG_ENABLE(x11app,         AS_HELP_STRING([--enable-x11app], [Build Apple's X11.app wrapper for Xquartz (default: no)]), [X11APP=$enableval], [X11APP=no])
 AC_ARG_ENABLE(xwin,    	      AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
 AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: no)]), [XPRINT=$enableval], [XPRINT=no])
 AC_ARG_ENABLE(xgl,            AS_HELP_STRING([--enable-xgl], [Build Xgl server (default: no)]), [XGL=$enableval], [XGL=no])
@@ -1774,7 +1776,9 @@ _AM_DEPENDENCIES([OBJC])
 AM_CONDITIONAL(HAVE_XPLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
 AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
 AM_CONDITIONAL(XDARWIN, [test "x$XDARWIN" = xyes])
+AM_CONDITIONAL(XDARWINAPP, [test "x$XDARWINAPP" = xyes])
 AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
+
 dnl kdrive DDX
 
 XEPHYR_LIBS=
diff-tree 7a4ec34e256bf36b041c011a083916ad75a1d8bc (from 3c19ec47b434d4ca84db58363cc053cc0b6aa413)
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Tue Sep 18 20:37:09 2007 -0700

    XDarwin:  Disable dtrace support on Darwin 9 (since it doesn't work ... yet ...)

diff --git a/configure.ac b/configure.ac
index fc6dd58..6e7ed05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,13 @@ dnl Check for dtrace program (needed to 
 AC_ARG_WITH(dtrace, AS_HELP_STRING([--with-dtrace=PATH],
 	     [Enable dtrace probes (default: enabled if dtrace found)]),
 	     [WDTRACE=$withval], [WDTRACE=auto])
+dnl Darwin 9 has dtrace, but it doesn't support compilation into ELF...
+if test "x$WDTRACE" = xauto; then
+	case $host_os in
+		darwin*) WDTRACE="no" ;;
+		*) WDTRACE="yes" ;;
+	esac
+fi
 if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then
 	AC_PATH_PROG(DTRACE, [dtrace], [not_found], [$PATH:/usr/sbin])
 	if test "x$DTRACE" = "xnot_found" ; then
diff-tree 3c19ec47b434d4ca84db58363cc053cc0b6aa413 (from 547ad2125ece93bbe01f6d09a3baf176ebd16bb3)
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Tue Sep 18 20:15:44 2007 -0700

    XDarwin: changed XF86BigFont support default from yes to auto so XDarwin can disable it

diff --git a/configure.ac b/configure.ac
index 24b12df..fc6dd58 100644
--- a/configure.ac
+++ b/configure.ac
@@ -515,7 +515,7 @@ AC_ARG_ENABLE(evi,            AS_HELP_ST
 AC_ARG_ENABLE(multibuffer,    AS_HELP_STRING([--enable-multibuffer], [Build Multibuffer extension (default: disabled)]), [MULTIBUFFER=$enableval], [MULTIBUFFER=no])
 AC_ARG_ENABLE(fontcache,      AS_HELP_STRING([--enable-fontcache], [Build FontCache extension (default: disabled)]), [FONTCACHE=$enableval], [FONTCACHE=no])
 AC_ARG_ENABLE(dbe,            AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes])
-AC_ARG_ENABLE(xf86bigfont,    AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big Font extension (default: enabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=yes])
+AC_ARG_ENABLE(xf86bigfont,    AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big Font extension (default: enabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=auto])
 AC_ARG_ENABLE(dpms,           AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes])
 AC_ARG_ENABLE(config-dbus,    AS_HELP_STRING([--enable-config-dbus], [Build D-BUS API support (default: no)]), [CONFIG_DBUS_API=$enableval], [CONFIG_DBUS_API=no])
 AC_ARG_ENABLE(config-hal,     AS_HELP_STRING([--disable-config-hal], [Build HAL support (default: auto)]), [CONFIG_HAL=$enableval], [CONFIG_HAL=auto])
@@ -1744,6 +1744,10 @@ return 0;}
                        AC_MSG_NOTICE([Disabling XF86VidMode extension])
                        XF86VIDMODE=no
                fi
+               if test "x$XF86BIGFONT" = xyes || test "x$XF86BIGFONT" = xauto; then
+                       AC_MSG_NOTICE([Disabling XF86BigFont extension])
+                       XF86BIGFONT=no
+               fi
                if test "x$DGA" = xyes || test "x$DGA" = xauto; then
                        AC_MSG_NOTICE([Disabling DGA extension])
                        DGA=no
diff-tree 547ad2125ece93bbe01f6d09a3baf176ebd16bb3 (from 56cc24ffb21f7fd41f9ea9e8f969aa85021b9f53)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Sep 17 20:33:56 2007 +0200

    EXA: Make sure driver hooks get correct offscreen offsets from exaCopyDirty.
    
    This should ensure the driver UploadTo/DownloadFromScreen hooks can always
    work as intended.

diff --git a/exa/exa_migration.c b/exa/exa_migration.c
index ace9076..c0e022c 100644
--- a/exa/exa_migration.c
+++ b/exa/exa_migration.c
@@ -127,7 +127,7 @@ exaCopyDirty(ExaMigrationPtr migrate, Re
     ExaPixmapPriv (pPixmap);
     RegionPtr damage = DamageRegion (pExaPixmap->pDamage);
     RegionRec CopyReg;
-    CARD8 *save_ptr;
+    Bool save_offscreen;
     int save_pitch;
     BoxPtr pBox;
     int nbox;
@@ -176,9 +176,9 @@ exaCopyDirty(ExaMigrationPtr migrate, Re
     pBox = REGION_RECTS(&CopyReg);
     nbox = REGION_NUM_RECTS(&CopyReg);
 
-    save_ptr = pPixmap->devPrivate.ptr;
+    save_offscreen = pExaPixmap->offscreen;
     save_pitch = pPixmap->devKind;
-    pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr;
+    pExaPixmap->offscreen = TRUE;
     pPixmap->devKind = pExaPixmap->fb_pitch;
 
     while (nbox--) {
@@ -216,7 +216,7 @@ exaCopyDirty(ExaMigrationPtr migrate, Re
     else
 	sync (pPixmap->drawable.pScreen);
 
-    pPixmap->devPrivate.ptr = save_ptr;
+    pExaPixmap->offscreen = save_offscreen;
     pPixmap->devKind = save_pitch;
 
     /* The copied bits are now valid in destination */
diff-tree 56cc24ffb21f7fd41f9ea9e8f969aa85021b9f53 (from 7ac89060e02c7a803018afd580720f8326561fd8)
Author: Alan Hourihane <alanh at tungstengraphics.com>
Date:   Mon Sep 17 20:33:56 2007 +0200

    EXA: Don't crash in ExaCheckPolyArc.
    
    See https://bugs.freedesktop.org/show_bug.cgi?id=12286 .

diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index fcd4af9..c55ef03 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -196,6 +196,12 @@ ExaCheckPolyArc (DrawablePtr pDrawable, 
 		int narcs, xArc *pArcs)
 {
     EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
+
+    /* Disable this as fbPolyArc can call miZeroPolyArc which in turn
+     * can call accelerated functions, that as yet, haven't been notified
+     * with exaFinishAccess().
+     */
+#if 0
     if (pGC->lineWidth == 0)
     {
 	exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
@@ -205,6 +211,7 @@ ExaCheckPolyArc (DrawablePtr pDrawable, 
 	exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 	return;
     }
+#endif
     miPolyArc (pDrawable, pGC, narcs, pArcs);
 }
 
diff-tree 7ac89060e02c7a803018afd580720f8326561fd8 (from 3876c6c80534a6f7412ec806a2ba9ada22c5e505)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Sep 17 20:33:55 2007 +0200

    EXA: Don't crash in exaGetImage when swapped out.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 8500c5b..2acade2 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1324,9 +1324,6 @@ exaGetImage (DrawablePtr pDrawable, int 
     int xoff, yoff;
     Bool ok;
 
-    if (pExaScr->swappedOut)
-	goto fallback;
-
     pixmaps[0].as_dst = FALSE;
     pixmaps[0].as_src = TRUE;
     pixmaps[0].pPix = pPix = exaGetDrawablePixmap (pDrawable);
@@ -1341,6 +1338,9 @@ exaGetImage (DrawablePtr pDrawable, int 
 
     REGION_INIT(pScreen, &Reg, &Box, 1);
 
+    if (pExaScr->swappedOut)
+	goto fallback;
+
     exaDoMigration(pixmaps, 1, FALSE);
 
     pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
diff-tree 3876c6c80534a6f7412ec806a2ba9ada22c5e505 (from d5738ff2e0f93df4729c075ce31a1041d580e50e)
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date:   Mon Sep 17 18:47:45 2007 +0200

    EXA: Fixed compiler warnings.

diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index aecbfeb..fcd4af9 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -258,11 +258,11 @@ ExaCheckPushPixels (GCPtr pGC, PixmapPtr
 		  exaDrawableLocation(&pBitmap->drawable),
 		  exaDrawableLocation(pDrawable)));
     exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
-    exaPrepareAccess (pBitmap, EXA_PREPARE_SRC);
+    exaPrepareAccess (&pBitmap->drawable, EXA_PREPARE_SRC);
     exaPrepareAccessGC (pGC);
     fbPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
     exaFinishAccessGC (pGC);
-    exaFinishAccess (pBitmap, EXA_PREPARE_SRC);
+    exaFinishAccess (&pBitmap->drawable, EXA_PREPARE_SRC);
     exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 }
 
diff-tree d5738ff2e0f93df4729c075ce31a1041d580e50e (from a0dafd95e1e13a2f1b77ab9f82fd365a7be19de5)
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date:   Mon Sep 17 16:59:03 2007 +0200

    EXA: Added missing exaPrepare/FinishAccess calls in ExaCheckPushPixels.

diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index d487dc5..aecbfeb 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -258,9 +258,11 @@ ExaCheckPushPixels (GCPtr pGC, PixmapPtr
 		  exaDrawableLocation(&pBitmap->drawable),
 		  exaDrawableLocation(pDrawable)));
     exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+    exaPrepareAccess (pBitmap, EXA_PREPARE_SRC);
     exaPrepareAccessGC (pGC);
     fbPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
     exaFinishAccessGC (pGC);
+    exaFinishAccess (pBitmap, EXA_PREPARE_SRC);
     exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 }
 
diff-tree a0dafd95e1e13a2f1b77ab9f82fd365a7be19de5 (from 7bd65577018a574970b767b67967b65fcd5c2bf0)
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date:   Mon Sep 17 16:45:20 2007 +0200

    Removed hw/xwin/winpntwin.c from Makefile.am.
    
    winpntwin.c was removed in e4d11e58ce349dfe6af2f73ff341317f9b39684c.

diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 8aaed8c..5ffba12 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -45,7 +45,6 @@ SRCS_NATIVEGDI = \
 	wingetsp.c \
 	winnativegdi.c \
 	winpixmap.c \
-	winpntwin.c \
 	winpolyline.c \
 	winpushpxl.c \
 	winrop.c \
diff-tree 7bd65577018a574970b767b67967b65fcd5c2bf0 (from b9f7aeb20015290a8acf938a11bf9272bf3527cf)
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date:   Sat Sep 15 14:01:57 2007 +0200

    Initialize output->pendingProperties.

diff --git a/randr/rroutput.c b/randr/rroutput.c
index a67e493..c1e971d 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -95,6 +95,7 @@ RROutputCreate (ScreenPtr   pScreen,
     output->numUserModes = 0;
     output->userModes = NULL;
     output->properties = NULL;
+    output->pendingProperties = FALSE;
     output->changed = FALSE;
     output->devPrivate = devPrivate;
     
diff-tree b9f7aeb20015290a8acf938a11bf9272bf3527cf (from parents)
Merge: e4d11e58ce349dfe6af2f73ff341317f9b39684c 06d27f8045966c1fb154eafaff308a01b93f265b
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Sep 13 00:15:45 2007 +0000

    Merge remote branch 'origin/master' into paint-window
    
    Conflicts:
    
    	mi/miexpose.c

diff --cc mi/miexpose.c
index 03d4c27,2dc8f15..6ace9f5
@@@ -545,25 -592,31 +544,31 @@@
      BoxPtr	pbox;
      xRectangle	*prect;
      int		numRects;
-     int		xoff, yoff;
- 
-     pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- 
- #ifdef COMPOSITE
-     xoff = -pPixmap->screen_x;
-     yoff = -pPixmap->screen_y;
- #else
-     xoff = 0;
-     yoff = 0;
- #endif
-     gcval[0].val = GXcopy;
-     gcmask = GCFunction;
+     /*
+      * Distance from screen to destination drawable, use this
+      * to adjust rendering coordinates which come in in screen space
+      */
+     int		draw_x_off, draw_y_off;
+     /*
+      * Tile offset for drawing; these need to align the tile
+      * to the appropriate window origin
+      */
+     int		tile_x_off, tile_y_off;
+     PixUnion	fill;
+     Bool	solid = TRUE;
+     DrawablePtr	drawable = &pWin->drawable;
  
 -    while (pWin->backgroundState == ParentRelative)
 -        pWin = pWin->parent;
 -
      if (what == PW_BACKGROUND)
      {
 +	while (pWin->backgroundState == ParentRelative)
 +	    pWin = pWin->parent;
 +
+ 	draw_x_off = drawable->x;
+ 	draw_y_off = drawable->y;
+ 
+ 	tile_x_off = 0;
+ 	tile_y_off = 0;
+ 	fill = pWin->background;
  	switch (pWin->backgroundState) {
  	case None:
  	    return;
diff-tree e4d11e58ce349dfe6af2f73ff341317f9b39684c (from 6da39c67905500ab2db00a45cda4a9f756cdde96)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep 12 13:58:46 2007 +0000

    Remove the PaintWindow optimization.
    
    This was an attempt to avoid scratch gc creation and validation for paintwin
    because that was expensive.  This is not the case in current servers, and the
    danger of failure to implement it correctly (as seen in all previous
    implementations) is high enough to justify removing it.  No performance
    difference detected with x11perf -create -move -resize -circulate on Xvfb.
    Leave the screen hooks for PaintWindow* in for now to avoid ABI change.

diff --git a/Xext/mbufbf.c b/Xext/mbufbf.c
index e29c974..b879abc 100644
--- a/Xext/mbufbf.c
+++ b/Xext/mbufbf.c
@@ -504,7 +504,7 @@ bufClearImageBufferArea(pMBBuffer, x,y, 
 
     REGION_INTERSECT(pScreen, &reg, &reg, &pBuffer->clipList);
     if (pBuffer->backgroundState != None)
-	(*pScreen->PaintWindowBackground)(pBuffer, &reg, PW_BACKGROUND);
+	miPaintWindow(pBuffer, &reg, PW_BACKGROUND);
     if (generateExposures)
 	MultibufferExpose(pMBBuffer, &reg);
 #ifdef _notdef
@@ -517,7 +517,7 @@ bufClearImageBufferArea(pMBBuffer, x,y, 
     if (generateExposures)
 	(*pScreen->WindowExposures)(pBuffer, &reg, pBSReg);
     else if (pBuffer->backgroundState != None)
-        (*pScreen->PaintWindowBackground)(pBuffer, &reg, PW_BACKGROUND);
+        miPaintWindow(pBuffer, &reg, PW_BACKGROUND);
 #endif
     REGION_UNINIT(pScreen, &reg);
     if (pBSReg)
@@ -836,8 +836,7 @@ bufClipNotify(pWin, dx,dy)
 
 /*
  * Updates buffer's background fields when the window's changes.
- * This is necessary because pScreen->PaintWindowBackground
- * is used to paint the buffer.
+ * This is necessary because miPaintWindow is used to paint the buffer.
  *
  * XXBS - Backingstore state will have be tracked too if it is supported.
  */
@@ -927,7 +926,7 @@ bufWindowExposures(pWin, prgn, other_exp
 	pBuffer = (BufferPtr) pMBBuffer->pDrawable;
 
 	if (i != pMBWindow->displayedMultibuffer)
-	    (* pScreen->PaintWindowBackground)(pBuffer,&tmp_rgn,PW_BACKGROUND);
+	    miPaintWindow(pBuffer, &tmp_rgn, PW_BACKGROUND);
 	if ((pMBBuffer->otherEventMask | pMBBuffer->eventMask) & ExposureMask)
 	    MultibufferExpose(pMBBuffer, &tmp_rgn);
     }
diff --git a/afb/Makefile.am b/afb/Makefile.am
index d6b8901..9fc22ca 100644
--- a/afb/Makefile.am
+++ b/afb/Makefile.am
@@ -6,7 +6,7 @@ libafb_gen_sources = afbbltC.c afbbltX.c
 
 DISTCLEANFILES = $(libafb_gen_sources)
 
-libafb_la_SOURCES = afbgc.c afbwindow.c afbfont.c afbfillrct.c afbpntwin.c afbpixmap.c \
+libafb_la_SOURCES = afbgc.c afbwindow.c afbfont.c afbfillrct.c afbpixmap.c \
 	 afbimage.c afbline.c afbbres.c afbhrzvert.c afbbresd.c afbpushpxl.c afbply1rct.c \
 	 afbzerarc.c afbfillarc.c afbfillsp.c afbsetsp.c afbscrinit.c afbplygblt.c \
 	 afbclip.c afbgetsp.c afbpolypnt.c afbbitblt.c afbcmap.c afbimggblt.c afbpntarea.c \
diff --git a/afb/afb.h b/afb/afb.h
index 9125951..943c2c6 100644
--- a/afb/afb.h
+++ b/afb/afb.h
@@ -506,11 +506,6 @@ extern void afbCopyRotatePixmap(
 	int /*xrot*/,
 	int /*yrot*/
 );
-extern void afbPaintWindow(
-	WindowPtr /*pWin*/,
-	RegionPtr /*pRegion*/,
-	int /*what*/
-);
 /* afbpolypnt.c */
 
 extern void afbPolyPoint(
@@ -744,16 +739,6 @@ extern int frameWindowPrivateIndex;		/* 
 #define afbGetGCPrivate(pGC) \
 	((afbPrivGC *)((pGC)->devPrivates[afbGCPrivateIndex].ptr))
 
-/* private field of window */
-typedef struct {
-	unsigned char fastBorder;	/* non-zero if border tile is 32 bits wide */
-	unsigned char fastBackground;
-	unsigned short unused; /* pad for alignment with Sun compiler */
-	DDXPointRec oldRotate;
-	PixmapPtr pRotatedBackground;
-	PixmapPtr pRotatedBorder;
-} afbPrivWin;
-
 /* Common macros for extracting drawing information */
 
 #define afbGetTypedWidth(pDrawable,wtype)( \
diff --git a/afb/afbpntwin.c b/afb/afbpntwin.c
deleted file mode 100644
index 6082f7c..0000000
--- a/afb/afbpntwin.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
-/***********************************************************
-
-Copyright (c) 1987  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 without limitation the rights
-to use, copy, modify, merge, publish, 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.  IN NO EVENT SHALL THE
-X CONSORTIUM 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 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 from the X Consortium.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        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 notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL 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 <X11/X.h>
-
-#include "windowstr.h"
-#include "regionstr.h"
-#include "pixmapstr.h"
-#include "scrnintstr.h"
-
-#include "afb.h"
-#include "maskbits.h"
-#include "mi.h"
-
-void
-afbPaintWindow(pWin, pRegion, what)
-	WindowPtr		pWin;
-	RegionPtr		pRegion;
-	int				what;
-{
-	register afbPrivWin		*pPrivWin;
-	unsigned char rrops[AFB_MAX_DEPTH];
-
-	pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
-
-	switch (what) {
-		case PW_BACKGROUND:
-			switch (pWin->backgroundState) {
-				case None:
-					return;
-				case ParentRelative:
-					do {
-						pWin = pWin->parent;
-					} while (pWin->backgroundState == ParentRelative);
-					(*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-																					 what);
-					return;
-				case BackgroundPixmap:
-					if (pPrivWin->fastBackground) {
-						afbTileAreaPPWCopy((DrawablePtr)pWin,
-												  REGION_NUM_RECTS(pRegion),
-												  REGION_RECTS(pRegion), GXcopy,
-												  pPrivWin->pRotatedBackground, ~0);
-						return;
-					} else {
-						afbTileAreaCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-											  REGION_RECTS(pRegion), GXcopy,
-											  pWin->background.pixmap, 0, 0, ~0);
-						return;
-					}
-					break;
-				case BackgroundPixel:
-					afbReduceRop(GXcopy, pWin->background.pixel, ~0,
-									  pWin->drawable.depth, rrops);
-					afbSolidFillArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-											REGION_RECTS(pRegion), rrops);
-					return;
-			}
-			break;
-		case PW_BORDER:
-			if (pWin->borderIsPixel) {
-				afbReduceRop(GXcopy, pWin->border.pixel, ~0, pWin->drawable.depth,
-								  rrops);
-				afbSolidFillArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-										REGION_RECTS(pRegion), rrops);
-				return;
-			} else if (pPrivWin->fastBorder) {
-				afbTileAreaPPWCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-										  REGION_RECTS(pRegion), GXcopy,
-										  pPrivWin->pRotatedBorder, ~0);
-				return;
-			}
-			break;
-	}
-	miPaintWindow(pWin, pRegion, what);
-}
diff --git a/afb/afbscrinit.c b/afb/afbscrinit.c
index 71e8d4c..f3a0542 100644
--- a/afb/afbscrinit.c
+++ b/afb/afbscrinit.c
@@ -71,7 +71,6 @@ SOFTWARE.
 #ifdef PIXMAP_PER_WINDOW
 int frameWindowPrivateIndex;
 #endif
-int afbWindowPrivateIndex;
 int afbGCPrivateIndex;
 int afbScreenPrivateIndex;
 
@@ -140,20 +139,16 @@ afbAllocatePrivates(ScreenPtr pScreen, i
 #ifdef PIXMAP_PER_WINDOW
 		frameWindowPrivateIndex = AllocateWindowPrivateIndex();
 #endif
-		afbWindowPrivateIndex = AllocateWindowPrivateIndex();
 		afbGCPrivateIndex = AllocateGCPrivateIndex();
 		afbGeneration = serverGeneration;
 	}
-	if (pWinIndex)
-		*pWinIndex = afbWindowPrivateIndex;
 	if (pGCIndex)
 		*pGCIndex = afbGCPrivateIndex;
 
 	afbScreenPrivateIndex = AllocateScreenPrivateIndex();
 	pScreen->GetWindowPixmap = afbGetWindowPixmap;
 	pScreen->SetWindowPixmap = afbSetWindowPixmap;
-	return(AllocateWindowPrivate(pScreen, afbWindowPrivateIndex, sizeof(afbPrivWin)) &&
-	       AllocateGCPrivate(pScreen, afbGCPrivateIndex, sizeof(afbPrivGC)));
+	return(AllocateGCPrivate(pScreen, afbGCPrivateIndex, sizeof(afbPrivGC)));
 }
 
 /* dts * (inch/dot) * (25.4 mm / inch) = mm */
@@ -198,8 +193,6 @@ afbScreenInit(register ScreenPtr pScreen
 	pScreen->ChangeWindowAttributes = afbChangeWindowAttributes;
 	pScreen->RealizeWindow = afbMapWindow;
 	pScreen->UnrealizeWindow = afbUnmapWindow;
-	pScreen->PaintWindowBackground = afbPaintWindow;
-	pScreen->PaintWindowBorder = afbPaintWindow;
 	pScreen->CopyWindow = afbCopyWindow;
 	pScreen->CreatePixmap = afbCreatePixmap;
 	pScreen->DestroyPixmap = afbDestroyPixmap;
diff --git a/afb/afbwindow.c b/afb/afbwindow.c
index a4a1602..5c2f18a 100644
--- a/afb/afbwindow.c
+++ b/afb/afbwindow.c
@@ -62,39 +62,16 @@ SOFTWARE.
 #include "maskbits.h"
 
 Bool
-afbCreateWindow(pWin)
-	register WindowPtr pWin;
+afbCreateWindow(WindowPtr pWin)
 {
-	register afbPrivWin *pPrivWin;
-
-	pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
-	pPrivWin->pRotatedBorder = NullPixmap;
-	pPrivWin->pRotatedBackground = NullPixmap;
-	pPrivWin->fastBackground = FALSE;
-	pPrivWin->fastBorder = FALSE;
-#ifdef PIXMAP_PER_WINDOW
-	pWin->devPrivates[frameWindowPrivateIndex].ptr =
-			pWin->pDrawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr;
-#endif
-
 	return (TRUE);
 }
 
 /* This always returns true, because Xfree can't fail.  It might be possible
  * on some devices for Destroy to fail */
 Bool
-afbDestroyWindow(pWin)
-	WindowPtr pWin;
+afbDestroyWindow(WindowPtr pWin)
 {
-	register afbPrivWin *pPrivWin;
-
-	pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
-
-	if (pPrivWin->pRotatedBorder)
-		(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
-	if (pPrivWin->pRotatedBackground)
-		(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
-
 	return (TRUE);
 }
 
@@ -106,46 +83,10 @@ afbMapWindow(pWindow)
 	return (TRUE);
 }
 
-/* (x, y) is the upper left corner of the window on the screen
-   do we really need to pass this?  (is it a;ready in pWin->absCorner?)
-   we only do the rotation for pixmaps that are 32 bits wide (padded
-or otherwise.)
-   afbChangeWindowAttributes() has already put a copy of the pixmap
-in pPrivWin->pRotated*
-*/
-
 /*ARGSUSED*/
 Bool
-afbPositionWindow(pWin, x, y)
-	WindowPtr pWin;
-	int x, y;
+afbPositionWindow(WindowPtr pWin, int x, int y)
 {
-	register afbPrivWin *pPrivWin;
-	int		reset = 0;
-
-	pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
-	if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground) {
-		afbXRotatePixmap(pPrivWin->pRotatedBackground,
-								pWin->drawable.x - pPrivWin->oldRotate.x);
-		afbYRotatePixmap(pPrivWin->pRotatedBackground,
-								pWin->drawable.y - pPrivWin->oldRotate.y);
-		reset = 1;
-	}
-
-	if (!pWin->borderIsPixel && pPrivWin->fastBorder) {
-		while (pWin->backgroundState == ParentRelative)
-			pWin = pWin->parent;
-		afbXRotatePixmap(pPrivWin->pRotatedBorder,
-								pWin->drawable.x - pPrivWin->oldRotate.x);
-		afbYRotatePixmap(pPrivWin->pRotatedBorder,
-								pWin->drawable.y - pPrivWin->oldRotate.y);
-		reset = 1;
-	}
-	if (reset) {
-		pPrivWin->oldRotate.x = pWin->drawable.x;
-		pPrivWin->oldRotate.y = pWin->drawable.y;
-	}
-
 	/* This is the "wrong" fix to the right problem, but it doesn't really
 	 * cost very much.  When the window is moved, we need to invalidate any
 	 * RotatedPixmap that exists in any GC currently validated against this
@@ -215,104 +156,8 @@ afbCopyWindow(pWin, ptOldOrg, prgnSrc)
 	REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
 }
 
-
-
-/* swap in correct PaintWindow* routine.  If we can use a fast output
-routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
-of it in devPrivate.
-*/
 Bool
-afbChangeWindowAttributes(pWin, mask)
-	register WindowPtr pWin;
-	register unsigned long mask;
+afbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
 {
-	register unsigned long index;
-	register afbPrivWin *pPrivWin;
-	WindowPtr		pBgWin;
-
-	pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
-	/*
-	 * When background state changes from ParentRelative and
-	 * we had previously rotated the fast border pixmap to match
-	 * the parent relative origin, rerotate to match window
-	 */
-	if (mask & (CWBackPixmap | CWBackPixel) &&
-		 pWin->backgroundState != ParentRelative && pPrivWin->fastBorder &&
-		 (pPrivWin->oldRotate.x != pWin->drawable.x ||
-		  pPrivWin->oldRotate.y != pWin->drawable.y)) {
-		afbXRotatePixmap(pPrivWin->pRotatedBorder,
-								pWin->drawable.x - pPrivWin->oldRotate.x);
-		afbYRotatePixmap(pPrivWin->pRotatedBorder,
-								pWin->drawable.y - pPrivWin->oldRotate.y);
-		pPrivWin->oldRotate.x = pWin->drawable.x;
-		pPrivWin->oldRotate.y = pWin->drawable.y;
-	}
-	while(mask) {
-		index = lowbit (mask);
-		mask &= ~index;
-		switch(index) {
-			case CWBackPixmap:
-				if (pWin->backgroundState == None)
-					pPrivWin->fastBackground = FALSE;
-				else if (pWin->backgroundState == ParentRelative) {
-					pPrivWin->fastBackground = FALSE;
-					/* Rotate border to match parent origin */
-					if (pPrivWin->pRotatedBorder) {
-						for (pBgWin = pWin->parent;
-							  pBgWin->backgroundState == ParentRelative;
-							  pBgWin = pBgWin->parent);
-						afbXRotatePixmap(pPrivWin->pRotatedBorder,
-												pBgWin->drawable.x - pPrivWin->oldRotate.x);
-						afbYRotatePixmap(pPrivWin->pRotatedBorder,
-												pBgWin->drawable.y - pPrivWin->oldRotate.y);
-						pPrivWin->oldRotate.x = pBgWin->drawable.x;
-						pPrivWin->oldRotate.y = pBgWin->drawable.y;
-					}
-				} else if ((pWin->background.pixmap->drawable.width <= PPW) &&
-							  !(pWin->background.pixmap->drawable.width &
-								 (pWin->background.pixmap->drawable.width - 1))) {
-					afbCopyRotatePixmap(pWin->background.pixmap,
-												&pPrivWin->pRotatedBackground,
-												pWin->drawable.x, pWin->drawable.y);
-					if (pPrivWin->pRotatedBackground) {
-						pPrivWin->fastBackground = TRUE;
-						pPrivWin->oldRotate.x = pWin->drawable.x;
-						pPrivWin->oldRotate.y = pWin->drawable.y;
-					} else
-						pPrivWin->fastBackground = FALSE;
-				} else
-					pPrivWin->fastBackground = FALSE;
-					break;
-
-			case CWBackPixel:
-				pPrivWin->fastBackground = FALSE;
-				break;
-
-			case CWBorderPixmap:
-				if ((pWin->border.pixmap->drawable.width <= PPW) &&
-					 !(pWin->border.pixmap->drawable.width &
-						(pWin->border.pixmap->drawable.width - 1))) {
-					for (pBgWin = pWin;
-						  pBgWin->backgroundState == ParentRelative;
-						  pBgWin = pBgWin->parent);
-					afbCopyRotatePixmap(pWin->border.pixmap,
-												&pPrivWin->pRotatedBorder,
-												pBgWin->drawable.x, pBgWin->drawable.y);
-					if (pPrivWin->pRotatedBorder) {
-						pPrivWin->fastBorder = TRUE;
-						pPrivWin->oldRotate.x = pBgWin->drawable.x;
-						pPrivWin->oldRotate.y = pBgWin->drawable.y;
-					} else
-						pPrivWin->fastBorder = FALSE;
-				} else
-					pPrivWin->fastBorder = FALSE;
-				break;
-			case CWBorderPixel:
-				pPrivWin->fastBorder = FALSE;
-				break;
-		}
-	}
-	/* Again, we have no failure modes indicated by any of the routines
-	 * we've called, so we have to assume it worked */
 	return (TRUE);
 }
diff --git a/cfb/Makefile.am.inc b/cfb/Makefile.am.inc
index 5aa913a..a2ee143 100644
--- a/cfb/Makefile.am.inc
+++ b/cfb/Makefile.am.inc
@@ -8,7 +8,7 @@ DISTCLEANFILES = $(libcfb_gen_sources)
 CFB_INCLUDES = -I$(top_srcdir)/mfb -I$(top_srcdir)/cfb
 
 libcfb_common_sources =  $(top_srcdir)/cfb/cfbgc.c $(top_srcdir)/cfb/cfbrrop.c \
-	$(top_srcdir)/cfb/cfbwindow.c $(top_srcdir)/cfb/cfbpntwin.c \
+	$(top_srcdir)/cfb/cfbwindow.c \
 	$(top_srcdir)/cfb/cfbmskbits.c $(top_srcdir)/cfb/cfbpixmap.c \
 	$(top_srcdir)/cfb/cfbbitblt.c $(top_srcdir)/cfb/cfbfillsp.c \
 	$(top_srcdir)/cfb/cfbsetsp.c $(top_srcdir)/cfb/cfbscrinit.c \
diff --git a/cfb/cfb.h b/cfb/cfb.h
index 5614f4f..c9ceda9 100644
--- a/cfb/cfb.h
+++ b/cfb/cfb.h
@@ -56,7 +56,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
 
 extern int  cfbGCPrivateIndex;
-extern int  cfbWindowPrivateIndex;
 
 /* private field of GC */
 typedef struct {
@@ -81,20 +80,6 @@ typedef struct {
     CfbBits	xor, and;
 } cfbRRopRec, *cfbRRopPtr;
 
-/* private field of window */
-typedef struct {
-    unsigned	char fastBorder; /* non-zero if border is 32 bits wide */
-    unsigned	char fastBackground;
-    unsigned short unused; /* pad for alignment with Sun compiler */
-    DDXPointRec	oldRotate;
-    PixmapPtr	pRotatedBackground;
-    PixmapPtr	pRotatedBorder;
-    } cfbPrivWin;
-
-#define cfbGetWindowPrivate(_pWin) ((cfbPrivWin *)\
-	(_pWin)->devPrivates[cfbWindowPrivateIndex].ptr)
-
-
 /* cfb8bit.c */
 
 extern int cfbSetStipple(
@@ -313,7 +298,6 @@ extern int cfb8SegmentSS1RectXor(
 
 extern Bool cfbAllocatePrivates(
     ScreenPtr /*pScreen*/,
-    int * /*window_index*/,
     int * /*gc_index*/
 );
 /* cfbbitblt.c */
@@ -806,27 +790,6 @@ extern void cfbFillPoly1RectGeneral(
     int /*count*/,
     DDXPointPtr /*ptsIn*/
 );
-/* cfbpntwin.c */
-
-extern void cfbPaintWindow(
-    WindowPtr /*pWin*/,
-    RegionPtr /*pRegion*/,
-    int /*what*/
-);
-
-extern void cfbFillBoxSolid(
-    DrawablePtr /*pDrawable*/,
-    int /*nBox*/,
-    BoxPtr /*pBox*/,
-    unsigned long /*pixel*/
-);
-
-extern void cfbFillBoxTile32(
-    DrawablePtr /*pDrawable*/,
-    int /*nBox*/,
-    BoxPtr /*pBox*/,
-    PixmapPtr /*tile*/
-);
 /* cfbpolypnt.c */
 
 extern void cfbPolyPoint(
diff --git a/cfb/cfballpriv.c b/cfb/cfballpriv.c
index e0ccdf4..858ff60 100644
--- a/cfb/cfballpriv.c
+++ b/cfb/cfballpriv.c
@@ -45,7 +45,6 @@ in this Software without prior written a
 #include "mibstore.h"
 
 #if 1 || PSZ==8
-int cfbWindowPrivateIndex = -1;
 int cfbGCPrivateIndex = -1;
 #endif
 #ifdef CFB_NEED_SCREEN_PRIVATE
@@ -55,29 +54,20 @@ static unsigned long cfbGeneration = 0;
 
 
 Bool
-cfbAllocatePrivates(pScreen, window_index, gc_index)
-    ScreenPtr	pScreen;
-    int		*window_index, *gc_index;
+cfbAllocatePrivates(ScreenPtr pScreen, int *gc_index)
 {
-    if (!window_index || !gc_index ||
-	(*window_index == -1 && *gc_index == -1))
+    if (!gc_index || *gc_index == -1)
     {
-    	if (!mfbAllocatePrivates(pScreen,
-			     	 &cfbWindowPrivateIndex, &cfbGCPrivateIndex))
+    	if (!mfbAllocatePrivates(pScreen, &cfbGCPrivateIndex))
 	    return FALSE;
-    	if (window_index)
-	    *window_index = cfbWindowPrivateIndex;
     	if (gc_index)
 	    *gc_index = cfbGCPrivateIndex;
     }
     else
     {
-	cfbWindowPrivateIndex = *window_index;
 	cfbGCPrivateIndex = *gc_index;
     }
-    if (!AllocateWindowPrivate(pScreen, cfbWindowPrivateIndex,
-			       sizeof(cfbPrivWin)) ||
-	!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
+    if (!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
 	return FALSE;
 #ifdef CFB_NEED_SCREEN_PRIVATE
     if (cfbGeneration != serverGeneration)
diff --git a/cfb/cfbmap.h b/cfb/cfbmap.h
index 1d6a3f8..2e709b1 100644
--- a/cfb/cfbmap.h
+++ b/cfb/cfbmap.h
@@ -71,8 +71,6 @@ in this Software without prior written a
 #undef cfbDoBitbltGeneral
 #undef cfbDoBitbltOr
 #undef cfbDoBitbltXor
-#undef cfbFillBoxSolid
-#undef cfbFillBoxTile32
 #undef cfbFillBoxTile32sCopy
 #undef cfbFillBoxTile32sGeneral
 #undef cfbFillBoxTileOdd
@@ -108,7 +106,6 @@ in this Software without prior written a
 #undef cfbNonTEOps
 #undef cfbNonTEOps1Rect
 #undef cfbPadPixmap
-#undef cfbPaintWindow
 #undef cfbPolyFillArcSolidCopy
 #undef cfbPolyFillArcSolidGeneral
 #undef cfbPolyFillRect
@@ -250,8 +247,6 @@ cfb can not hack PSZ yet
 #define cfbDoBitbltOr CFBNAME(DoBitbltOr)
 #define cfbDoBitbltXor CFBNAME(DoBitbltXor)
 #define cfbExpandDirectColors CFBNAME(cfbExpandDirectColors)
-#define cfbFillBoxSolid CFBNAME(FillBoxSolid)
-#define cfbFillBoxTile32 CFBNAME(FillBoxTile32)
 #define cfbFillBoxTile32sCopy CFBNAME(FillBoxTile32sCopy)
 #define cfbFillBoxTile32sGeneral CFBNAME(FillBoxTile32sGeneral)
 #define cfbFillBoxTileOdd CFBNAME(FillBoxTileOdd)
@@ -288,7 +283,6 @@ cfb can not hack PSZ yet
 #define cfbNonTEOps CFBNAME(NonTEOps)
 #define cfbNonTEOps1Rect CFBNAME(NonTEOps1Rect)
 #define cfbPadPixmap CFBNAME(PadPixmap)
-#define cfbPaintWindow CFBNAME(PaintWindow)
 #define cfbPolyFillArcSolidCopy CFBNAME(PolyFillArcSolidCopy)
 #define cfbPolyFillArcSolidGeneral CFBNAME(PolyFillArcSolidGeneral)
 #define cfbPolyFillRect CFBNAME(PolyFillRect)
diff --git a/cfb/cfbpntwin.c b/cfb/cfbpntwin.c
deleted file mode 100644
index 32f011e..0000000
--- a/cfb/cfbpntwin.c
+++ /dev/null
@@ -1,768 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 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.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        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 notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL 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 <X11/X.h>
-
-#include "windowstr.h"
-#include "regionstr.h"
-#include "pixmapstr.h"
-#include "scrnintstr.h"
-
-#include "cfb.h"
-#include "cfbmskbits.h"
-#include "mi.h"
-
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#include "panoramiXsrv.h"
-#endif
-
-void
-cfbPaintWindow(pWin, pRegion, what)
-    WindowPtr	pWin;
-    RegionPtr	pRegion;
-    int		what;
-{
-    register cfbPrivWin	*pPrivWin;
-    WindowPtr	pBgWin;
-
-    pPrivWin = cfbGetWindowPrivate(pWin);
-
-
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    break;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    break;
-	case BackgroundPixmap:
-	    if (pPrivWin->fastBackground)
-	    {
-		cfbFillBoxTile32 ((DrawablePtr)pWin,
-				  (int)REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion),
-				  pPrivWin->pRotatedBackground);
-	    }
-	    else
-	    {
-		int xorg = pWin->drawable.x;
-		int yorg = pWin->drawable.y;
-#ifdef PANORAMIX
-		if(!noPanoramiXExtension) {
-		    int index = pWin->drawable.pScreen->myNum;
-		    if(WindowTable[index] == pWin) {
-			xorg -= panoramiXdataPtr[index].x;
-			yorg -= panoramiXdataPtr[index].y;
-		    }
-		}
-#endif
-		cfbFillBoxTileOdd ((DrawablePtr)pWin,
-				   (int)REGION_NUM_RECTS(pRegion),
-				   REGION_RECTS(pRegion),
-				   pWin->background.pixmap,
-				   xorg, yorg);
-	    }
-	    break;
-	case BackgroundPixel:
-	    cfbFillBoxSolid ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel);
-	    break;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    cfbFillBoxSolid ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel);
-	}
-	else if (pPrivWin->fastBorder)
-	{
-	    cfbFillBoxTile32 ((DrawablePtr)pWin,
-			      (int)REGION_NUM_RECTS(pRegion),
-			      REGION_RECTS(pRegion),
-			      pPrivWin->pRotatedBorder);
-	}
-	else
-	{
-	    int xorg, yorg;
-
-	    for (pBgWin = pWin;
-		 pBgWin->backgroundState == ParentRelative;
-		 pBgWin = pBgWin->parent);
-
-	    xorg = pBgWin->drawable.x;
-	    yorg = pBgWin->drawable.y;
-
-#ifdef PANORAMIX
-	    if(!noPanoramiXExtension) {
-		int index = pWin->drawable.pScreen->myNum;
-		if(WindowTable[index] == pBgWin) {
-		    xorg -= panoramiXdataPtr[index].x;
-		    yorg -= panoramiXdataPtr[index].y;
-		}
-	    }
-#endif
-
-	    cfbFillBoxTileOdd ((DrawablePtr)pWin,
-			       (int)REGION_NUM_RECTS(pRegion),
-			       REGION_RECTS(pRegion),
-			       pWin->border.pixmap,
-			       xorg, yorg);
-	}
-	break;
-    }
-}
-
-/*
- * Use the RROP macros in copy mode
- */
-
-#define RROP GXcopy
-#include "cfbrrop.h"
-
-#ifdef RROP_UNROLL
-# define Expand(left,right,leftAdjust) {\
-    int part = nmiddle & RROP_UNROLL_MASK; \
-    int widthStep; \
-    widthStep = widthDst - nmiddle - leftAdjust; \
-    nmiddle >>= RROP_UNROLL_SHIFT; \
-    while (h--) { \
-	left \
-	pdst += part; \
-	switch (part) { \
-	    RROP_UNROLL_CASE(pdst) \
-	} \
-	m = nmiddle; \
-	while (m) { \
-	    pdst += RROP_UNROLL; \
-	    RROP_UNROLL_LOOP(pdst) \
-	    m--; \
-	} \
-	right \
-	pdst += widthStep; \
-    } \
-}
-
-#else
-# define Expand(left, right, leftAdjust) { \
-    int widthStep; \
-    widthStep = widthDst - nmiddle - leftAdjust; \
-    while (h--) { \
-	left \
-	m = nmiddle; \
-	while (m--) {\
-	    RROP_SOLID(pdst); \
-	    pdst++; \
-	} \
-	right \
-	pdst += widthStep; \
-    } \
-}
-#endif
-
-void
-cfbFillBoxSolid (pDrawable, nBox, pBox, pixel)
-    DrawablePtr	    pDrawable;
-    int		    nBox;
-    BoxPtr	    pBox;
-    unsigned long   pixel;
-{
-    CfbBits   *pdstBase;
-    int		    widthDst;
-    register int    h;
-    register CfbBits   *pdst;
-    int		    nmiddle;
-    int		    w;
-#if PSZ == 24
-    int leftIndex, rightIndex;
-    CfbBits piQxelArray[3], *pdstULC; /*upper left corner*/
-
-    piQxelArray[0] = (pixel&0xFFFFFF) | ((pixel&0xFF)<<24);
-    piQxelArray[1] = ((pixel&0xFFFF00)>>8) | ((pixel&0xFFFF)<<16);
-    piQxelArray[2] = ((pixel&0xFFFFFF)<<8) | ((pixel&0xFF0000)>>16);
-#else
-    register CfbBits   rrop_xor;
-    register CfbBits   leftMask, rightMask;
-    register int    m;
-#endif
-
-    cfbGetLongWidthAndPointer(pDrawable, widthDst, pdstBase);
-
-#if PSZ != 24
-    rrop_xor = PFILL(pixel);
-#endif
-    for (; nBox; nBox--, pBox++)
-    {
-    	pdst = pdstBase + pBox->y1 * widthDst;
-    	h = pBox->y2 - pBox->y1;
-	w = pBox->x2 - pBox->x1;
-#if PSZ == 8
-	if (w == 1)
-	{
-	    register char    *pdstb = ((char *) pdst) + pBox->x1;
-	    int	    incr = widthDst * PGSZB;
-
-	    while (h--)
-	    {
-		*pdstb = rrop_xor;
-		pdstb += incr;
-	    }
-	}
-	else
-	{
-#endif
-#if PSZ == 24
-/* _Box has x1, y1, x2, y2*/
-	  leftIndex = pBox->x1 & 3;
-	  rightIndex = ((leftIndex+w)<5)?0:(pBox->x2 &3);
-	  nmiddle = w - rightIndex;
-	  if(leftIndex){
-	      nmiddle -= (4 - leftIndex);
-	  }
-	  nmiddle >>= 2;
-	  if(nmiddle < 0)
-	    nmiddle = 0;
-
-	  pdst = pdstBase + pBox->y1 * widthDst + ((pBox->x1*3) >> 2);
-
-	  switch(leftIndex+w){
-	  case 4:
-	    switch(leftIndex){
-	    case 0:
-	      while(h--){
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst   = piQxelArray[2];
-		pdst -=2;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 1:
-	      while(h--){
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst   = piQxelArray[2];
-		pdst -=2;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 2:
-	      while(h--){
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst-- = piQxelArray[2];
-		pdst += widthDst;
-	      }
-	      break;
-	    case 3:
-	      while(h--){
-		*pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
-		pdst += widthDst;
-	      }
-	      break;
-	    }
-	    break;
-	  case 3:
-	    switch(leftIndex){
-	    case 0:
-	      while(h--){
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 1:
-	      while(h--){
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 2:
-	      while(h--){
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    }
-	    break;
-	  case 2:
-	    while(h--){
-	      if(leftIndex){
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-	      }
-	      else{
-		*pdst++ = piQxelArray[0];
-	      }
-		*pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
-		pdst--;
-		pdst += widthDst;
-	    }
-	    break;
-	  case 1: /*only if leftIndex = 0 and w = 1*/
-	    while(h--){
-		*pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
-		pdst += widthDst;
-	      }
-	    break;
-	  case 0: /*never*/
-	    break;
-	  default:
-	  {
-	    w = nmiddle;
-	    pdstULC = pdst;
-/*	    maskbits (pBox->x1, w, leftMask, rightMask, nmiddle);*/
-	    while(h--){
-	      nmiddle = w;
-	      pdst = pdstULC;
-	      switch(leftIndex){
-	      case 0:
-		break;
-	      case 1:
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst++ = piQxelArray[2];
-	        break;
-	      case 2:
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst++ = piQxelArray[2];
-	        break;
-	      case 3:
-		*pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
-		pdst++;
-	        break;
-	      }
-	      while(nmiddle--){
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst++ = piQxelArray[2];
-	      }
-	      switch(rightIndex){
-	      case 0:
-		break;
-	      case 1:
-		*pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
-	        break;
-	      case 2:
-		*pdst++ = piQxelArray[0];
-		*pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
-	        break;
-	      case 3:
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-	        break;
-	    }
-	    pdstULC += widthDst;
-	    }
-
-	  }
-	}
-#else
-	pdst += (pBox->x1 >> PWSH);
-	if ((pBox->x1 & PIM) + w <= PPW)
-	{
-	    maskpartialbits(pBox->x1, w, leftMask);
-	    while (h--) {
-		*pdst = (*pdst & ~leftMask) | (rrop_xor & leftMask);
-		pdst += widthDst;
-	    }
-	}
-	else
-	{
-	    maskbits (pBox->x1, w, leftMask, rightMask, nmiddle);
-	    if (leftMask)
-	    {
-		if (rightMask)
-		{
-		    Expand (RROP_SOLID_MASK (pdst, leftMask); pdst++; ,
-			    RROP_SOLID_MASK (pdst, rightMask); ,
-			    1)
-		}
-		else
-		{
-		    Expand (RROP_SOLID_MASK (pdst, leftMask); pdst++;,
-			    ;,
-			    1)
-		}
-	    }
-	    else
-	    {
-		if (rightMask)
-		{
-		    Expand (;,
-			    RROP_SOLID_MASK (pdst, rightMask);,
-			    0)
-		}
-		else
-		{
-		    Expand (;,
-			    ;,
-			    0)
-		}
-	    }
-	}
-#endif
-#if PSZ == 8
-	}
-#endif
-    }
-}
-
-void
-cfbFillBoxTile32 (pDrawable, nBox, pBox, tile)
-    DrawablePtr	    pDrawable;
-    int		    nBox;	/* number of boxes to fill */
-    BoxPtr 	    pBox;	/* pointer to list of boxes to fill */
-    PixmapPtr	    tile;	/* rotated, expanded tile */
-{
-    register CfbBits  *pdst;
-    CfbBits	    *psrc;
-    int			    tileHeight;
-
-    int			    widthDst;
-    int			    w;
-    int			    h;
-    int			    nmiddle;
-    int			    y;
-    int			    srcy;
-
-    CfbBits	    *pdstBase;
-#if PSZ == 24
-    int			    leftIndex, rightIndex;
-    CfbBits piQxelArray[3], *pdstULC;
-#else
-    register CfbBits  rrop_xor;	
-    register CfbBits  leftMask;
-    register CfbBits  rightMask;
-    register int      m;
-#endif
-
-    tileHeight = tile->drawable.height;
-    psrc = (CfbBits *)tile->devPrivate.ptr;
-
-    cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase);
-
-    while (nBox--)
-    {
-#if PSZ == 24
-	w = pBox->x2 - pBox->x1;
-	h = pBox->y2 - pBox->y1;
-	y = pBox->y1;
-	leftIndex = pBox->x1 & 3;
-/*	rightIndex = ((leftIndex+w)<5)?0:pBox->x2 &3;*/
-	rightIndex = pBox->x2 &3;
-	nmiddle = w - rightIndex;
-	if(leftIndex){
-	  nmiddle -= (4 - leftIndex);
-	}
-	nmiddle >>= 2;
-	if(nmiddle < 0)
-	  nmiddle = 0;
-
-	pdst = pdstBase + ((pBox->x1 *3)>> 2) +  pBox->y1 * widthDst;
-	srcy = y % tileHeight;
-
-#define StepTile    piQxelArray[0] = (psrc[srcy] & 0xFFFFFF) | ((psrc[srcy] & 0xFF)<<24); \
-		    piQxelArray[1] = (psrc[srcy] & 0xFFFF00) | ((psrc[srcy] & 0xFFFF)<<16); \
-		    piQxelArray[2] = ((psrc[srcy] & 0xFF0000)>>16) | \
-		    		     ((psrc[srcy] & 0xFFFFFF)<<8); \
-		    /*rrop_xor = psrc[srcy];*/ \
-		    ++srcy; \
-		    if (srcy == tileHeight) \
-		        srcy = 0;
-
-	  switch(leftIndex+w){
-	  case 4:
-	    switch(leftIndex){
-	    case 0:
-	      while(h--){
-		  StepTile
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst   = piQxelArray[2];
-		pdst-=2;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 1:
-	      while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst   = piQxelArray[2];
-		pdst-=2;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 2:
-	      while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst--   = piQxelArray[2];
-		pdst += widthDst;
-	      }
-	      break;
-	    case 3:
-	      while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
-		pdst += widthDst;
-	      }
-	      break;
-	    }
-	    break;
-	  case 3:
-	    switch(leftIndex){
-	    case 0:
-	      while(h--){
-		  StepTile
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 1:
-	      while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 2:
-	      while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    }
-	    break;
-	  case 2:
-	    while(h--){
-		  StepTile
-	      if(leftIndex){
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-	      }
-	      else{
-		*pdst++ = piQxelArray[0];
-	      }
-		*pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
-		pdst--;
-		pdst += widthDst;
-	    }
-	    break;
-	  case 1: /*only if leftIndex = 0 and w = 1*/
-	    while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
-		pdst += widthDst;
-	      }
-	    break;
-	  case 0: /*never*/
-	    break;
-	  default:
-	  {
-	    w = nmiddle;
-	    pdstULC = pdst;
-
-	    while(h--){
-	      StepTile
-	      nmiddle = w;
-	      pdst = pdstULC;
-	      switch(leftIndex){
-	      case 0:
-		break;
-	      case 1:
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst++ = piQxelArray[2];
-	        break;
-	      case 2:
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst++ = piQxelArray[2];
-	        break;
-	      case 3:
-		*pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
-		pdst++;
-	        break;
-	      }
-	      while(nmiddle--){
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst++ = piQxelArray[2];
-	      }
-	      switch(rightIndex){
-	      case 0:
-		break;
-	      case 1:
-		*pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
-		break;
-	      case 2:
-		*pdst++ = piQxelArray[0];
-		*pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
-		break;
-	      case 3:
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		break;
-	      }
-	      pdstULC += widthDst;
-	    }
-	  }
-	  }
-#else
-	w = pBox->x2 - pBox->x1;
-	h = pBox->y2 - pBox->y1;
-	y = pBox->y1;
-	pdst = pdstBase + (pBox->y1 * widthDst) + (pBox->x1 >> PWSH);
-	srcy = y % tileHeight;
-
-#define StepTile    rrop_xor = psrc[srcy]; \
-		    ++srcy; \
-		    if (srcy == tileHeight) \
-		        srcy = 0;
-
-	if ( ((pBox->x1 & PIM) + w) < PPW)
-	{
-	    maskpartialbits(pBox->x1, w, leftMask);
-	    rightMask = ~leftMask;
-	    while (h--)
-	    {
-		StepTile
-		*pdst = (*pdst & rightMask) | (rrop_xor & leftMask);
-		pdst += widthDst;
-	    }
-	}
-	else
-	{
-	    maskbits(pBox->x1, w, leftMask, rightMask, nmiddle);
-
-	    if (leftMask)
-	    {
-		if (rightMask)
-		{
-		    Expand (StepTile
-			    RROP_SOLID_MASK(pdst, leftMask); pdst++;,
-			    RROP_SOLID_MASK(pdst, rightMask);,
-			    1)
-		}
-		else
-		{
-		    Expand (StepTile
-			    RROP_SOLID_MASK(pdst, leftMask); pdst++;,
-			    ;,
-			    1)
-		}
-	    }
-	    else
-	    {
-		if (rightMask)
-		{
-		    Expand (StepTile
-			    ,
-			    RROP_SOLID_MASK(pdst, rightMask);,
-			    0)
-		}
-		else
-		{
-		    Expand (StepTile
-			    ,
-			    ;,
-			    0)
-		}
-	    }
-	}
-#endif
-        pBox++;
-    }
-}
diff --git a/cfb/cfbscrinit.c b/cfb/cfbscrinit.c
index 83f5cf0..ddfb41e 100644
--- a/cfb/cfbscrinit.c
+++ b/cfb/cfbscrinit.c
@@ -88,7 +88,7 @@ cfbSetupScreen(pScreen, pbits, xsize, ys
     int dpix, dpiy;		/* dots per inch */
     int width;			/* pixel width of frame buffer */
 {
-    if (!cfbAllocatePrivates(pScreen, (int *) 0, (int *) 0))
+    if (!cfbAllocatePrivates(pScreen, NULL))
 	return FALSE;
     pScreen->defColormap = FakeClientID(0);
     /* let CreateDefColormap do whatever it wants for pixels */ 
@@ -103,8 +103,6 @@ cfbSetupScreen(pScreen, pbits, xsize, ys
     pScreen->ChangeWindowAttributes = cfbChangeWindowAttributes;
     pScreen->RealizeWindow = cfbMapWindow;
     pScreen->UnrealizeWindow = cfbUnmapWindow;
-    pScreen->PaintWindowBackground = cfbPaintWindow;
-    pScreen->PaintWindowBorder = cfbPaintWindow;
     pScreen->CopyWindow = cfbCopyWindow;
     pScreen->CreatePixmap = cfbCreatePixmap;
     pScreen->DestroyPixmap = cfbDestroyPixmap;
diff --git a/cfb/cfbtile32.c b/cfb/cfbtile32.c
index fb6a106..90439ad 100644
--- a/cfb/cfbtile32.c
+++ b/cfb/cfbtile32.c
@@ -1,5 +1,5 @@
 /*
- * Fill 32 bit tiled rectangles.  Used by both PolyFillRect and PaintWindow.
+ * Fill 32 bit tiled rectangles.  Used by PolyFillRect.
  * no depth dependencies.
  */
 
diff --git a/cfb/cfbunmap.h b/cfb/cfbunmap.h
index 61c7fc9..d15c23e 100644
--- a/cfb/cfbunmap.h
+++ b/cfb/cfbunmap.h
@@ -74,8 +74,6 @@
 #undef cfbDoBitbltOr
 #undef cfbDoBitbltXor
 #undef cfbExpandDirectColors
-#undef cfbFillBoxSolid
-#undef cfbFillBoxTile32
 #undef cfbFillBoxTile32sCopy
 #undef cfbFillBoxTile32sGeneral
 #undef cfbFillBoxTileOdd
@@ -112,7 +110,6 @@
 #undef cfbNonTEOps
 #undef cfbNonTEOps1Rect
 #undef cfbPadPixmap
-#undef cfbPaintWindow
 #undef cfbPolyFillArcSolidCopy
 #undef cfbPolyFillArcSolidGeneral
 #undef cfbPolyFillRect
diff --git a/cfb/cfbwindow.c b/cfb/cfbwindow.c
index e04b73d..c4f027b 100644
--- a/cfb/cfbwindow.c
+++ b/cfb/cfbwindow.c
@@ -60,19 +60,8 @@ SOFTWARE.
 #include "cfbmskbits.h"
 
 Bool
-cfbCreateWindow(pWin)
-    WindowPtr pWin;
+cfbCreateWindow(WindowPtr pWin)
 {
-    cfbPrivWin *pPrivWin;
-
-    pPrivWin = cfbGetWindowPrivate(pWin);
-    pPrivWin->pRotatedBorder = NullPixmap;
-    pPrivWin->pRotatedBackground = NullPixmap;
-    pPrivWin->fastBackground = FALSE;
-    pPrivWin->fastBorder = FALSE;
-    pPrivWin->oldRotate.x = 0;
-    pPrivWin->oldRotate.y = 0;
-
 #ifdef PIXMAP_PER_WINDOW
     /* Setup pointer to Screen pixmap */
     pWin->devPrivates[frameWindowPrivateIndex].ptr =
@@ -83,17 +72,8 @@ cfbCreateWindow(pWin)
 }
 
 Bool
-cfbDestroyWindow(pWin)
-    WindowPtr pWin;
+cfbDestroyWindow(WindowPtr pWin)
 {
-    cfbPrivWin *pPrivWin;
-
-    pPrivWin = cfbGetWindowPrivate(pWin);
-
-    if (pPrivWin->pRotatedBorder)
-	(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
-    if (pPrivWin->pRotatedBackground)
-	(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
     return(TRUE);
 }
 
@@ -105,47 +85,10 @@ cfbMapWindow(pWindow)
     return(TRUE);
 }
 
-/* (x, y) is the upper left corner of the window on the screen 
-   do we really need to pass this?  (is it a;ready in pWin->absCorner?)
-   we only do the rotation for pixmaps that are 32 bits wide (padded
-or otherwise.)
-   cfbChangeWindowAttributes() has already put a copy of the pixmap
-in pPrivWin->pRotated*
-*/
 /*ARGSUSED*/
 Bool
-cfbPositionWindow(pWin, x, y)
-    WindowPtr pWin;
-    int x, y;
+cfbPositionWindow(WindowPtr pWin, int x, int y)
 {
-    cfbPrivWin *pPrivWin;
-    int setxy = 0;
-
-    pPrivWin = cfbGetWindowPrivate(pWin);
-    if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
-    {
-	cfbXRotatePixmap(pPrivWin->pRotatedBackground,
-		      pWin->drawable.x - pPrivWin->oldRotate.x);
-	cfbYRotatePixmap(pPrivWin->pRotatedBackground,
-		      pWin->drawable.y - pPrivWin->oldRotate.y);
-	setxy = 1;
-    }
-
-    if (!pWin->borderIsPixel &&	pPrivWin->fastBorder)
-    {
-	while (pWin->backgroundState == ParentRelative)
-	    pWin = pWin->parent;
-	cfbXRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.x - pPrivWin->oldRotate.x);
-	cfbYRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.y - pPrivWin->oldRotate.y);
-	setxy = 1;
-    }
-    if (setxy)
-    {
-	pPrivWin->oldRotate.x = pWin->drawable.x;
-	pPrivWin->oldRotate.y = pWin->drawable.y;
-    }
     return (TRUE);
 }
 
@@ -209,129 +152,9 @@ cfbCopyWindow(pWin, ptOldOrg, prgnSrc)
     REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
 }
 
-
-
-/* swap in correct PaintWindow* routine.  If we can use a fast output
-routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
-of it in devPrivates[cfbWindowPrivateIndex].ptr.
-*/
 Bool
-cfbChangeWindowAttributes(pWin, mask)
-    WindowPtr pWin;
-    unsigned long mask;
+cfbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
 {
-    register unsigned long index;
-    register cfbPrivWin *pPrivWin;
-    int width;
-    WindowPtr	pBgWin;
-
-    pPrivWin = cfbGetWindowPrivate(pWin);
-
-    /*
-     * When background state changes from ParentRelative and
-     * we had previously rotated the fast border pixmap to match
-     * the parent relative origin, rerotate to match window
-     */
-    if (mask & (CWBackPixmap | CWBackPixel) &&
-	pWin->backgroundState != ParentRelative &&
-	pPrivWin->fastBorder &&
-	(pPrivWin->oldRotate.x != pWin->drawable.x ||
-	 pPrivWin->oldRotate.y != pWin->drawable.y))
-    {
-	cfbXRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.x - pPrivWin->oldRotate.x);
-	cfbYRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.y - pPrivWin->oldRotate.y);
-	pPrivWin->oldRotate.x = pWin->drawable.x;
-	pPrivWin->oldRotate.y = pWin->drawable.y;
-    }
-    while(mask)
-    {
-	index = lowbit (mask);
-	mask &= ~index;
-	switch(index)
-	{
-	case CWBackPixmap:
-	    if (pWin->backgroundState == None)
-	    {
-		pPrivWin->fastBackground = FALSE;
-	    }
-	    else if (pWin->backgroundState == ParentRelative)
-	    {
-		pPrivWin->fastBackground = FALSE;
-		/* Rotate border to match parent origin */
-		if (pPrivWin->pRotatedBorder) {
-		    for (pBgWin = pWin->parent;
-			 pBgWin->backgroundState == ParentRelative;
-			 pBgWin = pBgWin->parent);
-		    cfbXRotatePixmap(pPrivWin->pRotatedBorder,
-				  pBgWin->drawable.x - pPrivWin->oldRotate.x);
-		    cfbYRotatePixmap(pPrivWin->pRotatedBorder,
-				  pBgWin->drawable.y - pPrivWin->oldRotate.y);
-		    pPrivWin->oldRotate.x = pBgWin->drawable.x;
-		    pPrivWin->oldRotate.y = pBgWin->drawable.y;
-		}
-	    }
-	    else if (((width = (pWin->background.pixmap->drawable.width * PSZ))
-		      <= PGSZ) && !(width & (width - 1)))
-	    {
-		cfbCopyRotatePixmap(pWin->background.pixmap,
-				    &pPrivWin->pRotatedBackground,
-				    pWin->drawable.x,
-				    pWin->drawable.y);
-		if (pPrivWin->pRotatedBackground)
-		{
-		    pPrivWin->fastBackground = TRUE;
-		    pPrivWin->oldRotate.x = pWin->drawable.x;
-		    pPrivWin->oldRotate.y = pWin->drawable.y;
-		}
-		else
-		{
-		    pPrivWin->fastBackground = FALSE;
-		}
-	    }
-	    else
-	    {
-		pPrivWin->fastBackground = FALSE;
-	    }
-	    break;
-
-	case CWBackPixel:
-	    pPrivWin->fastBackground = FALSE;
-	    break;
-
-	case CWBorderPixmap:
-	    if (((width = (pWin->border.pixmap->drawable.width * PSZ)) <= PGSZ) &&
-		!(width & (width - 1)))
-	    {
-		for (pBgWin = pWin;
-		     pBgWin->backgroundState == ParentRelative;
-		     pBgWin = pBgWin->parent);
-		cfbCopyRotatePixmap(pWin->border.pixmap,
-				    &pPrivWin->pRotatedBorder,
-				    pBgWin->drawable.x,
-				    pBgWin->drawable.y);
-		if (pPrivWin->pRotatedBorder)
-		{
-		    pPrivWin->fastBorder = TRUE;
-		    pPrivWin->oldRotate.x = pBgWin->drawable.x;
-		    pPrivWin->oldRotate.y = pBgWin->drawable.y;
-		}
-		else
-		{
-		    pPrivWin->fastBorder = FALSE;
-		}
-	    }
-	    else
-	    {
-		pPrivWin->fastBorder = FALSE;
-	    }
-	    break;
-	 case CWBorderPixel:
-	    pPrivWin->fastBorder = FALSE;
-	    break;
-	}
-    }
     return (TRUE);
 }
 
diff --git a/composite/compinit.c b/composite/compinit.c
index c557eeb..5f09fe2 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -70,7 +70,6 @@ compCloseScreen (int index, ScreenPtr pS
     pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
     
     pScreen->ClipNotify = cs->ClipNotify;
-    pScreen->PaintWindowBackground = cs->PaintWindowBackground;
     pScreen->UnrealizeWindow = cs->UnrealizeWindow;
     pScreen->RealizeWindow = cs->RealizeWindow;
     pScreen->DestroyWindow = cs->DestroyWindow;
@@ -431,9 +430,6 @@ compScreenInit (ScreenPtr pScreen)
     cs->UnrealizeWindow = pScreen->UnrealizeWindow;
     pScreen->UnrealizeWindow = compUnrealizeWindow;
 
-    cs->PaintWindowBackground = pScreen->PaintWindowBackground;
-    pScreen->PaintWindowBackground = compPaintWindowBackground;
-
     cs->ClipNotify = pScreen->ClipNotify;
     pScreen->ClipNotify = compClipNotify;
 
diff --git a/composite/compint.h b/composite/compint.h
index f69595c..535e1a4 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -123,7 +123,6 @@ typedef struct _CompScreen {
     DestroyWindowProcPtr	DestroyWindow;
     RealizeWindowProcPtr	RealizeWindow;
     UnrealizeWindowProcPtr	UnrealizeWindow;
-    PaintWindowProcPtr		PaintWindowBackground;
     ClipNotifyProcPtr		ClipNotify;
     /*
      * Called from ConfigureWindow, these
@@ -256,9 +255,6 @@ Bool
 compUnrealizeWindow (WindowPtr pWin);
 
 void
-compPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what);
-
-void
 compClipNotify (WindowPtr pWin, int dx, int dy);
 
 void
diff --git a/composite/compwindow.c b/composite/compwindow.c
index bfd2946..5792367 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -99,7 +99,7 @@ compRepaintBorder (ClientPtr pClient, po
 
 	REGION_NULL(pScreen, &exposed);
 	REGION_SUBTRACT(pScreen, &exposed, &pWindow->borderClip, &pWindow->winSize);
-	(*pWindow->drawable.pScreen->PaintWindowBorder)(pWindow, &exposed, PW_BORDER);
+	miPaintWindow(pWindow, &exposed, PW_BORDER);
 	REGION_UNINIT(pScreen, &exposed);
     }
     return TRUE;
@@ -240,21 +240,6 @@ compUnrealizeWindow (WindowPtr pWin)
     return ret;
 }
 
-void
-compPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    ScreenPtr		pScreen = pWin->drawable.pScreen;
-    CompSubwindowsPtr	csw = GetCompSubwindows (pWin);
-    CompScreenPtr	cs = GetCompScreen (pScreen);
-    
-    if (csw && csw->update == CompositeRedirectManual)
-	return;
-    pScreen->PaintWindowBackground = cs->PaintWindowBackground;
-    (*pScreen->PaintWindowBackground) (pWin, pRegion, what);
-    cs->PaintWindowBackground = pScreen->PaintWindowBackground;
-    pScreen->PaintWindowBackground = compPaintWindowBackground;
-}
-
 /*
  * Called after the borderClip for the window has settled down
  * We use this to make sure our extra borderClip has the right origin
diff --git a/dix/window.c b/dix/window.c
index ca4335c..717c5a7 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -1522,7 +1522,7 @@ PatchUp:
 
 	REGION_NULL(pScreen, &exposed);
 	REGION_SUBTRACT(pScreen, &exposed, &pWin->borderClip, &pWin->winSize);
-	(*pWin->drawable.pScreen->PaintWindowBorder)(pWin, &exposed, PW_BORDER);
+	miPaintWindow(pWin, &exposed, PW_BORDER);
 	REGION_UNINIT(pScreen, &exposed);
     }
     return error;
diff --git a/exa/exa.c b/exa/exa.c
index 458272d..eac2d91 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -604,8 +604,6 @@ exaCloseScreen(int i, ScreenPtr pScreen)
     pScreen->CloseScreen = pExaScr->SavedCloseScreen;
     pScreen->GetImage = pExaScr->SavedGetImage;
     pScreen->GetSpans = pExaScr->SavedGetSpans;
-    pScreen->PaintWindowBackground = pExaScr->SavedPaintWindowBackground;
-    pScreen->PaintWindowBorder = pExaScr->SavedPaintWindowBorder;
     pScreen->CreatePixmap = pExaScr->SavedCreatePixmap;
     pScreen->DestroyPixmap = pExaScr->SavedDestroyPixmap;
     pScreen->CopyWindow = pExaScr->SavedCopyWindow;
@@ -759,12 +757,6 @@ exaDriverInit (ScreenPtr		pScreen,
     pExaScr->SavedBitmapToRegion = pScreen->BitmapToRegion;
     pScreen->BitmapToRegion = exaBitmapToRegion;
 
-    pExaScr->SavedPaintWindowBackground = pScreen->PaintWindowBackground;
-    pScreen->PaintWindowBackground = exaPaintWindow;
-
-    pExaScr->SavedPaintWindowBorder = pScreen->PaintWindowBorder;
-    pScreen->PaintWindowBorder = exaPaintWindow;
-
 #ifdef RENDER
     if (ps) {
         pExaScr->SavedComposite = ps->Composite;
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 232ec99..8500c5b 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1304,54 +1304,6 @@ fallback:
     return TRUE;
 }
 
-void
-exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    ExaScreenPriv (pWin->drawable.pScreen);
-
-    if (REGION_NIL(pRegion))
-	return;
-
-    if (!pExaScr->swappedOut) {
-	DDXPointRec zeros = { 0, 0 };
-
-        switch (what) {
-        case PW_BACKGROUND:
-            switch (pWin->backgroundState) {
-            case None:
-                return;
-            case ParentRelative:
-                do {
-                    pWin = pWin->parent;
-                } while (pWin->backgroundState == ParentRelative);
-                (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-                                                                 what);
-                return;
-            case BackgroundPixel:
-		exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel,
-				   FB_ALLONES, GXcopy);
-                return;
-            case BackgroundPixmap:
-                exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap,
-				   &zeros, FB_ALLONES, GXcopy);
-                return;
-            }
-            break;
-        case PW_BORDER:
-            if (pWin->borderIsPixel) {
-                exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel,
-				   FB_ALLONES, GXcopy);
-                return;
-            } else {
-                exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap,
-				   &zeros, FB_ALLONES, GXcopy);
-                return;
-            }
-            break;
-        }
-    }
-    ExaCheckPaintWindow (pWin, pRegion, what);
-}
 
 /**
  * Accelerates GetImage for solid ZPixmap downloads from framebuffer memory.
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 02371d7..9e4f8bc 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -101,10 +101,8 @@ typedef struct {
     CloseScreenProcPtr 		 SavedCloseScreen;
     GetImageProcPtr 		 SavedGetImage;
     GetSpansProcPtr 		 SavedGetSpans;
-    PaintWindowBackgroundProcPtr SavedPaintWindowBackground;
     CreatePixmapProcPtr 	 SavedCreatePixmap;
     DestroyPixmapProcPtr 	 SavedDestroyPixmap;
-    PaintWindowBorderProcPtr 	 SavedPaintWindowBorder;
     CopyWindowProcPtr 		 SavedCopyWindow;
     ChangeWindowAttributesProcPtr SavedChangeWindowAttributes;
     BitmapToRegionProcPtr        SavedBitmapToRegion;
@@ -272,9 +270,6 @@ ExaCheckGetSpans (DrawablePtr pDrawable,
 		 int nspans,
 		 char *pdstStart);
 
-void
-ExaCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
-
 CARD32
 exaGetPixmapFirstPixel (PixmapPtr pPixmap); 
 
@@ -297,9 +292,6 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
 		    DDXPointPtr pPatOrg, CARD32 planemask, CARD32 alu);
 
 void
-exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
-
-void
 exaShmPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, unsigned int format,
 	       int w, int h, int sx, int sy, int sw, int sh, int dx, int dy,
 	       char *data);
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index f4d453e..d487dc5 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -278,23 +278,6 @@ ExaCheckGetSpans (DrawablePtr pDrawable,
     exaFinishAccess (pDrawable, EXA_PREPARE_SRC);
 }
 
-/* XXX: Note the lack of a prepare on the tile, if the window has a tiled
- * background.  This function happens to only be called if pExaScr->swappedOut,
- * so we actually end up not having to do it since the tile won't be in fb.
- * That doesn't make this not dirty, though.
- */
-void
-ExaCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    EXA_FALLBACK(("from %p (%c)\n", pWin,
-		  exaDrawableLocation(&pWin->drawable)));
-    exaPrepareAccess (&pWin->drawable, EXA_PREPARE_DEST);
-    exaPrepareAccessWindow(pWin);
-    fbPaintWindow (pWin, pRegion, what);
-    exaFinishAccessWindow(pWin);
-    exaFinishAccess (&pWin->drawable, EXA_PREPARE_DEST);
-}
-
 void
 ExaCheckComposite (CARD8      op,
                    PicturePtr pSrc,
diff --git a/fb/fb.h b/fb/fb.h
index a924f49..379a00a 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -2094,10 +2094,6 @@ fbFillRegionTiled (DrawablePtr	pDrawable
 		   RegionPtr	pRegion,
 		   PixmapPtr	pTile);
 
-void
-fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
-
-
 pixman_image_t *image_from_pict (PicturePtr pict,
 				 Bool       has_clip);
 void free_pixman_pict (PicturePtr, pixman_image_t *);
diff --git a/fb/fboverlay.c b/fb/fboverlay.c
index 5d7481e..0d1eb88 100644
--- a/fb/fboverlay.c
+++ b/fb/fboverlay.c
@@ -278,16 +278,6 @@ fbOverlayWindowExposures (WindowPtr	pWin
     miWindowExposures(pWin, prgn, other_exposed);
 }
 
-void
-fbOverlayPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    if (what == PW_BORDER)
-	fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
-				    fbOverlayWindowLayer (pWin),
-				    pRegion);
-    fbPaintWindow (pWin, pRegion, what);
-}
-
 Bool
 fbOverlaySetupScreen(ScreenPtr	pScreen,
 		     pointer	pbits1,
@@ -441,7 +431,6 @@ fbOverlayFinishScreenInit(ScreenPtr	pScr
     pScreen->CreateWindow = fbOverlayCreateWindow;
     pScreen->WindowExposures = fbOverlayWindowExposures;
     pScreen->CopyWindow = fbOverlayCopyWindow;
-    pScreen->PaintWindowBorder = fbOverlayPaintWindow;
 #ifdef FB_24_32BIT
     if (bpp == 24 && imagebpp == 32)
     {
diff --git a/fb/fboverlay.h b/fb/fboverlay.h
index af0acb8..55135ea 100644
--- a/fb/fboverlay.h
+++ b/fb/fboverlay.h
@@ -93,10 +93,6 @@ fbOverlayWindowExposures (WindowPtr	pWin
 			  RegionPtr	prgn,
 			  RegionPtr	other_exposed);
 
-void
-fbOverlayPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
-
-
 Bool
 fbOverlaySetupScreen(ScreenPtr	pScreen,
 		     pointer	pbits1,
diff --git a/fb/fbpseudocolor.c b/fb/fbpseudocolor.c
index 271e981..411bde1 100644
--- a/fb/fbpseudocolor.c
+++ b/fb/fbpseudocolor.c
@@ -94,8 +94,6 @@ typedef struct {
     CreateScreenResourcesProcPtr CreateScreenResources;
     CreateWindowProcPtr		CreateWindow;
     CopyWindowProcPtr		CopyWindow;
-    PaintWindowProcPtr		PaintWindowBackground;
-    PaintWindowProcPtr		PaintWindowBorder;
     WindowExposuresProcPtr	WindowExposures;
     CreateGCProcPtr		CreateGC;
     CreateColormapProcPtr	CreateColormap;
@@ -795,70 +793,6 @@ xxWindowExposures (WindowPtr	pWin,
 }
 
 static void
-xxPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    xxScrPriv(pWin->drawable.pScreen);
-    RegionRec		rgni;
-
-    DBG("xxPaintWindow\n");
-
-    REGION_NULL (pWin->drawable.pScreen, &rgni);
-#if 0
-    REGION_UNION (pWin->drawable.pScreen, &rgni, &rgni, &pWin->borderClip);
-    REGION_INTERSECT(pWin->drawable.pScreen, &rgni, &rgni, pRegion);
-#else
-    REGION_UNION (pWin->drawable.pScreen, &rgni, &rgni, pRegion);
-#endif
-    switch (what) {
-    case PW_BORDER:
-	REGION_SUBTRACT (pWin->drawable.pScreen, &rgni, &rgni, &pWin->winSize);
-	if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) {
-	    DBG("PaintWindowBorder\n");
-	    REGION_UNION (pWin->drawable.pScreen, &pScrPriv->region,
-			  &pScrPriv->region, &rgni);
-	} else {
-	    DBG("PaintWindowBorder NoOverlay\n");
-	    REGION_SUBTRACT (pWin->drawable.pScreen, &pScrPriv->region,
-			     &pScrPriv->region, &rgni);	
-	}
-	unwrap (pScrPriv, pWin->drawable.pScreen, PaintWindowBorder);
-	pWin->drawable.pScreen->PaintWindowBorder (pWin, pRegion, what);
-	wrap(pScrPriv, pWin->drawable.pScreen, PaintWindowBorder,
-	     xxPaintWindow);	
-	break;
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    break;
-	default:
-	    REGION_INTERSECT (pWin->drawable.pScreen, &rgni,
-			      &rgni,&pWin->winSize);
-	    if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) {
-		DBG("PaintWindowBackground\n");
-		REGION_UNION (pWin->drawable.pScreen, &pScrPriv->region,
-			      &pScrPriv->region, &rgni);
-	    } else {
-		DBG("PaintWindowBackground NoOverlay\n");
-		REGION_SUBTRACT (pWin->drawable.pScreen, &pScrPriv->region,
-				 &pScrPriv->region, &rgni);	
-	    }
-	    break;
-	}
-	
-	unwrap (pScrPriv, pWin->drawable.pScreen, PaintWindowBackground);
-	pWin->drawable.pScreen->PaintWindowBackground (pWin, pRegion, what);
-	wrap(pScrPriv, pWin->drawable.pScreen, PaintWindowBackground,
-	     xxPaintWindow);
-	break;
-    }
-    PRINT_RECTS(rgni);
-    PRINT_RECTS(pScrPriv->region);
-#if 1
-    REGION_UNINIT(pWin->drawable.pScreen,&rgni);
-#endif
-}
-
-static void
 xxCopyPseudocolorRegion(ScreenPtr pScreen, RegionPtr pReg,
 			xxCmapPrivPtr pCmapPriv)
 {
@@ -1171,8 +1105,6 @@ xxSetup(ScreenPtr pScreen, int myDepth, 
     wrap (pScrPriv, pScreen, CreateScreenResources, xxCreateScreenResources);
     wrap (pScrPriv, pScreen, CreateWindow, xxCreateWindow);
     wrap (pScrPriv, pScreen, CopyWindow, xxCopyWindow);
-    wrap (pScrPriv, pScreen, PaintWindowBorder, xxPaintWindow);
-    wrap (pScrPriv, pScreen, PaintWindowBackground, xxPaintWindow);
 #if 0 /* can we leave this out even with backing store enabled ? */
     wrap (pScrPriv, pScreen, WindowExposures, xxWindowExposures);
 #endif
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 661268c..41bef47 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -122,8 +122,6 @@ fbSetupScreen(ScreenPtr	pScreen, 
     pScreen->ChangeWindowAttributes = fbChangeWindowAttributes;
     pScreen->RealizeWindow = fbMapWindow;
     pScreen->UnrealizeWindow = fbUnmapWindow;
-    pScreen->PaintWindowBackground = fbPaintWindow;
-    pScreen->PaintWindowBorder = fbPaintWindow;
     pScreen->CopyWindow = fbCopyWindow;
     pScreen->CreatePixmap = fbCreatePixmap;
     pScreen->DestroyPixmap = fbDestroyPixmap;
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index 144f083..602b7e0 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -315,58 +315,3 @@ fbFillRegionTiled (DrawablePtr	pDrawable
     fbFinishAccess (&pTile->drawable);
     fbFinishAccess (pDrawable);
 }
-
-void
-fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    WindowPtr	pBgWin;
-    
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    break;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    break;
-	case BackgroundPixmap:
-	    fbFillRegionTiled (&pWin->drawable,
-			       pRegion,
-			       pWin->background.pixmap);
-	    break;
-	case BackgroundPixel:
-	    fbFillRegionSolid (&pWin->drawable,
-			       pRegion,
-			       0,
-			       fbReplicatePixel (pWin->background.pixel,
-						 pWin->drawable.bitsPerPixel));
-	    break;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    fbFillRegionSolid (&pWin->drawable,
-			       pRegion,
-			       0,
-			       fbReplicatePixel (pWin->border.pixel,
-						 pWin->drawable.bitsPerPixel));
-	}
-	else
-	{
-	    for (pBgWin = pWin;
-		 pBgWin->backgroundState == ParentRelative;
-		 pBgWin = pBgWin->parent);
-
-	    fbFillRegionTiled (&pBgWin->drawable,
-			       pRegion,
-			       pWin->border.pixmap);
-	}
-	break;
-    }
-    fbValidateDrawable (&pWin->drawable);
-}
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index 5ea9092..93ce41b 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -119,14 +119,12 @@
 #define fbOverlayGeneration wfbOverlayGeneration
 #define fbOverlayGetScreenPrivateIndex wfbOverlayGetScreenPrivateIndex
 #define fbOverlayPaintKey wfbOverlayPaintKey
-#define fbOverlayPaintWindow wfbOverlayPaintWindow
 #define fbOverlayScreenPrivateIndex wfbOverlayScreenPrivateIndex
 #define fbOverlaySetupScreen wfbOverlaySetupScreen
 #define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion
 #define fbOverlayWindowExposures wfbOverlayWindowExposures
 #define fbOverlayWindowLayer wfbOverlayWindowLayer
 #define fbPadPixmap wfbPadPixmap
-#define fbPaintWindow wfbPaintWindow
 #define fbPictureInit wfbPictureInit
 #define fbPixmapToRegion wfbPixmapToRegion
 #define fbPolyArc wfbPolyArc
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 038b21e..b309b7b 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -217,7 +217,7 @@ static void QuartzUpdateScreens(void)
     pRoot = WindowTable[pScreen->myNum];
     AppleWMSetScreenOrigin(pRoot);
     pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
-    pScreen->PaintWindowBackground(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
+    miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
 //    QuartzIgnoreNextWarpCursor();
     DefineInitialRootWindow(pRoot);
 
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index 67a0737..034cbac 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -306,9 +306,6 @@ static Bool
 xprSetupScreen(int index, ScreenPtr pScreen)
 {
     // Add alpha protecting replacements for fb screen functions
-    pScreen->PaintWindowBackground = SafeAlphaPaintWindow;
-    pScreen->PaintWindowBorder = SafeAlphaPaintWindow;
-
 #ifdef RENDER
     {
         PictureScreenPtr ps = GetPictureScreen(pScreen);
diff --git a/hw/dmx/dmx.h b/hw/dmx/dmx.h
index 37f42a7..4fef915 100644
--- a/hw/dmx/dmx.h
+++ b/hw/dmx/dmx.h
@@ -209,8 +209,6 @@ typedef struct _DMXScreenInfo {
     UnrealizeWindowProcPtr         UnrealizeWindow;
     RestackWindowProcPtr           RestackWindow;
     WindowExposuresProcPtr         WindowExposures;
-    PaintWindowBackgroundProcPtr   PaintWindowBackground;
-    PaintWindowBorderProcPtr       PaintWindowBorder;
     CopyWindowProcPtr              CopyWindow;
 
     ResizeWindowProcPtr            ResizeWindow;
diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c
index 8ae448a..a78e3ae 100644
--- a/hw/dmx/dmxscrinit.c
+++ b/hw/dmx/dmxscrinit.c
@@ -346,9 +346,6 @@ Bool dmxScreenInit(int idx, ScreenPtr pS
 	DMX_WRAP(UnrealizeWindow, dmxUnrealizeWindow, dmxScreen, pScreen);
 	DMX_WRAP(RestackWindow, dmxRestackWindow, dmxScreen, pScreen);
 	DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
-	DMX_WRAP(PaintWindowBackground, dmxPaintWindowBackground, dmxScreen,
-		 pScreen);
-	DMX_WRAP(PaintWindowBorder, dmxPaintWindowBorder, dmxScreen, pScreen);
 	DMX_WRAP(CopyWindow, dmxCopyWindow, dmxScreen, pScreen);
 
 	DMX_WRAP(ResizeWindow, dmxResizeWindow, dmxScreen, pScreen);
@@ -485,8 +482,6 @@ Bool dmxCloseScreen(int idx, ScreenPtr p
 	DMX_UNWRAP(UnrealizeWindow, dmxScreen, pScreen);
 	DMX_UNWRAP(RestackWindow, dmxScreen, pScreen);
 	DMX_UNWRAP(WindowExposures, dmxScreen, pScreen);
-	DMX_UNWRAP(PaintWindowBackground, dmxScreen, pScreen);
-	DMX_UNWRAP(PaintWindowBorder, dmxScreen, pScreen);
 	DMX_UNWRAP(CopyWindow, dmxScreen, pScreen);
 
 	DMX_UNWRAP(ResizeWindow, dmxScreen, pScreen);
diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c
index b66f2a3..7ccecfb 100644
--- a/hw/dmx/dmxwindow.c
+++ b/hw/dmx/dmxwindow.c
@@ -796,57 +796,6 @@ void dmxWindowExposures(WindowPtr pWindo
     DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
 }
 
-/** Paint background of \a pWindow in \a pRegion. */
-void dmxPaintWindowBackground(WindowPtr pWindow, RegionPtr pRegion, int what)
-{
-    ScreenPtr      pScreen = pWindow->drawable.pScreen;
-    DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
-    dmxWinPrivPtr  pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-    BoxPtr         pBox;
-    int            nBox;
-
-    DMX_UNWRAP(PaintWindowBackground, dmxScreen, pScreen);
-#if 0
-    if (pScreen->PaintWindowBackground)
-	pScreen->PaintWindowBackground(pWindow, pRegion, what);
-#endif
-
-    if (pWinPriv->window) {
-	/* Paint window background on back-end server */
-	pBox = REGION_RECTS(pRegion);
-	nBox = REGION_NUM_RECTS(pRegion);
-	while (nBox--) {
-	    XClearArea(dmxScreen->beDisplay, pWinPriv->window,
-		       pBox->x1 - pWindow->drawable.x,
-		       pBox->y1 - pWindow->drawable.y,
-		       pBox->x2 - pBox->x1,
-		       pBox->y2 - pBox->y1,
-		       False);
-	    pBox++;
-	}
-	dmxSync(dmxScreen, False);
-    }
-
-    DMX_WRAP(PaintWindowBackground, dmxPaintWindowBackground, dmxScreen, pScreen);
-}
-
-/** Paint window border for \a pWindow in \a pRegion. */
-void dmxPaintWindowBorder(WindowPtr pWindow, RegionPtr pRegion, int what)
-{
-    ScreenPtr      pScreen = pWindow->drawable.pScreen;
-    DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
-
-    DMX_UNWRAP(PaintWindowBorder, dmxScreen, pScreen);
-#if 0
-    if (pScreen->PaintWindowBorder)
-	pScreen->PaintWindowBorder(pWindow, pRegion, what);
-#endif
-
-    /* Paint window border on back-end server */
-
-    DMX_WRAP(PaintWindowBorder, dmxPaintWindowBorder, dmxScreen, pScreen);
-}
-
 /** Move \a pWindow on the back-end server.  Determine whether or not it
  *  is on or offscreen, and realize it if it is newly on screen and the
  *  lazy window creation optimization is enabled. */
diff --git a/hw/dmx/dmxwindow.h b/hw/dmx/dmxwindow.h
index f976c79..79f85ac 100644
--- a/hw/dmx/dmxwindow.h
+++ b/hw/dmx/dmxwindow.h
@@ -81,10 +81,6 @@ extern Bool dmxUnrealizeWindow(WindowPtr
 extern void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib);
 extern void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn,
 			       RegionPtr other_exposed);
-extern void dmxPaintWindowBackground(WindowPtr pWindow, RegionPtr pRegion,
-				     int what);
-extern void dmxPaintWindowBorder(WindowPtr pWindow, RegionPtr pRegion,
-				 int what);
 extern void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg,
 			  RegionPtr prgnSrc);
 
diff --git a/hw/kdrive/igs/igsdraw.c b/hw/kdrive/igs/igsdraw.c
index d2ae098..e1ff2be 100644
--- a/hw/kdrive/igs/igsdraw.c
+++ b/hw/kdrive/igs/igsdraw.c
@@ -1367,74 +1367,6 @@ igsCopyWindow(WindowPtr pWin, DDXPointRe
     REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
 }
 
-void
-igsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    KdScreenPriv(pWin->drawable.pScreen);
-    PixmapPtr	pTile;
-
-    if (!REGION_NUM_RECTS(pRegion)) 
-	return;
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixmap:
-	    pTile = pWin->background.pixmap;
-	    if (igsPatternDimOk (pTile->drawable.width) &&
-		igsPatternDimOk (pTile->drawable.height))
-	    {
-		igsFillBoxTiled ((DrawablePtr)pWin,
-				 (int)REGION_NUM_RECTS(pRegion),
-				 REGION_RECTS(pRegion),
-				 pTile, 
-				 pWin->drawable.x, pWin->drawable.y, GXcopy);
-		return;
-	    }
-	    break;
-	case BackgroundPixel:
-	    igsFillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel, GXcopy, ~0);
-	    return;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    igsFillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel, GXcopy, ~0);
-	    return;
-	}
-	else
-	{
-	    pTile = pWin->border.pixmap;
-	    if (igsPatternDimOk (pTile->drawable.width) &&
-		igsPatternDimOk (pTile->drawable.height))
-	    {
-		igsFillBoxTiled ((DrawablePtr)pWin,
-				 (int)REGION_NUM_RECTS(pRegion),
-				 REGION_RECTS(pRegion),
-				 pTile, 
-				 pWin->drawable.x, pWin->drawable.y, GXcopy);
-		return;
-	    }
-	}
-	break;
-    }
-    KdCheckPaintWindow (pWin, pRegion, what);
-}
 
 Bool
 igsDrawInit (ScreenPtr pScreen)
@@ -1453,9 +1385,7 @@ igsDrawInit (ScreenPtr pScreen)
      */
     pScreen->CreateGC = igsCreateGC;
     pScreen->CopyWindow = igsCopyWindow;
-    pScreen->PaintWindowBackground = igsPaintWindow;
-    pScreen->PaintWindowBorder = igsPaintWindow;
-    
+
     /*
      * Initialize patterns
      */
diff --git a/hw/kdrive/savage/s3.h b/hw/kdrive/savage/s3.h
index 628abc8..d8db0eb 100644
--- a/hw/kdrive/savage/s3.h
+++ b/hw/kdrive/savage/s3.h
@@ -470,7 +470,6 @@ void	s3CursorDisable (ScreenPtr pScreen)
 void	s3CursorFini (ScreenPtr pScreen);
 void	s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
 
-void	s3DumbPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
 void	s3DumbCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
     
 Bool	s3DrawInit (ScreenPtr pScreen);
diff --git a/hw/kdrive/savage/s3draw.c b/hw/kdrive/savage/s3draw.c
index 258dbcf..7b6543b 100644
--- a/hw/kdrive/savage/s3draw.c
+++ b/hw/kdrive/savage/s3draw.c
@@ -2262,71 +2262,6 @@ s3PaintKey (DrawablePtr	pDrawable,
 #endif
 
 void
-s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    SetupS3(pWin->drawable.pScreen);
-    s3ScreenInfo(pScreenPriv);
-    s3PatternPtr    pPattern;
-
-    DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "s3PaintWindow 0x%x extents %d %d %d %d n %d",
-		 pWin->drawable.id,
-		 pRegion->extents.x1, pRegion->extents.y1,
-		 pRegion->extents.x2, pRegion->extents.y2,
-		 REGION_NUM_RECTS(pRegion)));
-    if (!REGION_NUM_RECTS(pRegion)) 
-	return;
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixmap:
-	    pPattern = s3GetWindowPrivate(pWin);
-	    if (pPattern)
-	    {
-		s3FillBoxPattern ((DrawablePtr)pWin,
-				  (int)REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion),
-				  GXcopy, ~0, pPattern);
-		return;
-	    }
-	    break;
-	case BackgroundPixel:
-	    s3FillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel, GXcopy, ~0);
-	    return;
-    	}
-    	break;
-    case PW_BORDER:
-#ifndef S3_TRIO
-	if (s3s->fbmap[1] >= 0)
-	    fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
-					fbOverlayWindowLayer (pWin),
-					pRegion);
-#endif
-	if (pWin->borderIsPixel)
-	{
-	    s3FillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel, GXcopy, ~0);
-	    return;
-	}
-	break;
-    }
-    KdCheckPaintWindow (pWin, pRegion, what);
-}
-
-void
 s3CopyWindowProc (DrawablePtr pSrcDrawable,
 		  DrawablePtr pDstDrawable,
 		  GCPtr       pGC,
@@ -3006,55 +2941,6 @@ s3_24CreateWindow(WindowPtr pWin)
     return fbCreateWindow (pWin);
 }
 
-void
-s3_24PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    SetupS3(pWin->drawable.pScreen);
-    s3PatternPtr    pPattern;
-
-    DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "s3PaintWindow 0x%x extents %d %d %d %d n %d",
-		 pWin->drawable.id,
-		 pRegion->extents.x1, pRegion->extents.y1,
-		 pRegion->extents.x2, pRegion->extents.y2,
-		 REGION_NUM_RECTS(pRegion)));
-    if (!REGION_NUM_RECTS(pRegion)) 
-	return;
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixel:
-	    if (ok24(pWin->background.pixel))
-	    {
-		s3_24FillBoxSolid((DrawablePtr)pWin,
-				  (int)REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion),
-				  pWin->background.pixel, GXcopy, ~0);
-		return;
-	    }
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel && ok24(pWin->border.pixel))
-	{
-	    s3_24FillBoxSolid((DrawablePtr)pWin,
-			      (int)REGION_NUM_RECTS(pRegion),
-			      REGION_RECTS(pRegion),
-			      pWin->border.pixel, GXcopy, ~0);
-	    return;
-	}
-	break;
-    }
-    KdCheckPaintWindow (pWin, pRegion, what);
-}
 
 Bool
 s3DrawInit (ScreenPtr pScreen)
@@ -3089,8 +2975,6 @@ s3DrawInit (ScreenPtr pScreen)
     {
 	pScreen->CreateGC = s3_24CreateGC;
 	pScreen->CreateWindow = s3_24CreateWindow;
-	pScreen->PaintWindowBackground = s3_24PaintWindow;
-	pScreen->PaintWindowBorder = s3_24PaintWindow;
 	pScreen->CopyWindow = s3CopyWindow;
     }
     else
@@ -3109,8 +2993,6 @@ s3DrawInit (ScreenPtr pScreen)
 	pScreen->CreateWindow = s3CreateWindow;
 	pScreen->ChangeWindowAttributes = s3ChangeWindowAttributes;
 	pScreen->DestroyWindow = s3DestroyWindow;
-	pScreen->PaintWindowBackground = s3PaintWindow;
-	pScreen->PaintWindowBorder = s3PaintWindow;
 #ifndef S3_TRIO
 	if (pScreenPriv->screen->fb[1].depth)
 	{
diff --git a/hw/kdrive/sis530/sisdraw.c b/hw/kdrive/sis530/sisdraw.c
index fd80fa7..f2b39a4 100644
--- a/hw/kdrive/sis530/sisdraw.c
+++ b/hw/kdrive/sis530/sisdraw.c
@@ -1537,75 +1537,6 @@ sisCopyWindow(WindowPtr pWin, DDXPointRe
     REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
 }
 
-void
-sisPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    KdScreenPriv(pWin->drawable.pScreen);
-    PixmapPtr	pTile;
-
-    if (!REGION_NUM_RECTS(pRegion)) 
-	return;
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixmap:
-	    pTile = pWin->background.pixmap;
-	    if (sisPatternDimOk (pTile->drawable.width) &&
-		sisPatternDimOk (pTile->drawable.height))
-	    {
-		sisFillBoxTiled ((DrawablePtr)pWin,
-				 (int)REGION_NUM_RECTS(pRegion),
-				 REGION_RECTS(pRegion),
-				 pTile, 
-				 pWin->drawable.x, pWin->drawable.y, GXcopy);
-		return;
-	    }
-	    break;
-	case BackgroundPixel:
-	    sisFillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel, GXcopy);
-	    return;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    sisFillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel, GXcopy);
-	    return;
-	}
-	else
-	{
-	    pTile = pWin->border.pixmap;
-	    if (sisPatternDimOk (pTile->drawable.width) &&
-		sisPatternDimOk (pTile->drawable.height))
-	    {
-		sisFillBoxTiled ((DrawablePtr)pWin,
-				 (int)REGION_NUM_RECTS(pRegion),
-				 REGION_RECTS(pRegion),
-				 pTile, 
-				 pWin->drawable.x, pWin->drawable.y, GXcopy);
-		return;
-	    }
-	}
-	break;
-    }
-    KdCheckPaintWindow (pWin, pRegion, what);
-}
-
 Bool
 sisDrawInit (ScreenPtr pScreen)
 {
@@ -1621,9 +1552,7 @@ sisDrawInit (ScreenPtr pScreen)
      */
     pScreen->CreateGC = sisCreateGC;
     pScreen->CopyWindow = sisCopyWindow;
-    pScreen->PaintWindowBackground = sisPaintWindow;
-    pScreen->PaintWindowBorder = sisPaintWindow;
-    
+
     return TRUE;
 }
 
diff --git a/hw/kdrive/src/kaa.c b/hw/kdrive/src/kaa.c
index c9805dd..7ee6c0b 100644
--- a/hw/kdrive/src/kaa.c
+++ b/hw/kdrive/src/kaa.c
@@ -1009,52 +1009,6 @@ kaaFillRegionTiled (DrawablePtr pDrawabl
 }
 #endif
 
-static void
-kaaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-
-    if (!REGION_NUM_RECTS(pRegion)) 
-	return;
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixel:
-	    kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel);
-	    return;
-#if 0	    
-	case BackgroundPixmap:
-	    kaaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap);
-	    return;
-#endif
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel);
-	    return;
-	}
-#if 0
-	else
-	{
-	    kaaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap);
-	    return;
-	}
-#endif
-	break;
-    }
-    KdCheckPaintWindow (pWin, pRegion, what);
-}
-
 Bool
 kaaDrawInit (ScreenPtr		pScreen,
 	     KaaScreenInfoPtr	pScreenInfo)
@@ -1091,8 +1045,6 @@ kaaDrawInit (ScreenPtr		pScreen,
      */
     pScreen->CreateGC = kaaCreateGC;
     pScreen->CopyWindow = kaaCopyWindow;
-    pScreen->PaintWindowBackground = kaaPaintWindow;
-    pScreen->PaintWindowBorder = kaaPaintWindow;
 #ifdef RENDER
     if (ps) {
 	ps->Composite = kaaComposite;
diff --git a/hw/kdrive/src/kasync.c b/hw/kdrive/src/kasync.c
index 5190963..5388f21 100644
--- a/hw/kdrive/src/kasync.c
+++ b/hw/kdrive/src/kasync.c
@@ -224,14 +224,6 @@ KdCheckGetSpans (DrawablePtr pDrawable,
 }
 
 void
-KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    kaaWaitSync (pWin->drawable.pScreen);
-    kaaDrawableDirty ((DrawablePtr)pWin);
-    fbPaintWindow (pWin, pRegion, what);
-}
-
-void
 KdCheckCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 {
     kaaWaitSync (pWin->drawable.pScreen);
@@ -265,8 +257,6 @@ KdScreenInitAsync (ScreenPtr pScreen)
 {
     pScreen->GetImage = KdCheckGetImage;
     pScreen->GetSpans = KdCheckGetSpans;
-    pScreen->PaintWindowBackground = KdCheckPaintWindow;
-    pScreen->PaintWindowBorder = KdCheckPaintWindow;
     pScreen->CopyWindow = KdCheckCopyWindow;
 #ifdef RENDER
     KdPictureInitAsync (pScreen);
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 2da008d..2fde66c 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -612,9 +612,6 @@ KdCheckGetSpans (DrawablePtr pDrawable,
 		 char *pdstStart);
 
 void
-KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
-
-void
 KdCheckCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
 
 void
diff --git a/hw/xfree86/rac/xf86RAC.c b/hw/xfree86/rac/xf86RAC.c
index 8492cdb..9d2812c 100644
--- a/hw/xfree86/rac/xf86RAC.c
+++ b/hw/xfree86/rac/xf86RAC.c
@@ -98,8 +98,6 @@ typedef struct _RACScreen {
     GetImageProcPtr 		GetImage;
     GetSpansProcPtr 		GetSpans;
     SourceValidateProcPtr 	SourceValidate;
-    PaintWindowBackgroundProcPtr PaintWindowBackground;
-    PaintWindowBorderProcPtr 	PaintWindowBorder;
     CopyWindowProcPtr 		CopyWindow;
     ClearToBackgroundProcPtr 	ClearToBackground;
     CreatePixmapProcPtr         CreatePixmap;
@@ -139,8 +137,6 @@ static void RACGetSpans (DrawablePtr pDr
 			 int *pwidth, int nspans, char	*pdstStart);
 static void RACSourceValidate (DrawablePtr	pDrawable,
 			       int x, int y, int width, int height );
-static void RACPaintWindowBackground(WindowPtr pWin, RegionPtr prgn, int what);
-static void RACPaintWindowBorder(WindowPtr pWin, RegionPtr prgn, int what);
 static void RACCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
 			  RegionPtr prgnSrc );
 static void RACClearToBackground (WindowPtr pWin, int x, int y,
@@ -296,8 +292,6 @@ xf86RACInit(ScreenPtr pScreen, unsigned 
     WRAP_SCREEN_COND(GetImage, RACGetImage, RAC_FB);
     WRAP_SCREEN_COND(GetSpans, RACGetSpans, RAC_FB);
     WRAP_SCREEN_COND(SourceValidate, RACSourceValidate, RAC_FB);
-    WRAP_SCREEN_COND(PaintWindowBackground, RACPaintWindowBackground, RAC_FB);
-    WRAP_SCREEN_COND(PaintWindowBorder, RACPaintWindowBorder, RAC_FB);
     WRAP_SCREEN_COND(CopyWindow, RACCopyWindow, RAC_FB);
     WRAP_SCREEN_COND(ClearToBackground, RACClearToBackground, RAC_FB);
     WRAP_SCREEN_COND(CreatePixmap, RACCreatePixmap, RAC_FB);
@@ -341,8 +335,6 @@ RACCloseScreen (int i, ScreenPtr pScreen
     UNWRAP_SCREEN(GetImage);
     UNWRAP_SCREEN(GetSpans);
     UNWRAP_SCREEN(SourceValidate);
-    UNWRAP_SCREEN(PaintWindowBackground);
-    UNWRAP_SCREEN(PaintWindowBorder);
     UNWRAP_SCREEN(CopyWindow);
     UNWRAP_SCREEN(ClearToBackground);
     UNWRAP_SCREEN(SaveScreen);
@@ -427,38 +419,6 @@ RACSourceValidate (
 }
 
 static void
-RACPaintWindowBackground(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-  )
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    DPRINT_S("RACPaintWindowBackground",pScreen->myNum);
-    SCREEN_PROLOG (PaintWindowBackground);
-    ENABLE;
-    (*pScreen->PaintWindowBackground) (pWin, prgn, what);
-    SCREEN_EPILOG (PaintWindowBackground, RACPaintWindowBackground);
-}
-
-static void
-RACPaintWindowBorder(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    DPRINT_S("RACPaintWindowBorder",pScreen->myNum);
-    SCREEN_PROLOG (PaintWindowBorder);
-    ENABLE;
-    (*pScreen->PaintWindowBorder) (pWin, prgn, what);
-    SCREEN_EPILOG (PaintWindowBorder, RACPaintWindowBorder);
-}
-
-static void
 RACCopyWindow(
     WindowPtr pWin,
     DDXPointRec ptOldOrg,
diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c
index c1b6ed1..3511a63 100644
--- a/hw/xfree86/shadowfb/shadow.c
+++ b/hw/xfree86/shadowfb/shadow.c
@@ -35,11 +35,6 @@
 #define MAX(a,b) (((a)>(b))?(a):(b))
 
 static Bool ShadowCloseScreen (int i, ScreenPtr pScreen);
-static void ShadowPaintWindow (
-    WindowPtr pWin,
-    RegionPtr prgn,
-    int what 
-);
 static void ShadowCopyWindow(
     WindowPtr pWin,
     DDXPointRec ptOldOrg,
@@ -82,8 +77,6 @@ typedef struct {
   RefreshAreaFuncPtr			preRefresh;
   RefreshAreaFuncPtr                    postRefresh;
   CloseScreenProcPtr			CloseScreen;
-  PaintWindowBackgroundProcPtr		PaintWindowBackground;
-  PaintWindowBorderProcPtr		PaintWindowBorder;
   CopyWindowProcPtr			CopyWindow;
   CreateGCProcPtr			CreateGC;
   ModifyPixmapHeaderProcPtr		ModifyPixmapHeader;
@@ -200,8 +193,6 @@ ShadowFBInit2 (
     pPriv->vtSema = TRUE;
 
     pPriv->CloseScreen = pScreen->CloseScreen;
-    pPriv->PaintWindowBackground = pScreen->PaintWindowBackground;
-    pPriv->PaintWindowBorder = pScreen->PaintWindowBorder;
     pPriv->CopyWindow = pScreen->CopyWindow;
     pPriv->CreateGC = pScreen->CreateGC;
     pPriv->ModifyPixmapHeader = pScreen->ModifyPixmapHeader;
@@ -210,8 +201,6 @@ ShadowFBInit2 (
     pPriv->LeaveVT = pScrn->LeaveVT;
 
     pScreen->CloseScreen = ShadowCloseScreen;
-    pScreen->PaintWindowBackground = ShadowPaintWindow;
-    pScreen->PaintWindowBorder = ShadowPaintWindow;
     pScreen->CopyWindow = ShadowCopyWindow;
     pScreen->CreateGC = ShadowCreateGC;
     pScreen->ModifyPixmapHeader = ShadowModifyPixmapHeader;
@@ -276,8 +265,6 @@ ShadowCloseScreen (int i, ScreenPtr pScr
 #endif /* RENDER */
 
     pScreen->CloseScreen = pPriv->CloseScreen;
-    pScreen->PaintWindowBackground = pPriv->PaintWindowBackground;
-    pScreen->PaintWindowBorder = pPriv->PaintWindowBorder;
     pScreen->CopyWindow = pPriv->CopyWindow;
     pScreen->CreateGC = pPriv->CreateGC;
     pScreen->ModifyPixmapHeader = pPriv->ModifyPixmapHeader;
@@ -296,35 +283,6 @@ ShadowCloseScreen (int i, ScreenPtr pScr
     return (*pScreen->CloseScreen) (i, pScreen);
 }
 
-static void
-ShadowPaintWindow(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-){
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
-    int num = 0;
-
-    if(pPriv->vtSema && (num = REGION_NUM_RECTS(prgn)))
-        if(pPriv->preRefresh)
-            (*pPriv->preRefresh)(pPriv->pScrn, num, REGION_RECTS(prgn));
-
-    if(what == PW_BACKGROUND) {
-	pScreen->PaintWindowBackground = pPriv->PaintWindowBackground;
-	(*pScreen->PaintWindowBackground) (pWin, prgn, what);
-	pScreen->PaintWindowBackground = ShadowPaintWindow;
-    } else {
-	pScreen->PaintWindowBorder = pPriv->PaintWindowBorder;
-	(*pScreen->PaintWindowBorder) (pWin, prgn, what);
-	pScreen->PaintWindowBorder = ShadowPaintWindow;
-    }
-
-    if(num && pPriv->postRefresh)
-        (*pPriv->postRefresh)(pPriv->pScrn, num, REGION_RECTS(prgn));    
-}
-
-
 static void 
 ShadowCopyWindow(
    WindowPtr pWin,
diff --git a/hw/xfree86/xaa/Makefile.am b/hw/xfree86/xaa/Makefile.am
index 6ed8303..58c8e88 100644
--- a/hw/xfree86/xaa/Makefile.am
+++ b/hw/xfree86/xaa/Makefile.am
@@ -16,7 +16,7 @@ libxaa_la_SOURCES = xaaInit.c xaaGC.c xa
                    xaaBitBlt.c xaaCpyArea.c xaaGCmisc.c xaaCpyWin.c \
                    xaaCpyPlane.c xaaFillRect.c xaaTEText.c xaaNonTEText.c \
                    xaaPCache.c xaaSpans.c xaaROP.c xaaImage.c xaaWrapper.c \
-                   xaaPaintWin.c xaaRect.c xaaLineMisc.c xaaBitOrder.c \
+                   xaaRect.c xaaLineMisc.c xaaBitOrder.c \
                    xaaFillPoly.c xaaWideLine.c xaaTables.c xaaFillArc.c \
                    xaaLine.c xaaDashLine.c xaaOverlay.c xaaOffscreen.c \
                    xaaOverlayDF.c xaaStateChange.c xaaPict.c $(POLYSEG) \
diff --git a/hw/xfree86/xaa/xaa.h b/hw/xfree86/xaa/xaa.h
index c8d0467..1dc7ed2 100644
--- a/hw/xfree86/xaa/xaa.h
+++ b/hw/xfree86/xaa/xaa.h
@@ -1238,8 +1238,6 @@ typedef struct _XAAInfoRec {
 
    GetImageProcPtr GetImage;
    GetSpansProcPtr GetSpans;
-   PaintWindowBackgroundProcPtr PaintWindowBackground;
-   PaintWindowBorderProcPtr PaintWindowBorder;
    CopyWindowProcPtr CopyWindow;
    BackingStoreSaveAreasProcPtr SaveAreas;
    BackingStoreRestoreAreasProcPtr RestoreAreas;
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 93f6995..4222425 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -147,10 +147,6 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr
 	infoRec->GetImage = XAAGetImage;
     if(!infoRec->GetSpans)
 	infoRec->GetSpans = XAAGetSpans;
-    if(!infoRec->PaintWindowBackground)
-	infoRec->PaintWindowBackground = XAAPaintWindow;
-    if(!infoRec->PaintWindowBorder)
-	infoRec->PaintWindowBorder = XAAPaintWindow;
     if(!infoRec->CopyWindow)
 	infoRec->CopyWindow = XAACopyWindow;
 
@@ -162,10 +158,6 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr
     pScreen->GetImage = infoRec->GetImage;
     pScreenPriv->GetSpans = pScreen->GetSpans;
     pScreen->GetSpans = infoRec->GetSpans;
-    pScreenPriv->PaintWindowBackground = pScreen->PaintWindowBackground;
-    pScreen->PaintWindowBackground = infoRec->PaintWindowBackground;
-    pScreenPriv->PaintWindowBorder = pScreen->PaintWindowBorder;
-    pScreen->PaintWindowBorder = infoRec->PaintWindowBorder;
     pScreenPriv->CopyWindow = pScreen->CopyWindow;
     pScreen->CopyWindow = infoRec->CopyWindow;
     pScreenPriv->CreatePixmap = pScreen->CreatePixmap;
@@ -236,8 +228,6 @@ XAACloseScreen (int i, ScreenPtr pScreen
     pScreen->CloseScreen = pScreenPriv->CloseScreen;
     pScreen->GetImage = pScreenPriv->GetImage;
     pScreen->GetSpans = pScreenPriv->GetSpans;
-    pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground;
-    pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder;
     pScreen->CopyWindow = pScreenPriv->CopyWindow;
     pScreen->WindowExposures = pScreenPriv->WindowExposures;
     pScreen->CreatePixmap = pScreenPriv->CreatePixmap;
diff --git a/hw/xfree86/xaa/xaaOverlay.c b/hw/xfree86/xaa/xaaOverlay.c
index 0164590..86b30ff 100644
--- a/hw/xfree86/xaa/xaaOverlay.c
+++ b/hw/xfree86/xaa/xaaOverlay.c
@@ -93,183 +93,6 @@ XAACopyWindow8_32(
 	REGION_DESTROY(pScreen, borderClip);
 }
 
-
-
-
-static void
-XAAPaintWindow8_32(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-){
-    ScreenPtr  pScreen = pWin->drawable.pScreen;
-    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
-    int nBox = REGION_NUM_RECTS(prgn);
-    BoxPtr pBox = REGION_RECTS(prgn);
-    PixmapPtr pPix = NULL;
-    int depth = pWin->drawable.depth;
-    int fg = 0, pm;
-
-    if(!infoRec->pScrn->vtSema) goto BAILOUT;	
-
-    switch (what) {
-    case PW_BACKGROUND:
-	switch(pWin->backgroundState) {
-	case None: return;
-	case ParentRelative:
-	    do { pWin = pWin->parent; }
-	    while(pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, what);
-	    return;
-	case BackgroundPixel:
-	    fg = pWin->background.pixel;
-	    break;
-	case BackgroundPixmap:
-	    pPix = pWin->background.pixmap;
-	    break;
-	}
-	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel) 
-	    fg = pWin->border.pixel;
-	else 	/* pixmap */ 
-	    pPix = pWin->border.pixmap;
-	break;
-    default: return;
-    }
-
-    if(depth == 8) {
-	pm = 0xff000000;
-	fg <<= 24;
-    } else
-	pm = 0x00ffffff;
-
-    if(!pPix) {	
-        if(infoRec->FillSolidRects &&
-           !(infoRec->FillSolidRectsFlags & NO_PLANEMASK) &&
-           (!(infoRec->FillSolidRectsFlags & RGB_EQUAL) ||
-			(depth == 8) || CHECK_RGB_EQUAL(fg)))  
-	{
-	    (*infoRec->FillSolidRects)(infoRec->pScrn, fg, GXcopy, 
-						pm, nBox, pBox);
-	    return;
-	}
-    } else {	/* pixmap */
-        XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
-	WindowPtr pBgWin = pWin;
-	int xorg, yorg;
-
-	if (what == PW_BORDER) {
-	    for (pBgWin = pWin;
-		 pBgWin->backgroundState == ParentRelative;
-		 pBgWin = pBgWin->parent);
-	}
-
-        xorg = pBgWin->drawable.x;
-        yorg = pBgWin->drawable.y;
-
-#ifdef PANORAMIX
-	if(!noPanoramiXExtension) {
-	    int index = pScreen->myNum;
-	    if(WindowTable[index] == pBgWin) {
-		xorg -= panoramiXdataPtr[index].x;
-		yorg -= panoramiXdataPtr[index].y;
-	    }
-	}
-#endif
-
-	if(IS_OFFSCREEN_PIXMAP(pPix) && infoRec->FillCacheBltRects) {
-	    XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
-
-	    pCache->x = pPriv->offscreenArea->box.x1;
-	    pCache->y = pPriv->offscreenArea->box.y1;
-	    pCache->w = pCache->orig_w = 
-		pPriv->offscreenArea->box.x2 - pCache->x;
-	    pCache->h = pCache->orig_h = 
-		pPriv->offscreenArea->box.y2 - pCache->y;
-	    pCache->trans_color = -1;
-	     
-	    (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, pm,
-				nBox, pBox, xorg, yorg, pCache);
-
-	    return;
-	}
-
-	if(pPriv->flags & DIRTY) {
-	    pPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK);
-	    pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-        }
-
-    	if(!(pPriv->flags & REDUCIBILITY_CHECKED) &&
-	    (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
-	    XAACheckTileReducibility(pPix, infoRec->CanDoMono8x8);
-	}
-
-	if(pPriv->flags & REDUCIBLE_TO_8x8) {
-	    if((pPriv->flags & REDUCIBLE_TO_2_COLOR) &&
-		infoRec->CanDoMono8x8 && infoRec->FillMono8x8PatternRects &&
-		!(infoRec->FillMono8x8PatternRectsFlags & NO_PLANEMASK) &&
-		!(infoRec->FillMono8x8PatternRectsFlags & TRANSPARENCY_ONLY) && 
-		(!(infoRec->FillMono8x8PatternRectsFlags & RGB_EQUAL) || 
-		(CHECK_RGB_EQUAL(pPriv->fg) && CHECK_RGB_EQUAL(pPriv->bg)))) 
-	    {
-		(*infoRec->FillMono8x8PatternRects)(infoRec->pScrn,
-			pPriv->fg, pPriv->bg, GXcopy, pm, nBox, pBox,
-			pPriv->pattern0, pPriv->pattern1, xorg, yorg);
-		return;
-	    }
-	    if(infoRec->CanDoColor8x8 && infoRec->FillColor8x8PatternRects &&
-		!(infoRec->FillColor8x8PatternRectsFlags & NO_PLANEMASK)) 
-	    {
-		XAACacheInfoPtr pCache = (*infoRec->CacheColor8x8Pattern)(
-					infoRec->pScrn, pPix, -1, -1);
-
-		(*infoRec->FillColor8x8PatternRects) (infoRec->pScrn, 
-			GXcopy, pm, nBox, pBox, xorg, yorg, pCache);
-		return;
-	    }        
-	}
-
-	if(infoRec->UsingPixmapCache && infoRec->FillCacheBltRects && 
-	    !(infoRec->FillCacheBltRectsFlags & NO_PLANEMASK) && 
-	    (pPix->drawable.height <= infoRec->MaxCacheableTileHeight) &&
-	    (pPix->drawable.width <= infoRec->MaxCacheableTileWidth)) 
-	{
-	     XAACacheInfoPtr pCache = 
-			(*infoRec->CacheTile)(infoRec->pScrn, pPix);
-	     (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, pm,
-				nBox, pBox, xorg, yorg, pCache);
-	     return;
-	}
-
-	if(infoRec->FillImageWriteRects && 
-		!(infoRec->FillImageWriteRectsFlags & NO_PLANEMASK)) 
-	{
-	    (*infoRec->FillImageWriteRects) (infoRec->pScrn, GXcopy, 
-			pm, nBox, pBox, xorg, yorg, pPix);
-	    return;
-	}
-    }
-
-    if(infoRec->NeedToSync) {
-	(*infoRec->Sync)(infoRec->pScrn);
-	infoRec->NeedToSync = FALSE;
-    }
-
-BAILOUT:
-
-    if(what == PW_BACKGROUND) {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBackground);
-	(*pScreen->PaintWindowBackground) (pWin, prgn, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBackground, XAAPaintWindow8_32);
-    } else {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBorder);
-	(*pScreen->PaintWindowBorder) (pWin, prgn, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBorder, XAAPaintWindow8_32);
-    }
-}
-
-
 static void
 XAASetColorKey8_32(
     ScreenPtr pScreen,
@@ -295,8 +118,6 @@ XAASetupOverlay8_32Planar(ScreenPtr pScr
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
     int i;
 
-    pScreen->PaintWindowBackground = XAAPaintWindow8_32;
-    pScreen->PaintWindowBorder = XAAPaintWindow8_32;
     pScreen->CopyWindow = XAACopyWindow8_32;
 
     if(!(infoRec->FillSolidRectsFlags & NO_PLANEMASK))
diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c
index 5897e32..bf91098 100644
--- a/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/hw/xfree86/xaa/xaaOverlayDF.c
@@ -28,7 +28,6 @@
 /* Screen funcs */
 
 static void XAAOverCopyWindow(WindowPtr, DDXPointRec, RegionPtr);
-static void XAAOverPaintWindow(WindowPtr, RegionPtr, int);
 static void XAAOverWindowExposures(WindowPtr, RegionPtr, RegionPtr);
 
 static int XAAOverStippledFillChooser(GCPtr);
@@ -194,8 +193,6 @@ XAAInitDualFramebufferOverlay(
     /* Overwrite key screen functions.  The XAA core will clean up */
 
     pScreen->CopyWindow = XAAOverCopyWindow;
-    pScreen->PaintWindowBackground = XAAOverPaintWindow;
-    pScreen->PaintWindowBorder = XAAOverPaintWindow;
     pScreen->WindowExposures = XAAOverWindowExposures;
 
     pOverPriv->StippledFillChooser = infoRec->StippledFillChooser;
@@ -410,56 +407,6 @@ XAAOverCopyWindow(
 }
 
 
-static void
-XAAOverPaintWindow(
-    WindowPtr   pWin,
-    RegionPtr   pRegion,
-    int         what
-){
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen);
-    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
-    ScrnInfoPtr pScrn = infoRec->pScrn;
-
-    if(pScrn->vtSema) {
-	if(what == PW_BACKGROUND) {
-	    SWITCH_DEPTH(pWin->drawable.depth);
-	    (*infoRec->PaintWindowBackground)(pWin, pRegion, what);
-	    return;
-	} else {
-	    if(pWin->drawable.bitsPerPixel == 8) {
-		SWITCH_DEPTH(8);
-		(*infoRec->PaintWindowBorder)(pWin, pRegion, what);
-		return;
-	    } else if (infoRec->FillSolidRects)  {
-		SWITCH_DEPTH(8);
-		(*infoRec->FillSolidRects)(pScrn, pScrn->colorKey, GXcopy, 
-			~0, REGION_NUM_RECTS(pRegion), REGION_RECTS(pRegion));
-
-		SWITCH_DEPTH(pWin->drawable.depth);
-		(*infoRec->PaintWindowBorder)(pWin, pRegion, what);
-		return;
-	    } 
-	}
-
-	if(infoRec->NeedToSync) {
-	    (*infoRec->Sync)(infoRec->pScrn);
-	    infoRec->NeedToSync = FALSE;
-	}
-    }
-
-    if(what == PW_BACKGROUND) {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBackground);
-	(*pScreen->PaintWindowBackground) (pWin, pRegion, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBackground, XAAOverPaintWindow);
-    } else {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBorder);
-	(*pScreen->PaintWindowBorder) (pWin, pRegion, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBorder, XAAOverPaintWindow);
-    }
-}
-
-
 void
 XAAOverWindowExposures(
    WindowPtr pWin,
diff --git a/hw/xfree86/xaa/xaaPaintWin.c b/hw/xfree86/xaa/xaaPaintWin.c
deleted file mode 100644
index af5680c..0000000
--- a/hw/xfree86/xaa/xaaPaintWin.c
+++ /dev/null
@@ -1,200 +0,0 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "gcstruct.h"
-#include "pixmapstr.h"
-#include "xaawrap.h"
-
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#include "panoramiXsrv.h"
-#endif
-
-void
-XAAPaintWindow(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-)
-{
-    ScreenPtr  pScreen = pWin->drawable.pScreen;
-    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
-    int nBox = REGION_NUM_RECTS(prgn);
-    BoxPtr pBox = REGION_RECTS(prgn);
-    int fg = -1;
-    PixmapPtr pPix = NULL;
-
-    if(!infoRec->pScrn->vtSema) goto BAILOUT;	
-
-    switch (what) {
-    case PW_BACKGROUND:
-	switch(pWin->backgroundState) {
-	case None: return;
-	case ParentRelative:
-	    do { pWin = pWin->parent; }
-	    while(pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, what);
-	    return;
-	case BackgroundPixel:
-	    fg = pWin->background.pixel;
-	    break;
-	case BackgroundPixmap:
-	    pPix = pWin->background.pixmap;
-	    break;
-	}
-	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel) 
-	    fg = pWin->border.pixel;
-	else 	/* pixmap */ 
-	    pPix = pWin->border.pixmap;
-	break;
-    default: return;
-    }
-
-
-    if(!pPix) {
-        if(infoRec->FillSolidRects &&
-           (!(infoRec->FillSolidRectsFlags & RGB_EQUAL) || 
-                (CHECK_RGB_EQUAL(fg))) )  {
-	    (*infoRec->FillSolidRects)(infoRec->pScrn, fg, GXcopy, ~0,
-					nBox, pBox);
-	    return;
-	}
-    } else {	/* pixmap */
-        XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
-	WindowPtr pBgWin = pWin;
-	Bool NoCache = FALSE;
-	int xorg, yorg;
-
-	/* Hack so we can use this with the dual framebuffer layers
-	   which only support the pixmap cache in the primary bpp */
-	if(pPix->drawable.bitsPerPixel != infoRec->pScrn->bitsPerPixel)
-	    NoCache = TRUE;
-
-	if (what == PW_BORDER) {
-	    for (pBgWin = pWin;
-		 pBgWin->backgroundState == ParentRelative;
-		 pBgWin = pBgWin->parent);
-	}
-
-        xorg = pBgWin->drawable.x;
-        yorg = pBgWin->drawable.y;
-
-#ifdef PANORAMIX
-	if(!noPanoramiXExtension) {
-	    int index = pScreen->myNum;
-	    if(WindowTable[index] == pBgWin) {
-		xorg -= panoramiXdataPtr[index].x;
-		yorg -= panoramiXdataPtr[index].y;
-	    }
-	}
-#endif
-
-	if(IS_OFFSCREEN_PIXMAP(pPix) && infoRec->FillCacheBltRects) {
-	    XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
-
-	    pCache->x = pPriv->offscreenArea->box.x1;
-	    pCache->y = pPriv->offscreenArea->box.y1;
-	    pCache->w = pCache->orig_w = 
-		pPriv->offscreenArea->box.x2 - pCache->x;
-	    pCache->h = pCache->orig_h = 
-		pPriv->offscreenArea->box.y2 - pCache->y;
-	    pCache->trans_color = -1;
-	     
-	    (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, ~0,
-				nBox, pBox, xorg, yorg, pCache);
-	    return;
-	}
-
-	if(pPriv->flags & DIRTY) {
-	    pPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK);
-	    pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-        }
-
-    	if(!(pPriv->flags & REDUCIBILITY_CHECKED) &&
-	    (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
-	    XAACheckTileReducibility(pPix, infoRec->CanDoMono8x8);
-	}
-
-	if(pPriv->flags & REDUCIBLE_TO_8x8) {
-	    if((pPriv->flags & REDUCIBLE_TO_2_COLOR) &&
-		infoRec->CanDoMono8x8 && infoRec->FillMono8x8PatternRects &&
-		!(infoRec->FillMono8x8PatternRectsFlags & TRANSPARENCY_ONLY) && 
-		(!(infoRec->FillMono8x8PatternRectsFlags & RGB_EQUAL) || 
-		(CHECK_RGB_EQUAL(pPriv->fg) && CHECK_RGB_EQUAL(pPriv->bg)))) {
-
-	    	(*infoRec->FillMono8x8PatternRects)(infoRec->pScrn,
-			pPriv->fg, pPriv->bg, GXcopy, ~0, nBox, pBox,
-			pPriv->pattern0, pPriv->pattern1, xorg, yorg);
-		return;
-	    }
-	    if(infoRec->CanDoColor8x8 && !NoCache &&
-				infoRec->FillColor8x8PatternRects) {
-		XAACacheInfoPtr pCache = (*infoRec->CacheColor8x8Pattern)(
-					infoRec->pScrn, pPix, -1, -1);
-
-		(*infoRec->FillColor8x8PatternRects) ( infoRec->pScrn, 
-				GXcopy, ~0, nBox, pBox, xorg, yorg, pCache);
-		return;
-	    }        
-	}
-
-	/* The window size check is to reduce pixmap cache thrashing
-	   when there are lots of little windows with pixmap backgrounds
-	   like are sometimes used for buttons, etc... */
-
-	if(infoRec->UsingPixmapCache && 
-	    infoRec->FillCacheBltRects && !NoCache &&
-	    ((what == PW_BORDER) ||
-		(pPix->drawable.height != pWin->drawable.height) ||
-		(pPix->drawable.width != pWin->drawable.width)) &&
-	    (pPix->drawable.height <= infoRec->MaxCacheableTileHeight) &&
-	    (pPix->drawable.width <= infoRec->MaxCacheableTileWidth)) {
-
-	     XAACacheInfoPtr pCache = 
-			(*infoRec->CacheTile)(infoRec->pScrn, pPix);
-	     (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, ~0,
-					nBox, pBox, xorg, yorg, pCache);
-	     return;
-	}
-
-	if(infoRec->FillImageWriteRects && 
-		!(infoRec->FillImageWriteRectsFlags & NO_GXCOPY)) {
-	    (*infoRec->FillImageWriteRects) (infoRec->pScrn, GXcopy, 
-                   		~0, nBox, pBox, xorg, yorg, pPix);
-	    return;
-	}
-    }
-
-
-    if(infoRec->NeedToSync) {
-	(*infoRec->Sync)(infoRec->pScrn);
-	infoRec->NeedToSync = FALSE;
-    }
-
-BAILOUT:
-
-    if(what == PW_BACKGROUND) {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBackground);
-	(*pScreen->PaintWindowBackground) (pWin, prgn, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBackground, XAAPaintWindow);
-    } else {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBorder);
-	(*pScreen->PaintWindowBorder) (pWin, prgn, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBorder, XAAPaintWindow);
-    }
-
-}
diff --git a/hw/xfree86/xaa/xaaStateChange.c b/hw/xfree86/xaa/xaaStateChange.c
index 711f779..02c556b 100644
--- a/hw/xfree86/xaa/xaaStateChange.c
+++ b/hw/xfree86/xaa/xaaStateChange.c
@@ -259,8 +259,6 @@ typedef struct _XAAStateWrapRec {
 				       XAACacheInfoPtr pCache);
    GetImageProcPtr GetImage;
    GetSpansProcPtr GetSpans;
-   PaintWindowBackgroundProcPtr PaintWindowBackground;
-   PaintWindowBorderProcPtr PaintWindowBorder;
    CopyWindowProcPtr CopyWindow;
 #ifdef RENDER
    Bool (*SetupForCPUToScreenAlphaTexture2)(ScrnInfoPtr pScrn, int op,
@@ -1449,26 +1447,6 @@ static void XAAStateWrapGetSpans(Drawabl
 			   pwidth, nspans, pdstStart);
 }
 
-static void XAAStateWrapPaintWindowBackground(WindowPtr pWindow, RegionPtr pRegion,
-					      int what)
-{
-   GET_STATEPRIV_SCREEN(pWindow->drawable.pScreen);
-   STATE_CHECK_SP(pStatePriv);
-
-   (*pStatePriv->PaintWindowBackground)(pWindow, pRegion,
-					what);
-}
-
-static void XAAStateWrapPaintWindowBorder(WindowPtr pWindow, RegionPtr pRegion, 
-					  int what)
-{
-   GET_STATEPRIV_SCREEN(pWindow->drawable.pScreen);
-   STATE_CHECK_SP(pStatePriv);
-
-   (*pStatePriv->PaintWindowBorder)(pWindow, pRegion, 
-				    what);
-}
-
 static void XAAStateWrapCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, 
 				   RegionPtr prgnSrc)
 {
@@ -1649,8 +1627,6 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAI
    XAA_STATE_WRAP(WriteColor8x8PatternToCache);
    XAA_STATE_WRAP(GetImage);
    XAA_STATE_WRAP(GetSpans);
-   XAA_STATE_WRAP(PaintWindowBackground);
-   XAA_STATE_WRAP(PaintWindowBorder);
    XAA_STATE_WRAP(CopyWindow);
 #ifdef RENDER
    XAA_STATE_WRAP(SetupForCPUToScreenAlphaTexture2);
diff --git a/hw/xfree86/xaa/xaaWrapper.c b/hw/xfree86/xaa/xaaWrapper.c
index 6d8107b..b0176f0 100644
--- a/hw/xfree86/xaa/xaaWrapper.c
+++ b/hw/xfree86/xaa/xaaWrapper.c
@@ -54,8 +54,6 @@ typedef struct {
     CreateScreenResourcesProcPtr CreateScreenResources;
     CreateWindowProcPtr		CreateWindow;
     CopyWindowProcPtr		CopyWindow;
-    PaintWindowProcPtr		PaintWindowBackground;
-    PaintWindowProcPtr		PaintWindowBorder;
     WindowExposuresProcPtr	WindowExposures;
     CreateGCProcPtr		CreateGC;
     CreateColormapProcPtr	CreateColormap;
@@ -73,8 +71,6 @@ typedef struct {
     CreateScreenResourcesProcPtr wrapCreateScreenResources;
     CreateWindowProcPtr		wrapCreateWindow;
     CopyWindowProcPtr		wrapCopyWindow;
-    PaintWindowProcPtr		wrapPaintWindowBackground;
-    PaintWindowProcPtr		wrapPaintWindowBorder;
     WindowExposuresProcPtr	wrapWindowExposures;
     CreateGCProcPtr		wrapCreateGC;
     CreateColormapProcPtr	wrapCreateColormap;
@@ -208,33 +204,6 @@ xaaWrapperWindowExposures (WindowPtr	pWi
 	      WindowExposures, wrapWindowExposures, xaaWrapperWindowExposures);
 }
 
-static void
-xaaWrapperPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    xaaWrapperScrPriv(pWin->drawable.pScreen);
-
-    switch (what) {
-	case PW_BORDER:
-	    cond_unwrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen,
-			PaintWindowBorder, wrapPaintWindowBorder);
-
-	    pWin->drawable.pScreen->PaintWindowBorder (pWin, pRegion, what);
-	    cond_wrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen,
-		      PaintWindowBorder, wrapPaintWindowBorder,
-		      xaaWrapperPaintWindow);
-	    break;
-	case PW_BACKGROUND:
-	    cond_unwrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen,
-			PaintWindowBackground, wrapPaintWindowBackground);
-
-	    pWin->drawable.pScreen->PaintWindowBackground (pWin, pRegion, what);
-	    cond_wrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen,
-		      PaintWindowBackground, wrapPaintWindowBackground,
-		      xaaWrapperPaintWindow);
-	    break;
-    }
-}
-
 static Bool
 xaaWrapperCreateColormap(ColormapPtr pmap)
 {
@@ -327,8 +296,6 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAIn
     get (pScrPriv, pScreen, CreateScreenResources, wrapCreateScreenResources);
     get (pScrPriv, pScreen, CreateWindow, wrapCreateWindow);
     get (pScrPriv, pScreen, CopyWindow, wrapCopyWindow);
-    get (pScrPriv, pScreen, PaintWindowBorder, wrapPaintWindowBorder);
-    get (pScrPriv, pScreen, PaintWindowBackground, wrapPaintWindowBackground);
     get (pScrPriv, pScreen, WindowExposures, wrapWindowExposures);
     get (pScrPriv, pScreen, CreateGC, wrapCreateGC);
     get (pScrPriv, pScreen, CreateColormap, wrapCreateColormap);
@@ -351,8 +318,6 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAIn
 	  xaaWrapperCreateScreenResources);
     wrap (pScrPriv, pScreen, CreateWindow, xaaWrapperCreateWindow);
     wrap (pScrPriv, pScreen, CopyWindow, xaaWrapperCopyWindow);
-    wrap (pScrPriv, pScreen, PaintWindowBorder, xaaWrapperPaintWindow);
-    wrap (pScrPriv, pScreen, PaintWindowBackground, xaaWrapperPaintWindow);
     wrap (pScrPriv, pScreen, WindowExposures, xaaWrapperWindowExposures);
     wrap (pScrPriv, pScreen, CreateGC, xaaWrapperCreateGC);
     wrap (pScrPriv, pScreen, CreateColormap, xaaWrapperCreateColormap);
diff --git a/hw/xfree86/xaa/xaalocal.h b/hw/xfree86/xaa/xaalocal.h
index 3ddea24..686cc87 100644
--- a/hw/xfree86/xaa/xaalocal.h
+++ b/hw/xfree86/xaa/xaalocal.h
@@ -45,8 +45,6 @@ typedef struct _XAAScreen {
    CloseScreenProcPtr 		CloseScreen;
    GetImageProcPtr 		GetImage;
    GetSpansProcPtr 		GetSpans;
-   PaintWindowBackgroundProcPtr PaintWindowBackground;
-   PaintWindowBorderProcPtr 	PaintWindowBorder;
    CopyWindowProcPtr 		CopyWindow;
    WindowExposuresProcPtr	WindowExposures;
    CreatePixmapProcPtr 		CreatePixmap;
@@ -1315,14 +1313,6 @@ XAAWritePixmapToCacheLinear(
    int bpp, int depth
 );
 
-
-void
-XAAPaintWindow(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-);
-
 void 
 XAASolidHorVertLineAsRects(
    ScrnInfoPtr pScrn,
diff --git a/hw/xfree86/xf1bpp/Makefile.am b/hw/xfree86/xf1bpp/Makefile.am
index 4ea7ef0..c724f76 100644
--- a/hw/xfree86/xf1bpp/Makefile.am
+++ b/hw/xfree86/xf1bpp/Makefile.am
@@ -45,7 +45,6 @@ libxf1bppmfb_a_SOURCES = \
         mfbline.c \
         mfbmisc.c \
         mfbpixmap.c \
-        mfbpntwin.c \
         mfbpolypnt.c \
         mfbpushpxl.c \
         mfbscrclse.c \
diff --git a/hw/xfree86/xf1bpp/mfbmap.h b/hw/xfree86/xf1bpp/mfbmap.h
index 5825c1c..e330ebd 100644
--- a/hw/xfree86/xf1bpp/mfbmap.h
+++ b/hw/xfree86/xf1bpp/mfbmap.h
@@ -61,7 +61,6 @@
 #define mfbListInstalledColormaps  xf1bppListInstalledColormaps
 #define mfbMapWindow  xf1bppMapWindow
 #define mfbPadPixmap  xf1bppPadPixmap
-#define mfbPaintWindow  xf1bppPaintWindow
 #define mfbPixmapToRegion  xf1bppPixmapToRegion
 #define mfbPixmapToRegionWeak xf1bppPixmapToRegionWeak
 #define mfbPolyFillArcSolid  xf1bppPolyFillArcSolid
diff --git a/hw/xfree86/xf1bpp/mfbunmap.h b/hw/xfree86/xf1bpp/mfbunmap.h
index 16237a1..56b734b 100644
--- a/hw/xfree86/xf1bpp/mfbunmap.h
+++ b/hw/xfree86/xf1bpp/mfbunmap.h
@@ -53,7 +53,6 @@
 #undef mfbListInstalledColormaps
 #undef mfbMapWindow
 #undef mfbPadPixmap
-#undef mfbPaintWindow
 #undef mfbPixmapToRegion
 #undef mfbPixmapToRegionWeak
 #undef mfbPolyFillArcSolid
diff --git a/hw/xfree86/xf4bpp/Makefile.am b/hw/xfree86/xf4bpp/Makefile.am
index 8665b2a..1414a0d 100644
--- a/hw/xfree86/xf4bpp/Makefile.am
+++ b/hw/xfree86/xf4bpp/Makefile.am
@@ -17,7 +17,6 @@ libxf4bpp_la_SOURCES = \
         ppcGetSp.c \
         ppcImg.c \
         ppcPixmap.c \
-        ppcPntWin.c \
         ppcPolyPnt.c \
         ppcQuery.c \
         ppcRslvC.c \
diff --git a/hw/xfree86/xf4bpp/ppcGC.c b/hw/xfree86/xf4bpp/ppcGC.c
index b59dab3..674a38b 100644
--- a/hw/xfree86/xf4bpp/ppcGC.c
+++ b/hw/xfree86/xf4bpp/ppcGC.c
@@ -176,8 +176,7 @@ register GCPtr pGC ;
 
 	pGC->fExpose = TRUE;
 	pGC->freeCompClip = FALSE;
-	pGC->pRotatedPixmap = NullPixmap;
-	
+
 	/* GJA: I don't like this code:
          * they allocated a mfbPrivGC, ignore the allocated data and place
          * a pointer to a ppcPrivGC in its slot.
@@ -200,12 +199,6 @@ xf4bppDestroyGC( pGC )
 {
     TRACE( ( "xf4bppDestroyGC(pGC=0x%x)\n", pGC ) ) ;
 
-    /* (ef) 11/9/87 -- ppc doesn't use rotated tile or stipple, but */
-    /*		*does* call mfbValidateGC under some conditions.    */
-    /*		mfbValidateGC *does* use rotated tile and stipple   */
-    if ( pGC->pRotatedPixmap )
-	mfbDestroyPixmap( pGC->pRotatedPixmap ) ;
-
     if ( pGC->freeCompClip && pGC->pCompositeClip )
 	REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
     if(pGC->ops->devPrivate.val) xfree( pGC->ops );
diff --git a/hw/xfree86/xf4bpp/ppcIO.c b/hw/xfree86/xf4bpp/ppcIO.c
index 8d726e7..313fcb0 100644
--- a/hw/xfree86/xf4bpp/ppcIO.c
+++ b/hw/xfree86/xf4bpp/ppcIO.c
@@ -205,8 +205,6 @@ xf4bppScreenInit( pScreen, pbits, virtx,
   pScreen-> CreateWindow = xf4bppCreateWindowForXYhardware;
   pScreen-> DestroyWindow = xf4bppDestroyWindow;
   pScreen-> PositionWindow = xf4bppPositionWindow;
-  pScreen-> PaintWindowBackground = xf4bppPaintWindow;
-  pScreen-> PaintWindowBorder = xf4bppPaintWindow;
   pScreen-> CopyWindow = xf4bppCopyWindow;
   pScreen-> CreatePixmap = xf4bppCreatePixmap;
   pScreen-> CreateGC = xf4bppCreateGC;
@@ -219,7 +217,7 @@ xf4bppScreenInit( pScreen, pbits, virtx,
   pScreen-> ResolveColor = xf4bppResolveColor;
   mfbFillInScreen(pScreen);
 
-  if (!mfbAllocatePrivates(pScreen, (int*)NULL, (int*)NULL))
+  if (!mfbAllocatePrivates(pScreen, NULL))
 	return FALSE;
 
   if (!miScreenInit(pScreen, pbits, virtx, virty, dpix, dpiy, width,
diff --git a/hw/xfree86/xf4bpp/ppcPntWin.c b/hw/xfree86/xf4bpp/ppcPntWin.c
deleted file mode 100644
index 5d7a07e..0000000
--- a/hw/xfree86/xf4bpp/ppcPntWin.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright IBM Corporation 1987,1988,1989
- *
- * 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 notice appear in all copies and that 
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of IBM not be
- * used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.
- *
- * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * IBM 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.
- *
-*/
-
-/***********************************************************
-
-Copyright (c) 1987  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 without limitation the rights
-to use, copy, modify, merge, publish, 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.  IN NO EVENT SHALL THE
-X CONSORTIUM 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 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 from the X Consortium.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        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 notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL 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_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf4bpp.h"
-#include "mfbmap.h"
-#include "mfb.h"
-#include "mi.h"
-#include "scrnintstr.h"
-#include "ibmTrace.h"
-
-/* NOTE: These functions only work for visuals up to 31-bits deep */
-static void xf4bppPaintWindowSolid(
-    WindowPtr,
-    RegionPtr,
-    int 
-);
-static void xf4bppPaintWindowTile(
-    WindowPtr,
-    RegionPtr,
-    int 
-);
-
-void
-xf4bppPaintWindow(pWin, pRegion, what)
-    WindowPtr	pWin;
-    RegionPtr	pRegion;
-    int		what;
-{
-
-    register mfbPrivWin	*pPrivWin;
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbGetWindowPrivateIndex()].ptr);
-
-    TRACE(("xf4bppPaintWindow( pWin= 0x%x, pRegion= 0x%x, what= %d )\n",
-							pWin,pRegion,what));
-
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixmap:
-	    if (pPrivWin->fastBackground)
-	    {
-		xf4bppPaintWindowTile(pWin, pRegion, what);
-		return;
-	    }
-	    break;
-	case BackgroundPixel:
-	    xf4bppPaintWindowSolid(pWin, pRegion, what);
-	    return;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    xf4bppPaintWindowSolid(pWin, pRegion, what);
-	    return;
-	}
-	else if (pPrivWin->fastBorder)
-	{
-            xf4bppPaintWindowTile(pWin, pRegion, what);
-	    return;
-	}
-	break;
-    }
-    miPaintWindow(pWin, pRegion, what);
-}
-
-static void
-xf4bppPaintWindowSolid(pWin, pRegion, what)
-    register WindowPtr pWin;
-    register RegionPtr pRegion;
-    int what;		
-{
-    register int nbox;
-    register BoxPtr pbox;
-    register unsigned long int pixel;
-    register unsigned long int pm ;
-
-    TRACE(("xf4bppPaintWindowSolid(pWin= 0x%x, pRegion= 0x%x, what= %d)\n", pWin, pRegion, what));
-
-    if ( !( nbox = REGION_NUM_RECTS(pRegion)))
-	return ;
-    pbox = REGION_RECTS(pRegion);
-
-    if (what == PW_BACKGROUND)
-	pixel = pWin->background.pixel;
-    else
-	pixel = pWin->border.pixel; 
-
-    pm = ( 1 << pWin->drawable.depth ) - 1 ;
-    for ( ; nbox-- ; pbox++ ) {
-	/*
-	 * call fill routine, the parms are:
-	 * 	fill(color, alu, planes, x, y, width, height);
-	 */
-	xf4bppFillSolid( pWin, pixel, GXcopy, pm, pbox->x1, pbox->y1, 
-		pbox->x2 - pbox->x1, pbox->y2 - pbox->y1 ) ; 
-    }
-    return ;
-}
-
-static void
-xf4bppPaintWindowTile(pWin, pRegion, what)
-    register WindowPtr pWin;
-    register RegionPtr pRegion;
-    int what;		
-{
-    register int nbox;
-    register BoxPtr pbox;
-    register PixmapPtr pTile;
-    register unsigned long int pm ;
-
-    TRACE(("xf4bppPaintWindowTile(pWin= 0x%x, pRegion= 0x%x, what= %d)\n", pWin, pRegion, what));
-
-    if ( !( nbox = REGION_NUM_RECTS(pRegion)))
-	return ;
-    pbox = REGION_RECTS(pRegion);
-
-    if (what == PW_BACKGROUND)
-	pTile = pWin->background.pixmap;
-    else
-	pTile = pWin->border.pixmap;
-
-    pm = ( 1 << pWin->drawable.depth ) - 1 ;
-    for ( ; nbox-- ; pbox++ ) {
-	/*
-	 * call tile routine, the parms are:
-	 * 	tile(tile, alu, planes, x, y, width, height,xSrc,ySrc);
-	 */
-	xf4bppTileRect(pWin, pTile, GXcopy, pm, 
-		pbox->x1, pbox->y1, 
-		pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
-		pWin->drawable.x, pWin->drawable.y );
-    }
-    return ;
-}
diff --git a/hw/xfree86/xf4bpp/ppcWindow.c b/hw/xfree86/xf4bpp/ppcWindow.c
index 01768d9..8261af1 100644
--- a/hw/xfree86/xf4bpp/ppcWindow.c
+++ b/hw/xfree86/xf4bpp/ppcWindow.c
@@ -214,15 +214,7 @@ Bool
 xf4bppCreateWindowForXYhardware(pWin)
 register WindowPtr pWin ;
 {
-    register mfbPrivWin *pPrivWin;
-
     TRACE(("xf4bppCreateWindowForXYhardware (pWin= 0x%x)\n", pWin));
 
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbGetWindowPrivateIndex()].ptr);
-    pPrivWin->pRotatedBorder = NullPixmap;
-    pPrivWin->pRotatedBackground = NullPixmap;
-    pPrivWin->fastBackground = 0;
-    pPrivWin->fastBorder = 0;
-
     return TRUE;
 }
diff --git a/hw/xfree86/xf4bpp/xf4bpp.h b/hw/xfree86/xf4bpp/xf4bpp.h
index 5d5dcdd..e7e3721 100644
--- a/hw/xfree86/xf4bpp/xf4bpp.h
+++ b/hw/xfree86/xf4bpp/xf4bpp.h
@@ -189,13 +189,6 @@ PixmapPtr xf4bppCopyPixmap(
     PixmapPtr
 );
 
-/* ppcPntWin.c */
-void xf4bppPaintWindow(
-    WindowPtr,
-    RegionPtr,
-    int
-);
-
 /* ppcPolyPnt.c */
 void xf4bppPolyPoint(
     DrawablePtr,
diff --git a/hw/xfree86/xf8_32bpp/cfb8_32.h b/hw/xfree86/xf8_32bpp/cfb8_32.h
index 31028a3..e140965 100644
--- a/hw/xfree86/xf8_32bpp/cfb8_32.h
+++ b/hw/xfree86/xf8_32bpp/cfb8_32.h
@@ -111,13 +111,6 @@ cfb8_32GetImage (
     char *pdstLine
 );
 
-void
-cfb8_32PaintWindow (
-    WindowPtr   pWin,
-    RegionPtr   pRegion,
-    int         what
-);
-
 Bool
 cfb8_32ScreenInit (
     ScreenPtr pScreen,
@@ -135,15 +128,6 @@ cfb8_32FillBoxSolid8 (
    unsigned long color
 );
 
-
-void
-cfb8_32FillBoxSolid32 (
-   DrawablePtr pDraw,
-   int nbox,
-   BoxPtr pBox,
-   unsigned long color
-);
-
 RegionPtr 
 cfb8_32CopyPlane(
     DrawablePtr pSrc,
diff --git a/hw/xfree86/xf8_32bpp/cfbpntwin.c b/hw/xfree86/xf8_32bpp/cfbpntwin.c
index a1b9887..fbf597d 100644
--- a/hw/xfree86/xf8_32bpp/cfbpntwin.c
+++ b/hw/xfree86/xf8_32bpp/cfbpntwin.c
@@ -23,97 +23,6 @@
 #endif
 
 void
-cfb8_32PaintWindow(
-    WindowPtr   pWin,
-    RegionPtr   pRegion,
-    int         what
-){
-    WindowPtr pBgWin;
-    int xorg, yorg;
-
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    break;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(
-						pWin, pRegion, what);
-	    break;
-	case BackgroundPixmap:
-	    xorg = pWin->drawable.x;
-	    yorg = pWin->drawable.y;
-#ifdef PANORAMIX
-	    if(!noPanoramiXExtension) {
-		int index = pWin->drawable.pScreen->myNum;
-		if(WindowTable[index] == pWin) {
-		    xorg -= panoramiXdataPtr[index].x;
-		    yorg -= panoramiXdataPtr[index].y;
-		}
-	    }
-#endif
-	    cfb32FillBoxTileOddGeneral ((DrawablePtr)pWin,
-			(int)REGION_NUM_RECTS(pRegion), REGION_RECTS(pRegion),
-			pWin->background.pixmap, xorg, yorg, GXcopy, 
-			(pWin->drawable.depth == 24) ? 0x00ffffff : 0xff000000);
-	    break;
-	case BackgroundPixel:
-	    if(pWin->drawable.depth == 24) 
-		cfb8_32FillBoxSolid32 ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel);
-	    else
-		cfb8_32FillBoxSolid8 ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel);
-	    break;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel) {
-	    if(pWin->drawable.depth == 24) {
-		cfb8_32FillBoxSolid32 ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel);
-	    } else
-		cfb8_32FillBoxSolid8 ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel);
-	} else {
-	    for (pBgWin = pWin;
-		 pBgWin->backgroundState == ParentRelative;
-		 pBgWin = pBgWin->parent);
-
-	    xorg = pBgWin->drawable.x;
-	    yorg = pBgWin->drawable.y;
-
-#ifdef PANORAMIX
-	    if(!noPanoramiXExtension) {
-		int index = pWin->drawable.pScreen->myNum;
-		if(WindowTable[index] == pBgWin) {
-		    xorg -= panoramiXdataPtr[index].x;
-		    yorg -= panoramiXdataPtr[index].y;
-		}
-	    }
-#endif
-	    cfb32FillBoxTileOddGeneral ((DrawablePtr)pWin,
-			(int)REGION_NUM_RECTS(pRegion), REGION_RECTS(pRegion),
-			pWin->border.pixmap, xorg, yorg, GXcopy, 
-			(pWin->drawable.depth == 24) ? 0x00ffffff : 0xff000000);
-	}
-	break;
-    }
-
-}
-
-void
 cfb8_32FillBoxSolid8(
    DrawablePtr pDraw,
    int nbox,
@@ -140,41 +49,3 @@ cfb8_32FillBoxSolid8(
 	pbox++;
     }
 }
-
-
-void
-cfb8_32FillBoxSolid32(
-   DrawablePtr pDraw,
-   int nbox,
-   BoxPtr pbox,
-   unsigned long color
-){
-    CARD8 *ptr, *data;
-    CARD16 *ptr2, *data2;
-    int pitch, pitch2;
-    int height, width, i;
-    CARD8 c = (CARD8)(color >> 16);
-    CARD16 c2 = (CARD16)color;
-
-    cfbGetByteWidthAndPointer(pDraw, pitch, ptr);
-    cfbGetTypedWidthAndPointer(pDraw, pitch2, ptr2, CARD16, CARD16);
-    ptr += 2; /* point to the third byte */
-
-    while(nbox--) {
-	data = ptr + (pbox->y1 * pitch) + (pbox->x1 << 2);
-	data2 = ptr2 + (pbox->y1 * pitch2) + (pbox->x1 << 1);
-	width = (pbox->x2 - pbox->x1) << 1;
-	height = pbox->y2 - pbox->y1;
-
-	while(height--) {
-            for(i = 0; i < width; i+=2) {
-		data[i << 1] = c;
-		data2[i] = c2;
-	    }
-            data += pitch;
-            data2 += pitch2;
-	}
-	pbox++;
-    }
-}
-
diff --git a/hw/xfree86/xf8_32bpp/cfbscrinit.c b/hw/xfree86/xf8_32bpp/cfbscrinit.c
index 29dc669..5e2657f 100644
--- a/hw/xfree86/xf8_32bpp/cfbscrinit.c
+++ b/hw/xfree86/xf8_32bpp/cfbscrinit.c
@@ -56,11 +56,7 @@ cfb8_32AllocatePrivates(ScreenPtr pScree
    
    
    /* All cfb will have the same GC and Window private indicies */
-   if(!mfbAllocatePrivates(pScreen,&cfbWindowPrivateIndex, &cfbGCPrivateIndex))
-	return FALSE;
-
-   /* The cfb indicies are the mfb indicies. Reallocating them resizes them */ 
-   if(!AllocateWindowPrivate(pScreen,cfbWindowPrivateIndex,sizeof(cfbPrivWin)))
+   if(!mfbAllocatePrivates(pScreen, &cfbGCPrivateIndex))
 	return FALSE;
 
    if(!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
@@ -109,8 +105,6 @@ cfb8_32SetupScreen(
     pScreen->ChangeWindowAttributes = cfb8_32ChangeWindowAttributes;
     pScreen->RealizeWindow = cfb32MapWindow;			/* OK */
     pScreen->UnrealizeWindow = cfb32UnmapWindow;		/* OK */
-    pScreen->PaintWindowBackground = cfb8_32PaintWindow;
-    pScreen->PaintWindowBorder = cfb8_32PaintWindow;
     pScreen->CopyWindow = cfb8_32CopyWindow;
     pScreen->CreatePixmap = cfb32CreatePixmap;			/* OK */
     pScreen->DestroyPixmap = cfb32DestroyPixmap; 		/* OK */
diff --git a/hw/xfree86/xf8_32bpp/cfbwindow.c b/hw/xfree86/xf8_32bpp/cfbwindow.c
index ce741cb..787cbde 100644
--- a/hw/xfree86/xf8_32bpp/cfbwindow.c
+++ b/hw/xfree86/xf8_32bpp/cfbwindow.c
@@ -27,11 +27,6 @@
 Bool
 cfb8_32CreateWindow(WindowPtr pWin)
 {
-    cfbPrivWin *pPrivWin = cfbGetWindowPrivate(pWin);
-
-    pPrivWin->fastBackground = FALSE;
-    pPrivWin->fastBorder = FALSE;
-
     pWin->drawable.bitsPerPixel = 32;
     return TRUE;
 }
diff --git a/hw/xfree86/xf8_32bpp/xf86overlay.c b/hw/xfree86/xf8_32bpp/xf86overlay.c
index c5585ca..3cd351a 100644
--- a/hw/xfree86/xf8_32bpp/xf86overlay.c
+++ b/hw/xfree86/xf8_32bpp/xf86overlay.c
@@ -34,7 +34,6 @@ static Bool OverlayCreateGC(GCPtr pGC);
 static Bool OverlayDestroyPixmap(PixmapPtr);
 static PixmapPtr OverlayCreatePixmap(ScreenPtr, int, int, int);
 static Bool OverlayChangeWindowAttributes(WindowPtr, unsigned long);
-static void OverlayPaintWindow(WindowPtr, RegionPtr, int);
 
 /** Funcs **/
 static void OverlayValidateGC(GCPtr, unsigned long, DrawablePtr);
@@ -159,8 +158,6 @@ typedef struct {
    CreatePixmapProcPtr		CreatePixmap;
    DestroyPixmapProcPtr		DestroyPixmap;
    ChangeWindowAttributesProcPtr ChangeWindowAttributes;
-   PaintWindowBackgroundProcPtr	PaintWindowBackground;
-   PaintWindowBorderProcPtr	PaintWindowBorder;
    int				LockPrivate;
 } OverlayScreenRec, *OverlayScreenPtr;
 
@@ -284,16 +281,12 @@ xf86Overlay8Plus32Init (ScreenPtr pScree
     pScreenPriv->CreatePixmap = pScreen->CreatePixmap;
     pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap;
     pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
-    pScreenPriv->PaintWindowBackground = pScreen->PaintWindowBackground;
-    pScreenPriv->PaintWindowBorder = pScreen->PaintWindowBorder;
 
     pScreen->CreateGC = OverlayCreateGC;
     pScreen->CloseScreen = OverlayCloseScreen;
     pScreen->CreatePixmap = OverlayCreatePixmap; 
     pScreen->DestroyPixmap = OverlayDestroyPixmap; 
     pScreen->ChangeWindowAttributes = OverlayChangeWindowAttributes; 
-    pScreen->PaintWindowBackground = OverlayPaintWindow; 
-    pScreen->PaintWindowBorder = OverlayPaintWindow; 
 
     pScreenPriv->LockPrivate = 0; 
 
@@ -402,8 +395,6 @@ OverlayCloseScreen (int i, ScreenPtr pSc
     pScreen->CreatePixmap = pScreenPriv->CreatePixmap;
     pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap;
     pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
-    pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground;
-    pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder;
 
     xfree ((pointer) pScreenPriv);
 
@@ -435,62 +426,6 @@ OverlayChangeWindowAttributes (WindowPtr
     return result;
 }
 
-static void
-OverlayPaintWindow(
-  WindowPtr pWin,
-  RegionPtr pReg,
-  int what
-){
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen);
-    OverlayPixmapPtr pixPriv;
-    PixmapPtr oldPix = NULL;
-
-    if(what == PW_BACKGROUND) {
-	if(pWin->drawable.depth == 8) {
-	   if(pWin->backgroundState == ParentRelative) {
-		do {
-		   pWin = pWin->parent;
-		} while (pWin->backgroundState == ParentRelative);
-	   }
-
-	   if(pWin->backgroundState == BackgroundPixmap) {
-		oldPix = pWin->background.pixmap;
-		pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(oldPix);
-		/* have to do this here because alot of applications
-		   incorrectly assume changes to a pixmap that is
-		   a window background go into effect immediatedly */
-		if(pixPriv->dirty & IS_DIRTY)
-		    OverlayRefreshPixmap(pWin->background.pixmap);
-		pWin->background.pixmap = pixPriv->pix32;
-	   }
-	}
-
-	pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground;
-	(*pScreen->PaintWindowBackground) (pWin, pReg, what);
-	pScreen->PaintWindowBackground = OverlayPaintWindow;
-
-	if(oldPix)
-	   pWin->background.pixmap = oldPix;
-    } else {
-	if((pWin->drawable.depth == 8) && !pWin->borderIsPixel) {
-	   oldPix = pWin->border.pixmap;
-	   pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(oldPix);
-	   if(pixPriv->dirty & IS_DIRTY)
-		OverlayRefreshPixmap(pWin->border.pixmap);
-	   pWin->border.pixmap = pixPriv->pix32;
-        }
-
-	pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder;
-	(*pScreen->PaintWindowBorder) (pWin, pReg, what);
-	pScreen->PaintWindowBorder = OverlayPaintWindow;
-
-	if(oldPix)
-	   pWin->border.pixmap = oldPix;
-    }
-}
-
-
 /*********************** GC Funcs *****************************/
 
 
diff --git a/hw/xgl/glx/xglx.c b/hw/xgl/glx/xglx.c
index 92974f0..87d8a4e 100644
--- a/hw/xgl/glx/xglx.c
+++ b/hw/xgl/glx/xglx.c
@@ -927,7 +927,7 @@ xglxWindowExposures (WindowPtr pWin,
 	REGION_SUBTRACT (pScreen, &ClipList, &pWin->borderClip,
 			 &pWin->winSize);
 	REGION_INTERSECT (pScreen, &ClipList, &ClipList, (RegionPtr) pReg);
-	(*pScreen->PaintWindowBorder) (pWin, &ClipList, PW_BORDER);
+	miPaintWindow(pWin, &ClipList, PW_BORDER);
 	REGION_UNINIT (pScreen, &ClipList);
     }
 
diff --git a/hw/xgl/xgl.h b/hw/xgl/xgl.h
index 5710bbf..7bca1d5 100644
--- a/hw/xgl/xgl.h
+++ b/hw/xgl/xgl.h
@@ -272,8 +272,6 @@ typedef struct _xglScreen {
     CreateWindowProcPtr		  CreateWindow;
     DestroyWindowProcPtr	  DestroyWindow;
     ChangeWindowAttributesProcPtr ChangeWindowAttributes;
-    PaintWindowBackgroundProcPtr  PaintWindowBackground;
-    PaintWindowBorderProcPtr	  PaintWindowBorder;
     CopyWindowProcPtr		  CopyWindow;
     CreateGCProcPtr		  CreateGC;
     CloseScreenProcPtr		  CloseScreen;
@@ -1090,16 +1088,6 @@ xglCopyWindow (WindowPtr   pWin,
 	       DDXPointRec ptOldOrg,
 	       RegionPtr   prgnSrc);
 
-void
-xglPaintWindowBackground (WindowPtr pWin,
-			  RegionPtr pRegion,
-			  int	    what);
-
-void
-xglPaintWindowBorder (WindowPtr pWin,
-		      RegionPtr pRegion,
-		      int	what);
-
 PixmapPtr
 xglGetWindowPixmap (WindowPtr pWin);
 
diff --git a/hw/xgl/xglscreen.c b/hw/xgl/xglscreen.c
index e468697..9b7297b 100644
--- a/hw/xgl/xglscreen.c
+++ b/hw/xgl/xglscreen.c
@@ -210,8 +210,6 @@ xglScreenInit (ScreenPtr pScreen)
     XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
     XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
     XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
-    XGL_SCREEN_WRAP (PaintWindowBackground, xglPaintWindowBackground);
-    XGL_SCREEN_WRAP (PaintWindowBorder, xglPaintWindowBorder);
 
     XGL_SCREEN_WRAP (CreateGC, xglCreateGC);
 
diff --git a/hw/xgl/xglwindow.c b/hw/xgl/xglwindow.c
index 967d10f..393f01d 100644
--- a/hw/xgl/xglwindow.c
+++ b/hw/xgl/xglwindow.c
@@ -141,181 +141,6 @@ xglCopyWindow (WindowPtr   pWin,
     REGION_UNINIT (pWin->drawable.pScreen, &rgnDst);
 }
 
-static Bool
-xglFillRegionSolid (DrawablePtr	pDrawable,
-		    RegionPtr	pRegion,
-		    Pixel	pixel)
-{
-    glitz_pixel_format_t format;
-    glitz_surface_t      *solid;
-    glitz_buffer_t	 *buffer;
-    BoxPtr		 pExtent;
-    Bool		 ret;
-
-    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
-    XGL_SCREEN_PRIV (pDrawable->pScreen);
-
-    if (!xglPrepareTarget (pDrawable))
-	return FALSE;
-
-    solid = glitz_surface_create (pScreenPriv->drawable,
-				  pPixmapPriv->pVisual->format.surface,
-				  1, 1, 0, NULL);
-    if (!solid)
-	return FALSE;
-
-    glitz_surface_set_fill (solid, GLITZ_FILL_REPEAT);
-
-    format.fourcc	  = GLITZ_FOURCC_RGB;
-    format.masks	  = pPixmapPriv->pVisual->pPixel->masks;
-    format.xoffset	  = 0;
-    format.skip_lines     = 0;
-    format.bytes_per_line = sizeof (CARD32);
-    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
-
-    buffer = glitz_buffer_create_for_data (&pixel);
-
-    glitz_set_pixels (solid, 0, 0, 1, 1, &format, buffer);
-
-    glitz_buffer_destroy (buffer);
-
-    pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion);
-
-    ret = xglSolid (pDrawable,
-		    GLITZ_OPERATOR_SRC,
-		    solid,
-		    NULL,
-		    pExtent->x1, pExtent->y1,
-		    pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
-		    REGION_RECTS (pRegion),
-		    REGION_NUM_RECTS (pRegion));
-
-    glitz_surface_destroy (solid);
-
-    return ret;
-}
-
-static Bool
-xglFillRegionTiled (DrawablePtr	pDrawable,
-		    RegionPtr	pRegion,
-		    PixmapPtr	pTile,
-		    int		tileX,
-		    int		tileY)
-{
-    BoxPtr pExtent;
-
-    pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion);
-
-    if (xglTile (pDrawable,
-		 GLITZ_OPERATOR_SRC,
-		 pTile,
-		 tileX, tileY,
-		 NULL,
-		 pExtent->x1, pExtent->y1,
-		 pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
-		 REGION_RECTS (pRegion),
-		 REGION_NUM_RECTS (pRegion)))
-	return TRUE;
-
-    return FALSE;
-}
-
-void
-xglPaintWindowBackground (WindowPtr pWin,
-			  RegionPtr pRegion,
-			  int	    what)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    switch (pWin->backgroundState) {
-    case None:
-	return;
-    case ParentRelative:
-	do {
-	    pWin = pWin->parent;
-	} while (pWin->backgroundState == ParentRelative);
-
-	(*pScreen->PaintWindowBackground) (pWin, pRegion, what);
-	return;
-    case BackgroundPixmap:
-	if (xglFillRegionTiled (&pWin->drawable,
-				pRegion,
-				pWin->background.pixmap,
-				-pWin->drawable.x,
-				-pWin->drawable.y))
-	{
-	    xglAddCurrentBitDamage (&pWin->drawable);
-	    return;
-	}
-
-	if (!xglSyncBits (&pWin->background.pixmap->drawable, NullBox))
-	    FatalError (XGL_SW_FAILURE_STRING);
-	break;
-    case BackgroundPixel:
-	if (xglFillRegionSolid (&pWin->drawable,
-				pRegion,
-				pWin->background.pixel))
-	{
-	    xglAddCurrentBitDamage (&pWin->drawable);
-	    return;
-	}
-	break;
-    }
-
-    XGL_WINDOW_FALLBACK_PROLOGUE (pWin, PaintWindowBackground);
-    (*pScreen->PaintWindowBackground) (pWin, pRegion, what);
-    XGL_WINDOW_FALLBACK_EPILOGUE (pWin, pRegion, PaintWindowBackground,
-				  xglPaintWindowBackground);
-}
-
-void
-xglPaintWindowBorder (WindowPtr pWin,
-		      RegionPtr pRegion,
-		      int	what)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    if (pWin->borderIsPixel)
-    {
-	if (xglFillRegionSolid (&pWin->drawable,
-				pRegion,
-				pWin->border.pixel))
-	{
-	    xglAddCurrentBitDamage (&pWin->drawable);
-	    return;
-	}
-    }
-    else
-    {
-	WindowPtr pBgWin = pWin;
-
-	while (pBgWin->backgroundState == ParentRelative)
-	    pBgWin = pBgWin->parent;
-
-	if (xglFillRegionTiled (&pBgWin->drawable,
-				pRegion,
-				pWin->border.pixmap,
-				-pBgWin->drawable.x,
-				-pBgWin->drawable.y))
-	{
-	    xglAddCurrentBitDamage (&pWin->drawable);
-	    return;
-	}
-
-	if (!xglSyncBits (&pWin->border.pixmap->drawable, NullBox))
-	    FatalError (XGL_SW_FAILURE_STRING);
-    }
-
-    XGL_WINDOW_FALLBACK_PROLOGUE (pWin, PaintWindowBorder);
-    (*pScreen->PaintWindowBorder) (pWin, pRegion, what);
-    XGL_WINDOW_FALLBACK_EPILOGUE (pWin, pRegion, PaintWindowBorder,
-				  xglPaintWindowBorder);
-}
-
 PixmapPtr
 xglGetWindowPixmap (WindowPtr pWin)
 {
diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c
index d08e482..86f856e 100644
--- a/hw/xnest/Screen.c
+++ b/hw/xnest/Screen.c
@@ -294,8 +294,6 @@ xnestOpenScreen(int index, ScreenPtr pSc
   pScreen->UnrealizeWindow = xnestUnrealizeWindow;
   pScreen->PostValidateTree = NULL;
   pScreen->WindowExposures = xnestWindowExposures;
-  pScreen->PaintWindowBackground = xnestPaintWindowBackground;
-  pScreen->PaintWindowBorder = xnestPaintWindowBorder;
   pScreen->CopyWindow = xnestCopyWindow;
   pScreen->ClipNotify = xnestClipNotify;
 
diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c
index f87a1ba..e83fb90 100644
--- a/hw/xnest/Window.c
+++ b/hw/xnest/Window.c
@@ -379,30 +379,6 @@ xnestUnrealizeWindow(WindowPtr pWin)
 }
 
 void
-xnestPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-  int i;
-  BoxPtr pBox;
-
-  xnestConfigureWindow(pWin, CWWidth | CWHeight);
-
-  pBox = REGION_RECTS(pRegion);
-  for (i = 0; i < REGION_NUM_RECTS(pRegion); i++)
-    XClearArea(xnestDisplay, xnestWindow(pWin),
-	       pBox[i].x1 - pWin->drawable.x,
-	       pBox[i].y1 - pWin->drawable.y,
-	       pBox[i].x2 - pBox[i].x1, 
-	       pBox[i].y2 - pBox[i].y1,
-	       False);
-}
-
-void
-xnestPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-  xnestConfigureWindow(pWin, CWBorderWidth);
-}
-
-void
 xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion)
 {
 }
diff --git a/hw/xnest/XNWindow.h b/hw/xnest/XNWindow.h
index 21be5f5..6c63f1f 100644
--- a/hw/xnest/XNWindow.h
+++ b/hw/xnest/XNWindow.h
@@ -64,8 +64,6 @@ void xnestConfigureWindow(WindowPtr pWin
 Bool xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
 Bool xnestRealizeWindow(WindowPtr pWin);
 Bool xnestUnrealizeWindow(WindowPtr pWin);
-void xnestPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what);
-void xnestPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what);
 void xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion);
 void xnestClipNotify(WindowPtr pWin, int dx, int dy);
 void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn,
diff --git a/hw/xprint/pcl/Pcl.h b/hw/xprint/pcl/Pcl.h
index 217e304..0c50ed2 100644
--- a/hw/xprint/pcl/Pcl.h
+++ b/hw/xprint/pcl/Pcl.h
@@ -568,10 +568,6 @@ extern void PclCopyWindow(
 extern Bool PclChangeWindowAttributes(
     register WindowPtr pWin,
     register unsigned long mask);
-extern void PclPaintWindow(
-    WindowPtr   pWin,
-    RegionPtr   pRegion,
-    int         what);
 
 /******
  * Functions in PclFonts.c
diff --git a/hw/xprint/pcl/PclInit.c b/hw/xprint/pcl/PclInit.c
index 1832252..574b481 100644
--- a/hw/xprint/pcl/PclInit.c
+++ b/hw/xprint/pcl/PclInit.c
@@ -201,8 +201,6 @@ InitializePclDriver(
     pScreen->RealizeWindow = PclMapWindow;
     pScreen->UnrealizeWindow = PclUnmapWindow;
 */
-    pScreen->PaintWindowBackground = PclPaintWindow;
-    pScreen->PaintWindowBorder = PclPaintWindow;
     pScreen->CopyWindow = PclCopyWindow; /* XXX Hard routine to write! */
 
     pScreen->CreatePixmap = fbCreatePixmap;
diff --git a/hw/xprint/pcl/PclWindow.c b/hw/xprint/pcl/PclWindow.c
index 80f4e91..f34ad7f 100644
--- a/hw/xprint/pcl/PclWindow.c
+++ b/hw/xprint/pcl/PclWindow.c
@@ -198,232 +198,6 @@ PclChangeWindowAttributes(
     return TRUE;
 }
 
-
-/*
- * This function is largely ripped from miPaintWindow, but modified so
- * that the background is not painted to the root window, and so that
- * the backing store is not referenced.
- */
-void
-PclPaintWindow(
-    WindowPtr	pWin,
-    RegionPtr	pRegion,
-    int		what)
-{
-	
-#define FUNCTION	0
-#define FOREGROUND	1
-#define TILE		2
-#define FILLSTYLE	3
-#define ABSX		4
-#define ABSY		5
-#define CLIPMASK	6
-#define SUBWINDOW	7
-#define COUNT_BITS	8
-
-    pointer gcval[7];
-    pointer newValues [COUNT_BITS];
-
-    BITS32 gcmask, index, mask;
-    RegionRec prgnWin;
-    DDXPointRec oldCorner;
-    BoxRec box;
-    WindowPtr	pBgWin;
-    GCPtr pGC;
-    register int i;
-    register BoxPtr pbox;
-    register ScreenPtr pScreen = pWin->drawable.pScreen;
-    register xRectangle *prect;
-    int numRects;
-
-    gcmask = 0;
-
-    /*
-     * We don't want to paint a window that has no place to put the
-     * PCL output.
-     */
-    if( PclGetContextFromWindow( pWin ) == (XpContextPtr)NULL )
-      return;
-    
-    if (what == PW_BACKGROUND)
-    {
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    (*pWin->parent->drawable.pScreen->PaintWindowBackground)
-	      (pWin->parent, pRegion, what);
-	    return;
-	case BackgroundPixel:
-	    newValues[FOREGROUND] = (pointer)pWin->background.pixel;
-	    newValues[FILLSTYLE] = (pointer)FillSolid;
-	    gcmask |= GCForeground | GCFillStyle;
-	    break;
-	case BackgroundPixmap:
-	    newValues[TILE] = (pointer)pWin->background.pixmap;
-	    newValues[FILLSTYLE] = (pointer)FillTiled;
-	    gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | 
-	      GCTileStipYOrigin;
-	    break;
-	}
-    }
-    else
-    {
-	if (pWin->borderIsPixel)
-	{
-	    newValues[FOREGROUND] = (pointer)pWin->border.pixel;
-	    newValues[FILLSTYLE] = (pointer)FillSolid;
-	    gcmask |= GCForeground | GCFillStyle;
-	}
-	else
-	{
-	    newValues[TILE] = (pointer)pWin->border.pixmap;
-	    newValues[FILLSTYLE] = (pointer)FillTiled;
-	    gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin
-	      | GCTileStipYOrigin;
-	}
-    }
-
-    prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(pRegion) *
-					 sizeof(xRectangle));
-    if (!prect)
-	return;
-
-    newValues[FUNCTION] = (pointer)GXcopy;
-    gcmask |= GCFunction | GCClipMask;
-
-    i = pScreen->myNum;
-
-    pBgWin = pWin;
-    if (what == PW_BORDER)
-    {
-	while (pBgWin->backgroundState == ParentRelative)
-	    pBgWin = pBgWin->parent;
-    }
-
-    pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
-    if (!pGC)
-      {
-	  DEALLOCATE_LOCAL(prect);
-	  return;
-      }
-    /*
-     * mash the clip list so we can paint the border by
-     * mangling the window in place, pretending it
-     * spans the entire screen
-     */
-    if (what == PW_BORDER)
-      {
-	  prgnWin = pWin->clipList;
-	  oldCorner.x = pWin->drawable.x;
-	  oldCorner.y = pWin->drawable.y;
-	  pWin->drawable.x = pWin->drawable.y = 0;
-	  box.x1 = 0;
-	  box.y1 = 0;
-	  box.x2 = pScreen->width;
-	  box.y2 = pScreen->height;
-	  REGION_INIT(pScreen, &pWin->clipList, &box, 1);
-	  pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-	  newValues[ABSX] = (pointer)(long)pBgWin->drawable.x;
-	  newValues[ABSY] = (pointer)(long)pBgWin->drawable.y;
-      }
-    else
-      {
-	  newValues[ABSX] = (pointer)0;
-	  newValues[ABSY] = (pointer)0;
-      }
-
-    mask = gcmask;
-    gcmask = 0;
-    i = 0;
-    while (mask) {
-    	index = lowbit (mask);
-	mask &= ~index;
-	switch (index) {
-	case GCFunction:
-	    if ((pointer)(long) pGC->alu != newValues[FUNCTION]) {
-		gcmask |= index;
-		gcval[i++] = newValues[FUNCTION];
-	    }
-	    break;
-	case GCTileStipXOrigin:
-	    if ((pointer)(long) pGC->patOrg.x != newValues[ABSX]) {
-		gcmask |= index;
-		gcval[i++] = newValues[ABSX];
-	    }
-	    break;
-	case GCTileStipYOrigin:
-	    if ((pointer)(long) pGC->patOrg.y != newValues[ABSY]) {
-		gcmask |= index;
-		gcval[i++] = newValues[ABSY];
-	    }
-	    break;
-	case GCClipMask:
-	    if ((pointer)(long) pGC->clientClipType != (pointer)CT_NONE) {
-		gcmask |= index;
-		gcval[i++] = (pointer)CT_NONE;
-	    }
-	    break;
-	case GCSubwindowMode:
-	    if ((pointer)(long) pGC->subWindowMode != newValues[SUBWINDOW]) {
-		gcmask |= index;
-		gcval[i++] = newValues[SUBWINDOW];
-	    }
-	    break;
-	case GCTile:
-	    if (pGC->tileIsPixel || 
-		(pointer) pGC->tile.pixmap != newValues[TILE])
- 	    {
-		gcmask |= index;
-		gcval[i++] = newValues[TILE];
-	    }
-	    break;
-	case GCFillStyle:
-	    if ((pointer)(long) pGC->fillStyle != newValues[FILLSTYLE]) {
-		gcmask |= index;
-		gcval[i++] = newValues[FILLSTYLE];
-	    }
-	    break;
-	case GCForeground:
-	    if ((pointer) pGC->fgPixel != newValues[FOREGROUND]) {
-		gcmask |= index;
-		gcval[i++] = newValues[FOREGROUND];
-	    }
-	    break;
-	}
-    }
-
-    if (gcmask)
-        DoChangeGC(pGC, gcmask, (XID *)gcval, 1);
-
-    if (pWin->drawable.serialNumber != pGC->serialNumber)
-	ValidateGC((DrawablePtr)pWin, pGC);
-
-    numRects = REGION_NUM_RECTS(pRegion);
-    pbox = REGION_RECTS(pRegion);
-    for (i= numRects; --i >= 0; pbox++, prect++)
-    {
-	prect->x = pbox->x1 - pWin->drawable.x;
-	prect->y = pbox->y1 - pWin->drawable.y;
-	prect->width = pbox->x2 - pbox->x1;
-	prect->height = pbox->y2 - pbox->y1;
-    }
-    prect -= numRects;
-    (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
-    DEALLOCATE_LOCAL(prect);
-
-    if (what == PW_BORDER)
-      {
-	  REGION_UNINIT(pScreen, &pWin->clipList);
-	  pWin->clipList = prgnWin;
-	  pWin->drawable.x = oldCorner.x;
-	  pWin->drawable.y = oldCorner.y;
-	  pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-      }
-    FreeScratchGC(pGC);
-
-}
-
 /*ARGSUSED*/
 Bool
 PclDestroyWindow(
diff --git a/hw/xprint/pcl/Pclmap.h b/hw/xprint/pcl/Pclmap.h
index ae88b5a..3990ab2 100644
--- a/hw/xprint/pcl/Pclmap.h
+++ b/hw/xprint/pcl/Pclmap.h
@@ -105,7 +105,6 @@ copyright holders.
 #define PclUnmapWindow			PCLNAME(UnmapWindow)
 #define PclCopyWindow			PCLNAME(CopyWindow)
 #define PclChangeWindowAttributes	PCLNAME(ChangeWindowAttributes)
-#define PclPaintWindow			PCLNAME(PaintWindow)
 #define PclDestroyWindow		PCLNAME(DestroyWindow)
 
 /* PclGC.c */
diff --git a/hw/xprint/ps/Ps.h b/hw/xprint/ps/Ps.h
index 3adad39..25bd533 100644
--- a/hw/xprint/ps/Ps.h
+++ b/hw/xprint/ps/Ps.h
@@ -517,7 +517,6 @@ extern Bool PsUnmapWindow(WindowPtr pWin
 extern void PsCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
                          RegionPtr prgnSrc);
 extern Bool PsChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
-extern void PsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
 extern Bool PsDestroyWindow(WindowPtr pWin);
 
 /*
diff --git a/hw/xprint/ps/PsInit.c b/hw/xprint/ps/PsInit.c
index 639908f..6d4bd06 100644
--- a/hw/xprint/ps/PsInit.c
+++ b/hw/xprint/ps/PsInit.c
@@ -169,8 +169,6 @@ InitializePsDriver(ndx, pScreen, argc, a
   pScreen->ChangeWindowAttributes = PsChangeWindowAttributes;
   pScreen->RealizeWindow          = PsMapWindow;
   pScreen->UnrealizeWindow        = PsUnmapWindow;
-  pScreen->PaintWindowBackground  = PsPaintWindow;
-  pScreen->PaintWindowBorder      = PsPaintWindow;
   pScreen->CloseScreen            = PsCloseScreen;
   pScreen->CopyWindow             = PsCopyWindow;
        /* XXX Hard routine to write! */
diff --git a/hw/xprint/ps/PsWindow.c b/hw/xprint/ps/PsWindow.c
index 26075a8..ded7dd6 100644
--- a/hw/xprint/ps/PsWindow.c
+++ b/hw/xprint/ps/PsWindow.c
@@ -213,230 +213,6 @@ PsChangeWindowAttributes(
   return TRUE;
 }
 
-
-void
-PsPaintWindow(
-  WindowPtr pWin,
-  RegionPtr pRegion,
-  int       what)
-{
-  WindowPtr pRoot;
-
-#define FUNCTION        0
-#define FOREGROUND      1
-#define TILE            2
-#define FILLSTYLE       3
-#define ABSX            4
-#define ABSY            5
-#define CLIPMASK        6
-#define SUBWINDOW       7
-#define COUNT_BITS      8
-
-  pointer              gcval[7];
-  pointer              newValues [COUNT_BITS];
-
-  BITS32               gcmask, index, mask;
-  RegionRec            prgnWin;
-  DDXPointRec          oldCorner;
-  BoxRec               box;
-  WindowPtr            pBgWin;
-  GCPtr                pGC;
-  register int         i;
-  register BoxPtr      pbox;
-  register ScreenPtr   pScreen = pWin->drawable.pScreen;
-  register xRectangle *prect;
-  int                  numRects;
-
-  gcmask = 0;
-
-  /*
-   * We don't want to paint a window that has no place to put the
-   * PS output.
-   */
-  if( PsGetContextFromWindow(pWin)==(XpContextPtr)NULL ) return;
-
-  if( what==PW_BACKGROUND )
-  {
-    switch(pWin->backgroundState)
-    {
-      case None: return;
-      case ParentRelative:
-        (*pWin->parent->drawable.pScreen->PaintWindowBackground)
-          (pWin->parent, pRegion, what);
-        return;
-      case BackgroundPixel:
-        newValues[FOREGROUND] = (pointer)pWin->background.pixel;
-        newValues[FILLSTYLE] = (pointer)FillSolid;
-        gcmask |= GCForeground | GCFillStyle;
-        break;
-      case BackgroundPixmap:
-        newValues[TILE] = (pointer)pWin->background.pixmap;
-        newValues[FILLSTYLE] = (pointer)FillTiled;
-        gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
-        break;
-    }
-  }
-  else
-  {
-    if( pWin->borderIsPixel )
-    {
-      newValues[FOREGROUND] = (pointer)pWin->border.pixel;
-      newValues[FILLSTYLE] = (pointer)FillSolid;
-      gcmask |= GCForeground | GCFillStyle;
-    }
-    else
-    {
-      newValues[TILE] = (pointer)pWin->border.pixmap;
-      newValues[FILLSTYLE] = (pointer)FillTiled;
-      gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
-    }
-  }
-
-  prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(pRegion) *
-                                         sizeof(xRectangle));
-  if( !prect ) return;
-
-  newValues[FUNCTION] = (pointer)GXcopy;
-  gcmask |= GCFunction | GCClipMask;
-
-  i = pScreen->myNum;
-  pRoot = WindowTable[i];
-
-  pBgWin = pWin;
-  if (what == PW_BORDER)
-  {
-    while( pBgWin->backgroundState==ParentRelative ) pBgWin = pBgWin->parent;
-  }
-
-  pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
-  if( !pGC )
-  {
-    DEALLOCATE_LOCAL(prect);
-    return;
-  }
-  /*
-   * mash the clip list so we can paint the border by
-   * mangling the window in place, pretending it
-   * spans the entire screen
-   */
-  if( what==PW_BORDER )
-  {
-    prgnWin = pWin->clipList;
-    oldCorner.x = pWin->drawable.x;
-    oldCorner.y = pWin->drawable.y;
-    pWin->drawable.x = pWin->drawable.y = 0;
-    box.x1 = 0;
-    box.y1 = 0;
-    box.x2 = pScreen->width;
-    box.y2 = pScreen->height;
-    REGION_INIT(pScreen, &pWin->clipList, &box, 1);
-    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-    newValues[ABSX] = (pointer)(long)pBgWin->drawable.x;
-    newValues[ABSY] = (pointer)(long)pBgWin->drawable.y;
-  }
-  else
-  {
-    newValues[ABSX] = (pointer)0;
-    newValues[ABSY] = (pointer)0;
-  }
-
-  mask = gcmask;
-  gcmask = 0;
-  i = 0;
-  while( mask )
-  {
-    index = lowbit (mask);
-    mask &= ~index;
-    switch(index)
-    {
-      case GCFunction:
-        if( (pointer)(long)pGC->alu!=newValues[FUNCTION] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[FUNCTION];
-        }
-        break;
-      case GCTileStipXOrigin:
-        if( (pointer)(long)pGC->patOrg.x!=newValues[ABSX] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[ABSX];
-        }
-        break;
-      case GCTileStipYOrigin:
-        if( (pointer)(long)pGC->patOrg.y!=newValues[ABSY] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[ABSY];
-        }
-        break;
-      case GCClipMask:
-        if( (pointer)pGC->clientClipType!=(pointer)CT_NONE )
-        {
-          gcmask |= index;
-          gcval[i++] = (pointer)CT_NONE;
-        }
-        break;
-      case GCSubwindowMode:
-        if( (pointer)pGC->subWindowMode!=newValues[SUBWINDOW] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[SUBWINDOW];
-        }
-        break;
-      case GCTile:
-        if( pGC->tileIsPixel || (pointer)pGC->tile.pixmap!=newValues[TILE] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[TILE];
-        }
-        break;
-      case GCFillStyle:
-        if( (pointer)pGC->fillStyle!=newValues[FILLSTYLE] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[FILLSTYLE];
-        }
-        break;
-      case GCForeground:
-        if( (pointer)pGC->fgPixel!=newValues[FOREGROUND] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[FOREGROUND];
-        }
-        break;
-    }
-  }
-
-  if( gcmask ) DoChangeGC(pGC, gcmask, (XID *)gcval, 1);
-
-  if( pWin->drawable.serialNumber!=pGC->serialNumber )
-    ValidateGC((DrawablePtr)pWin, pGC);
-
-  numRects = REGION_NUM_RECTS(pRegion);
-  pbox = REGION_RECTS(pRegion);
-  for( i=numRects ; --i >= 0 ; pbox++,prect++ )
-  {
-    prect->x = pbox->x1 - pWin->drawable.x;
-    prect->y = pbox->y1 - pWin->drawable.y;
-    prect->width = pbox->x2 - pbox->x1;
-    prect->height = pbox->y2 - pbox->y1;
-  }
-  prect -= numRects;
-  (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
-  DEALLOCATE_LOCAL(prect);
-
-  if( what==PW_BORDER )
-  {
-    REGION_UNINIT(pScreen, &pWin->clipList);
-    pWin->clipList = prgnWin;
-    pWin->drawable.x = oldCorner.x;
-    pWin->drawable.y = oldCorner.y;
-    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-  }
-  FreeScratchGC(pGC);
-}
-
 /*ARGSUSED*/
 Bool
 PsDestroyWindow(WindowPtr pWin)
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 09a9fb2..d3be39b 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -579,8 +579,6 @@ typedef struct _winPrivScreenRec
   ValidateTreeProcPtr			ValidateTree;
   PostValidateTreeProcPtr		PostValidateTree;
   WindowExposuresProcPtr		WindowExposures;
-  PaintWindowBackgroundProcPtr		PaintWindowBackground;
-  PaintWindowBorderProcPtr		PaintWindowBorder;
   CopyWindowProcPtr			CopyWindow;
   ClearToBackgroundProcPtr		ClearToBackground;
   ClipNotifyProcPtr			ClipNotify;
@@ -1052,17 +1050,6 @@ winModifyPixmapHeaderNativeGDI (PixmapPt
 				pointer pPixData);
 #endif
 
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winpntwin.c
- */
-
-void
-winPaintWindowNativeGDI (WindowPtr pWin, RegionPtr pRegion, int what);
-#endif
-
-
 #ifdef XWIN_NATIVEGDI
 /*
  * winpolyline.c
diff --git a/hw/xwin/winpntwin.c b/hw/xwin/winpntwin.c
deleted file mode 100644
index caee712..0000000
--- a/hw/xwin/winpntwin.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *Copyright (C) 2001-2004 Harold L Hunt II 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, 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. IN NO EVENT SHALL HAROLD L HUNT II 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 Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors:	Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/* See Porting Layer Definition - p. 39
- * Sometimes implemented as two functions:
- *  PaintWindowBackground (nKind = PW_BACKGROUND)
- *  PaintWindowBorder (nKind = PW_BORDER)
- */
-void
-winPaintWindowNativeGDI (WindowPtr pWin,
-			 RegionPtr pRegion,
-			 int nKind)
-{
-  ErrorF ("winPaintWindow()\n");
-}
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index 52adba8..a49f68f 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -717,8 +717,6 @@ winFinishScreenInitNativeGDI (int index,
   pScreen->UnrealizeWindow = winUnmapWindowNativeGDI;
 
   /* Paint window */
-  pScreen->PaintWindowBackground = miPaintWindow;
-  pScreen->PaintWindowBorder = miPaintWindow;
   pScreen->CopyWindow = winCopyWindowNativeGDI;
 
   /* Fonts */
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 110f4dc..bcec02e 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -477,8 +477,8 @@ typedef struct _Screen {
     ValidateTreeProcPtr		ValidateTree;
     PostValidateTreeProcPtr	PostValidateTree;
     WindowExposuresProcPtr	WindowExposures;
-    PaintWindowBackgroundProcPtr PaintWindowBackground;
-    PaintWindowBorderProcPtr	PaintWindowBorder;
+    PaintWindowBackgroundProcPtr PaintWindowBackground; /** unused */
+    PaintWindowBorderProcPtr	PaintWindowBorder; /** unused */
     CopyWindowProcPtr		CopyWindow;
     ClearToBackgroundProcPtr	ClearToBackground;
     ClipNotifyProcPtr		ClipNotify;
diff --git a/mfb/Makefile.am b/mfb/Makefile.am
index 8ff0260..274a32d 100644
--- a/mfb/Makefile.am
+++ b/mfb/Makefile.am
@@ -12,7 +12,7 @@ libmfb_gen_sources = mfbseg.c mfbpgbwht.
 DISTCLEANFILES = $(libmfb_gen_sources)
 
 libmfb_la_SOURCES = mfbgc.c mfbwindow.c mfbfont.c \
-	 mfbfillrct.c mfbpntwin.c maskbits.c mfbpixmap.c \
+	 mfbfillrct.c maskbits.c mfbpixmap.c \
 	 mfbimage.c mfbline.c mfbbres.c mfbhrzvert.c mfbbresd.c \
 	 mfbpushpxl.c mfbzerarc.c mfbfillarc.c \
          mfbfillsp.c mfbsetsp.c mfbscrinit.c mfbscrclse.c mfbclip.c \
diff --git a/mfb/mfb.h b/mfb/mfb.h
index bc07f02..69d2d69 100644
--- a/mfb/mfb.h
+++ b/mfb/mfb.h
@@ -649,13 +649,6 @@ extern void mfbFillPolyWhite(
     int /*count*/,
     DDXPointPtr /*ptsIn*/
 );
-/* mfbpntwin.c */
-
-extern void mfbPaintWindow(
-    WindowPtr /*pWin*/,
-    RegionPtr /*pRegion*/,
-    int /*what*/
-);
 /* mfbpolypnt.c */
 
 extern void mfbPolyPoint(
@@ -704,7 +697,6 @@ extern Bool mfbCloseScreen(
 
 extern Bool mfbAllocatePrivates(
     ScreenPtr /*pScreen*/,
-    int * /*pWinIndex*/,
     int * /*pGCIndex*/
 );
 
@@ -893,24 +885,12 @@ typedef mfbPrivGC	*mfbPrivGCPtr;
 /* XXX these should be static, but it breaks the ABI */
 extern int  mfbGCPrivateIndex;		/* index into GC private array */
 extern int  mfbGetGCPrivateIndex(void);
-extern int  mfbWindowPrivateIndex;	/* index into Window private array */
-extern int  mfbGetWindowPrivateIndex(void);
 #ifdef PIXMAP_PER_WINDOW
 extern int  frameWindowPrivateIndex;	/* index into Window private array */
 extern int  frameGetWindowPrivateIndex(void);
 #endif
 
 #ifndef MFB_PROTOTYPES_ONLY
-/* private field of window */
-typedef struct {
-    unsigned char fastBorder;	/* non-zero if border tile is 32 bits wide */
-    unsigned char fastBackground;
-    unsigned short unused; /* pad for alignment with Sun compiler */
-    DDXPointRec	oldRotate;
-    PixmapPtr	pRotatedBackground;
-    PixmapPtr	pRotatedBorder;
-    } mfbPrivWin;
-
 /* Common macros for extracting drawing information */
 
 #define mfbGetTypedWidth(pDrawable,wtype) (\
diff --git a/mfb/mfbpntwin.c b/mfb/mfbpntwin.c
deleted file mode 100644
index b18797a..0000000
--- a/mfb/mfbpntwin.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
-/***********************************************************
-
-Copyright 1987, 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.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        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 notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL 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 <X11/X.h>
-
-#include "windowstr.h"
-#include "regionstr.h"
-#include "pixmapstr.h"
-#include "scrnintstr.h"
-
-#include "mfb.h"
-#include "maskbits.h"
-#include "mi.h"
-
-void
-mfbPaintWindow(pWin, pRegion, what)
-    WindowPtr	pWin;
-    RegionPtr	pRegion;
-    int		what;
-{
-    register mfbPrivWin	*pPrivWin;
-
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-    
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixmap:
-	    if (pPrivWin->fastBackground)
-	    {
-		mfbTileAreaPPWCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXcopy,
-				  pPrivWin->pRotatedBackground);
-		return;
-	    }
-	    break;
-	case BackgroundPixel:
-	    if (pWin->background.pixel & 1)
-		mfbSolidWhiteArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXset, NullPixmap);
-	    else
-		mfbSolidBlackArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXclear, NullPixmap);
-	    return;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    if (pWin->border.pixel & 1)
-		mfbSolidWhiteArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXset, NullPixmap);
-	    else
-		mfbSolidBlackArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXclear, NullPixmap);
-	    return;
-	}
-	else if (pPrivWin->fastBorder)
-	{
-	    mfbTileAreaPPWCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXcopy,
-				  pPrivWin->pRotatedBorder);
-	    return;
-	}
-	break;
-    }
-    miPaintWindow(pWin, pRegion, what);
-}
diff --git a/mfb/mfbscrinit.c b/mfb/mfbscrinit.c
index 13ea5d3..6d364b7 100644
--- a/mfb/mfbscrinit.c
+++ b/mfb/mfbscrinit.c
@@ -71,8 +71,6 @@ SOFTWARE.
 int frameWindowPrivateIndex;
 int frameGetWindowPrivateIndex(void) { return frameWindowPrivateIndex; }
 #endif
-int mfbWindowPrivateIndex;
-int mfbGetWindowPrivateIndex(void) { return mfbWindowPrivateIndex; }
 int mfbGCPrivateIndex;
 int mfbGetGCPrivateIndex(void) { return mfbGCPrivateIndex; }
 static unsigned long mfbGeneration = 0;
@@ -90,30 +88,23 @@ static DepthRec depth = {
 };
 
 Bool
-mfbAllocatePrivates(pScreen, pWinIndex, pGCIndex)
-    ScreenPtr pScreen;
-    int *pWinIndex, *pGCIndex;
+mfbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
 {
     if (mfbGeneration != serverGeneration)
     {
 #ifdef PIXMAP_PER_WINDOW
 	frameWindowPrivateIndex = AllocateWindowPrivateIndex();
 #endif
-	mfbWindowPrivateIndex = AllocateWindowPrivateIndex();
 	mfbGCPrivateIndex = miAllocateGCPrivateIndex();
 	visual.vid = FakeClientID(0);
 	VID = visual.vid;
 	mfbGeneration = serverGeneration;
     }
-    if (pWinIndex)
-	*pWinIndex = mfbWindowPrivateIndex;
     if (pGCIndex)
 	*pGCIndex = mfbGCPrivateIndex;
     pScreen->GetWindowPixmap = mfbGetWindowPixmap;
     pScreen->SetWindowPixmap = mfbSetWindowPixmap;
-    return (AllocateWindowPrivate(pScreen, mfbWindowPrivateIndex,
-				  sizeof(mfbPrivWin)) &&
-	    AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC)));
+    return AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC));
 }
 
 
@@ -126,7 +117,7 @@ mfbScreenInit(pScreen, pbits, xsize, ysi
     int dpix, dpiy;		/* dots per inch */
     int width;			/* pixel width of frame buffer */
 {
-    if 	(!mfbAllocatePrivates(pScreen, (int *)NULL, (int *)NULL))
+    if (!mfbAllocatePrivates(pScreen, NULL))
 	return FALSE;
     pScreen->defColormap = (Colormap) FakeClientID(0);
     /* whitePixel, blackPixel */
@@ -135,13 +126,9 @@ mfbScreenInit(pScreen, pbits, xsize, ysi
     pScreen->GetImage = mfbGetImage;
     pScreen->GetSpans = mfbGetSpans;
     pScreen->CreateWindow = mfbCreateWindow;
-    pScreen->DestroyWindow = mfbDestroyWindow;
     pScreen->PositionWindow = mfbPositionWindow;
-    pScreen->ChangeWindowAttributes = mfbChangeWindowAttributes;
     pScreen->RealizeWindow = mfbMapWindow;
     pScreen->UnrealizeWindow = mfbUnmapWindow;
-    pScreen->PaintWindowBackground = mfbPaintWindow;
-    pScreen->PaintWindowBorder = mfbPaintWindow;
     pScreen->CopyWindow = mfbCopyWindow;
     pScreen->CreatePixmap = mfbCreatePixmap;
     pScreen->DestroyPixmap = mfbDestroyPixmap;
diff --git a/mfb/mfbwindow.c b/mfb/mfbwindow.c
index b138d58..4cbf59f 100644
--- a/mfb/mfbwindow.c
+++ b/mfb/mfbwindow.c
@@ -64,31 +64,14 @@ Bool
 mfbCreateWindow(pWin)
     register WindowPtr pWin;
 {
-    register mfbPrivWin *pPrivWin;
-
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-    pPrivWin->pRotatedBorder = NullPixmap;
-    pPrivWin->pRotatedBackground = NullPixmap;
-    pPrivWin->fastBackground = FALSE;
-    pPrivWin->fastBorder = FALSE;
-
     return (TRUE);
 }
 
 /* This always returns true, because Xfree can't fail.  It might be possible
  * on some devices for Destroy to fail */
 Bool 
-mfbDestroyWindow(pWin)
-    WindowPtr pWin;
+mfbDestroyWindow(WindowPtr pWin)
 {
-    register mfbPrivWin *pPrivWin;
-
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-
-    if (pPrivWin->pRotatedBorder)
-	(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
-    if (pPrivWin->pRotatedBackground)
-	(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
     return (TRUE);
 }
 
@@ -113,35 +96,6 @@ mfbPositionWindow(pWin, x, y)
     register WindowPtr pWin;
     int x, y;
 {
-    register mfbPrivWin *pPrivWin;
-    int	reset = 0;
-
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-    if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
-    {
-	mfbXRotatePixmap(pPrivWin->pRotatedBackground,
-			 pWin->drawable.x - pPrivWin->oldRotate.x);
-	mfbYRotatePixmap(pPrivWin->pRotatedBackground,
-			 pWin->drawable.y - pPrivWin->oldRotate.y);
-	reset = 1;
-    }
-
-    if (!pWin->borderIsPixel && pPrivWin->fastBorder)
-    {
-	while (pWin->backgroundState == ParentRelative)
-	    pWin = pWin->parent;
-	mfbXRotatePixmap(pPrivWin->pRotatedBorder,
-			 pWin->drawable.x - pPrivWin->oldRotate.x);
-	mfbYRotatePixmap(pPrivWin->pRotatedBorder,
-			 pWin->drawable.y - pPrivWin->oldRotate.y);
-	reset = 1;
-    }
-    if (reset)
-    {
-	pPrivWin->oldRotate.x = pWin->drawable.x;
-	pPrivWin->oldRotate.y = pWin->drawable.y;
-    }
-
     /* This is the "wrong" fix to the right problem, but it doesn't really
      * cost very much.  When the window is moved, we need to invalidate any
      * RotatedPixmap that exists in any GC currently validated against this
@@ -211,131 +165,3 @@ mfbCopyWindow(pWin, ptOldOrg, prgnSrc)
     DEALLOCATE_LOCAL(pptSrc);
     REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
 }
-
-
-
-/* swap in correct PaintWindow* routine.  If we can use a fast output
-routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
-of it in devPrivate.
-*/
-Bool
-mfbChangeWindowAttributes(pWin, mask)
-    register WindowPtr pWin;
-    register unsigned long mask;
-{
-    register unsigned long index;
-    register mfbPrivWin *pPrivWin;
-    WindowPtr	pBgWin;
-
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-    /*
-     * When background state changes from ParentRelative and
-     * we had previously rotated the fast border pixmap to match
-     * the parent relative origin, rerotate to match window
-     */
-    if (mask & (CWBackPixmap | CWBackPixel) &&
-	pWin->backgroundState != ParentRelative &&
-	pPrivWin->fastBorder &&
-	(pPrivWin->oldRotate.x != pWin->drawable.x ||
-	 pPrivWin->oldRotate.y != pWin->drawable.y))
-    {
-	mfbXRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.x - pPrivWin->oldRotate.x);
-	mfbYRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.y - pPrivWin->oldRotate.y);
-	pPrivWin->oldRotate.x = pWin->drawable.x;
-	pPrivWin->oldRotate.y = pWin->drawable.y;
-    }
-    while(mask)
-    {
-	index = lowbit (mask);
-	mask &= ~index;
-	switch(index)
-	{
-	  case CWBackPixmap:
-	      if (pWin->backgroundState == None)
-	      {
-		  pPrivWin->fastBackground = FALSE;
-	      }
-	      else if (pWin->backgroundState == ParentRelative)
-	      {
-		  pPrivWin->fastBackground = FALSE;
-		  /* Rotate border to match parent origin */
-		  if (pPrivWin->pRotatedBorder) {
-		      for (pBgWin = pWin->parent;
-			   pBgWin->backgroundState == ParentRelative;
-			   pBgWin = pBgWin->parent);
-		      mfbXRotatePixmap(pPrivWin->pRotatedBorder,
-				    pBgWin->drawable.x - pPrivWin->oldRotate.x);
-		      mfbYRotatePixmap(pPrivWin->pRotatedBorder,
-				    pBgWin->drawable.y - pPrivWin->oldRotate.y);
-		      pPrivWin->oldRotate.x = pBgWin->drawable.x;
-		      pPrivWin->oldRotate.y = pBgWin->drawable.y;
-		  }
-	      }
-	      else if ((pWin->background.pixmap->drawable.width <= PPW) &&
-		       !(pWin->background.pixmap->drawable.width &
-			 (pWin->background.pixmap->drawable.width - 1)))
-	      {
-		  mfbCopyRotatePixmap(pWin->background.pixmap,
-				      &pPrivWin->pRotatedBackground,
-				      pWin->drawable.x,
-				      pWin->drawable.y);
-		  if (pPrivWin->pRotatedBackground)
-		  {
-		      pPrivWin->fastBackground = TRUE;
-		      pPrivWin->oldRotate.x = pWin->drawable.x;
-		      pPrivWin->oldRotate.y = pWin->drawable.y;
-		  }
-		  else
-		  {
-		      pPrivWin->fastBackground = FALSE;
-		  }
-	      }
-	      else
-	      {
-		  pPrivWin->fastBackground = FALSE;
-	      }
-	      break;
-
-	  case CWBackPixel:
-	      pPrivWin->fastBackground = FALSE;
-	      break;
-
-	  case CWBorderPixmap:
-	      if ((pWin->border.pixmap->drawable.width <= PPW) &&
-		  !(pWin->border.pixmap->drawable.width &
-		    (pWin->border.pixmap->drawable.width - 1)))
-	      {
-		  for (pBgWin = pWin;
-		       pBgWin->backgroundState == ParentRelative;
-		       pBgWin = pBgWin->parent);
-		  mfbCopyRotatePixmap(pWin->border.pixmap,
-				      &pPrivWin->pRotatedBorder,
-				      pBgWin->drawable.x,
-				      pBgWin->drawable.y);
-		  if (pPrivWin->pRotatedBorder)
-		  {
-		      pPrivWin->fastBorder = TRUE;
-		      pPrivWin->oldRotate.x = pBgWin->drawable.x;
-		      pPrivWin->oldRotate.y = pBgWin->drawable.y;
-		  }
-		  else
-		  {
-		      pPrivWin->fastBorder = FALSE;
-		  }
-	      }
-	      else
-	      {
-		  pPrivWin->fastBorder = FALSE;
-	      }
-	      break;
-	    case CWBorderPixel:
-	      pPrivWin->fastBorder = FALSE;
-	      break;
-	}
-    }
-    /* Again, we have no failure modes indicated by any of the routines
-     * we've called, so we have to assume it worked */
-    return (TRUE);
-}
diff --git a/mi/mibank.c b/mi/mibank.c
index 00638a4..3492f1e 100644
--- a/mi/mibank.c
+++ b/mi/mibank.c
@@ -121,8 +121,6 @@ typedef struct _miBankScreen
     GetImageProcPtr               GetImage;
     GetSpansProcPtr               GetSpans;
     CreateGCProcPtr               CreateGC;
-    PaintWindowBackgroundProcPtr  PaintWindowBackground;
-    PaintWindowBorderProcPtr      PaintWindowBorder;
     CopyWindowProcPtr             CopyWindow;
 } miBankScreenRec, *miBankScreenPtr;
 
@@ -1712,8 +1710,6 @@ miBankCloseScreen(
     SCREEN_UNWRAP(GetImage);
     SCREEN_UNWRAP(GetSpans);
     SCREEN_UNWRAP(CreateGC);
-    SCREEN_UNWRAP(PaintWindowBackground);
-    SCREEN_UNWRAP(PaintWindowBorder);
     SCREEN_UNWRAP(CopyWindow);
 
     Xfree(pScreenPriv);
@@ -1878,71 +1874,6 @@ miBankCreateGC(
 }
 
 static void
-miBankPaintWindow(
-    WindowPtr pWin,
-    RegionPtr pRegion,
-    int       what
-)
-{
-    ScreenPtr          pScreen = pWin->drawable.pScreen;
-    RegionRec          tmpReg;
-    int                i;
-    PaintWindowProcPtr PaintWindow;
-
-    SCREEN_INIT;
-    SCREEN_SAVE;
-
-    if (what == PW_BORDER)
-    {
-        SCREEN_UNWRAP(PaintWindowBorder);
-        PaintWindow = pScreen->PaintWindowBorder;
-    }
-    else
-    {
-        SCREEN_UNWRAP(PaintWindowBackground);
-        PaintWindow = pScreen->PaintWindowBackground;
-    }
-
-    if (!IS_BANKED(pWin))
-    {
-        (*PaintWindow)(pWin, pRegion, what);
-    }
-    else
-    {
-        REGION_NULL(pScreen, &tmpReg);
-
-        for (i = 0;  i < pScreenPriv->nBanks;  i++)
-        {
-            if (!pScreenPriv->pBanks[i])
-                continue;
-
-            REGION_INTERSECT(pScreen, &tmpReg, pRegion,
-                pScreenPriv->pBanks[i]);
-
-            if (REGION_NIL(&tmpReg))
-                continue;
-
-            SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, i);
-
-            (*PaintWindow)(pWin, &tmpReg, what);
-        }
-
-        REGION_UNINIT(pScreen, &tmpReg);
-    }
-
-    if (what == PW_BORDER)
-    {
-        SCREEN_WRAP(PaintWindowBorder, miBankPaintWindow);
-    }
-    else
-    {
-        SCREEN_WRAP(PaintWindowBackground, miBankPaintWindow);
-    }
-
-    SCREEN_RESTORE;
-}
-
-static void
 miBankCopyWindow(
     WindowPtr   pWindow,
     DDXPointRec ptOldOrg,
@@ -2269,8 +2200,6 @@ miInitializeBanking(
     SCREEN_WRAP(GetImage,              miBankGetImage);
     SCREEN_WRAP(GetSpans,              miBankGetSpans);
     SCREEN_WRAP(CreateGC,              miBankCreateGC);
-    SCREEN_WRAP(PaintWindowBackground, miBankPaintWindow);
-    SCREEN_WRAP(PaintWindowBorder,     miBankPaintWindow);
     SCREEN_WRAP(CopyWindow,            miBankCopyWindow);
 
     BANK_SCRPRIVLVAL = (pointer)pScreenPriv;
diff --git a/mi/miexpose.c b/mi/miexpose.c
index e82a0b5..03d4c27 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -307,8 +307,7 @@ miHandleExposures(pSrcDrawable, pDstDraw
 	    /* PaintWindowBackground doesn't clip, so we have to */
 	    REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, &pWin->clipList);
 	}
-	(*pWin->drawable.pScreen->PaintWindowBackground)(
-			(WindowPtr)pDstDrawable, &rgnExposed, PW_BACKGROUND);
+	miPaintWindow((WindowPtr)pDstDrawable, &rgnExposed, PW_BACKGROUND);
 
 	if (extents)
 	{
@@ -517,7 +516,7 @@ miWindowExposures(pWin, prgn, other_expo
 	    REGION_INTERSECT( pWin->drawable.pScreen, prgn, prgn, &pWin->clipList);
 	}
 	if (prgn && !REGION_NIL(prgn))
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, PW_BACKGROUND);
+	    miPaintWindow(pWin, prgn, PW_BACKGROUND);
 	if (clientInterested && exposures && !REGION_NIL(exposures))
 	    miSendExposures(pWin, exposures,
 			    pWin->drawable.x, pWin->drawable.y);
@@ -534,60 +533,13 @@ miWindowExposures(pWin, prgn, other_expo
 	REGION_DESTROY( pWin->drawable.pScreen, exposures);
 }
 
-
-/*
-    this code is highly unlikely.  it is not haile selassie.
-
-    there is some hair here.  we can't just use the window's
-clip region as it is, because if we are painting the border,
-the border is not in the client area and so we will be excluded
-when we validate the GC, and if we are painting a parent-relative
-background, the area we want to paint is in some other window.
-since we trust the code calling us to tell us to paint only areas
-that are really ours, we will temporarily give the window a
-clipList the size of the whole screen and an origin at (0,0).
-this more or less assumes that ddX code will do translation
-based on the window's absolute position, and that ValidateGC will
-look at clipList, and that no other fields from the
-window will be used.  it's not possible to just draw
-in the root because it may be a different depth.
-
-to get the tile to align correctly we set the GC's tile origin to
-be the (x,y) of the window's upper left corner, after which we
-get the right bits when drawing into the root.
-
-because the clip_mask is being set to None, we may call DoChangeGC with
-fPointer set true, thus we no longer need to install the background or
-border tile in the resource table.
-*/
-
-static RESTYPE ResType = 0;
-static int numGCs = 0;
-static GCPtr	screenContext[MAXSCREENS];
-
-/*ARGSUSED*/
-static int
-tossGC (
-    pointer value,
-    XID id)
-{
-    GCPtr pGC = (GCPtr)value;
-    screenContext[pGC->pScreen->myNum] = (GCPtr)NULL;
-    FreeGC (pGC, id);
-    numGCs--;
-    if (!numGCs)
-	ResType = 0;
-
-    return 0;
-}
-
 _X_EXPORT void
 miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
 {
     ScreenPtr	pScreen = pWin->drawable.pScreen;
     ChangeGCVal gcval[5];
     BITS32	gcmask;
-    PixmapPtr	pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+    PixmapPtr	pPixmap;
     GCPtr	pGC;
     int		i;
     BoxPtr	pbox;
@@ -595,8 +547,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     int		numRects;
     int		xoff, yoff;
 
-    while (pWin->backgroundState == ParentRelative)
-        pWin = pWin->parent;
+    pPixmap = (*pScreen->GetWindowPixmap) (pWin);
 
 #ifdef COMPOSITE
     xoff = -pPixmap->screen_x;
@@ -610,6 +561,9 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
 
     if (what == PW_BACKGROUND)
     {
+	while (pWin->backgroundState == ParentRelative)
+	    pWin = pWin->parent;
+
 	switch (pWin->backgroundState) {
 	case None:
 	    return;
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 1dbb85d..1dd28b8 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -865,9 +865,10 @@ miOverlayHandleExposures(WindowPtr pWin)
 	while (1) {
 	    if((mival = pTree->valdata)) {
 		if(!((*pPriv->InOverlay)(pTree->pWin))) {
-		    if (REGION_NOTEMPTY(pScreen, &mival->borderExposed))
-			(*pWin->drawable.pScreen->PaintWindowBorder)(
-				pTree->pWin, &mival->borderExposed, PW_BORDER);
+		    if (REGION_NOTEMPTY(pScreen, &mival->borderExposed)) {
+			miPaintWindow(pTree->pWin, &mival->borderExposed,
+				      PW_BORDER);
+		    }
 		    REGION_UNINIT(pScreen, &mival->borderExposed);
 
 		    (*WindowExposures)(pTree->pWin,&mival->exposed,NullRegion);
@@ -903,10 +904,10 @@ miOverlayHandleExposures(WindowPtr pWin)
 				REGION_RECTS(&val->after.exposed));
 		}
 	    } else {
-		if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed))
-		    (*pChild->drawable.pScreen->PaintWindowBorder)(pChild,
-						    &val->after.borderExposed,
-						    PW_BORDER);
+		if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed)) {
+			miPaintWindow(pChild, &val->after.borderExposed,
+				      PW_BORDER);
+		}
 		(*WindowExposures)(pChild, &val->after.exposed, NullRegion);
 	    }
 	    REGION_UNINIT(pScreen, &val->after.borderExposed);
@@ -1066,8 +1067,7 @@ miOverlayWindowExposures(
 		REGION_INTERSECT(pScreen, prgn, prgn, &pWin->clipList);
 	}
 	if (prgn && !REGION_NIL(prgn))
-	    (*pScreen->PaintWindowBackground)(
-			pWin, prgn, PW_BACKGROUND);
+	    miPaintWindow(pWin, prgn, PW_BACKGROUND);
 	if (clientInterested && exposures && !REGION_NIL(exposures))
 	    miSendExposures(pWin, exposures,
 			    pWin->drawable.x, pWin->drawable.y);
@@ -1738,7 +1738,7 @@ miOverlayClearToBackground(
     if (generateExposures)
         (*pScreen->WindowExposures)(pWin, &reg, pBSReg);
     else if (pWin->backgroundState != None)
-        (*pScreen->PaintWindowBackground)(pWin, &reg, PW_BACKGROUND);
+	miPaintWindow(pWin, &reg, PW_BACKGROUND);
     REGION_UNINIT(pScreen, &reg);
     if (pBSReg)
         REGION_DESTROY(pScreen, pBSReg);
diff --git a/mi/miscrinit.c b/mi/miscrinit.c
index cc40cbe..d88eb71 100644
--- a/mi/miscrinit.c
+++ b/mi/miscrinit.c
@@ -251,7 +251,7 @@ miScreenInit(pScreen, pbits, xsize, ysiz
     pScreen->ValidateTree = miValidateTree;
     pScreen->PostValidateTree = (PostValidateTreeProcPtr) 0;
     pScreen->WindowExposures = miWindowExposures;
-    /* PaintWindowBackground, PaintWindowBorder, CopyWindow */
+    /* CopyWindow */
     pScreen->ClearToBackground = miClearToBackground;
     pScreen->ClipNotify = (ClipNotifyProcPtr) 0;
     pScreen->RestackWindow = (RestackWindowProcPtr) 0;
diff --git a/mi/miwindow.c b/mi/miwindow.c
index cab67ea..77cb750 100644
--- a/mi/miwindow.c
+++ b/mi/miwindow.c
@@ -118,7 +118,7 @@ miClearToBackground(pWin, x, y, w, h, ge
     if (generateExposures)
 	(*pScreen->WindowExposures)(pWin, &reg, pBSReg);
     else if (pWin->backgroundState != None)
-        (*pScreen->PaintWindowBackground)(pWin, &reg, PW_BACKGROUND);
+	miPaintWindow(pWin, &reg, PW_BACKGROUND);
     REGION_UNINIT(pScreen, &reg);
     if (pBSReg)
 	REGION_DESTROY(pScreen, pBSReg);
@@ -451,9 +451,7 @@ miHandleValidateExposures(pWin)
 	if ( (val = pChild->valdata) )
 	{
 	    if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed))
-		(*pChild->drawable.pScreen->PaintWindowBorder)(pChild,
-						    &val->after.borderExposed,
-						    PW_BORDER);
+		miPaintWindow(pChild, &val->after.borderExposed, PW_BORDER);
 	    REGION_UNINIT(pScreen, &val->after.borderExposed);
 	    (*WindowExposures)(pChild, &val->after.exposed, NullRegion);
 	    REGION_UNINIT(pScreen, &val->after.exposed);
diff --git a/miext/cw/cw.c b/miext/cw/cw.c
index 7ee013b..bd49f3f 100644
--- a/miext/cw/cw.c
+++ b/miext/cw/cw.c
@@ -380,149 +380,6 @@ cwGetSpans(DrawablePtr pSrc, int wMax, D
     SCREEN_EPILOGUE(pScreen, GetSpans, cwGetSpans);
 }
 
-static void
-cwFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, unsigned long pixel)
-{
-    ScreenPtr pScreen = pDrawable->pScreen;
-    GCPtr     pGC;
-    BoxPtr    pBox;
-    int       nbox, i;
-    ChangeGCVal v[3];
-
-    pGC = GetScratchGC(pDrawable->depth, pScreen);
-    v[0].val = GXcopy;
-    v[1].val = pixel;
-    v[2].val = FillSolid;
-    dixChangeGC(NullClient, pGC, (GCFunction | GCForeground | GCFillStyle),
-		NULL, v);
-    ValidateGC(pDrawable, pGC);
-
-    pBox = REGION_RECTS(pRegion);
-    nbox = REGION_NUM_RECTS(pRegion);
-
-    for (i = 0; i < nbox; i++, pBox++) {
-	xRectangle rect;
-	rect.x      = pBox->x1;
-	rect.y      = pBox->y1;
-	rect.width  = pBox->x2 - pBox->x1;
-	rect.height = pBox->y2 - pBox->y1;
-	(*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &rect);
-    }
-
-   FreeScratchGC(pGC);
-}
-
-static void
-cwFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
-		  int x_off, int y_off)
-{
-    ScreenPtr pScreen = pDrawable->pScreen;
-    GCPtr     pGC;
-    BoxPtr    pBox;
-    int       nbox, i;
-    ChangeGCVal v[5];
-
-    pGC = GetScratchGC(pDrawable->depth, pScreen);
-    v[0].val = GXcopy;
-    v[1].val = FillTiled;
-    v[2].ptr = (pointer) pTile;
-    v[3].val = x_off;
-    v[4].val = y_off;
-    dixChangeGC(NullClient, pGC, (GCFunction | GCFillStyle | GCTile |
-		GCTileStipXOrigin | GCTileStipYOrigin), NULL, v);
-
-    ValidateGC(pDrawable, pGC);
-
-    pBox = REGION_RECTS(pRegion);
-    nbox = REGION_NUM_RECTS(pRegion);
-
-    for (i = 0; i < nbox; i++, pBox++) {
-	xRectangle rect;
-	rect.x      = pBox->x1;
-	rect.y      = pBox->y1;
-	rect.width  = pBox->x2 - pBox->x1;
-	rect.height = pBox->y2 - pBox->y1;
-	(*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &rect);
-    }
-
-   FreeScratchGC(pGC);
-}
-
-static void
-cwPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    SCREEN_PROLOGUE(pScreen, PaintWindowBackground);
-
-    if (!cwDrawableIsRedirWindow((DrawablePtr)pWin)) {
-	(*pScreen->PaintWindowBackground)(pWin, pRegion, what);
-    } else {
-	DrawablePtr pBackingDrawable;
-	int x_off, y_off, x_screen, y_screen;
-
-	while (pWin->backgroundState == ParentRelative)
-	    pWin = pWin->parent;
-
-	pBackingDrawable = cwGetBackingDrawable((DrawablePtr)pWin, &x_off,
-						&y_off);
-
-	x_screen = x_off - pWin->drawable.x;
-	y_screen = y_off - pWin->drawable.y;
-
-	if (pWin && (pWin->backgroundState == BackgroundPixel ||
-		pWin->backgroundState == BackgroundPixmap))
-	{
-	    REGION_TRANSLATE(pScreen, pRegion, x_screen, y_screen);
-
-	    if (pWin->backgroundState == BackgroundPixel) {
-		cwFillRegionSolid(pBackingDrawable, pRegion,
-				  pWin->background.pixel);
-	    } else {
-		cwFillRegionTiled(pBackingDrawable, pRegion,
-				  pWin->background.pixmap, x_off, y_off);
-	    }
-
-	    REGION_TRANSLATE(pScreen, pRegion, -x_screen, -y_screen);
-	}
-    }
-
-    SCREEN_EPILOGUE(pScreen, PaintWindowBackground, cwPaintWindowBackground);
-}
-
-static void
-cwPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    SCREEN_PROLOGUE(pScreen, PaintWindowBorder);
-
-    if (!cwDrawableIsRedirWindow((DrawablePtr)pWin)) {
-	(*pScreen->PaintWindowBorder)(pWin, pRegion,  what);
-    } else {
-	DrawablePtr pBackingDrawable;
-	int x_off, y_off, x_screen, y_screen;
-
-	pBackingDrawable = cwGetBackingDrawable((DrawablePtr)pWin, &x_off,
-						&y_off);
-
-	x_screen = x_off - pWin->drawable.x;
-	y_screen = y_off - pWin->drawable.y;
-
-	REGION_TRANSLATE(pScreen, pRegion, x_screen, y_screen);
-
-	if (pWin->borderIsPixel) {
-	    cwFillRegionSolid(pBackingDrawable, pRegion, pWin->border.pixel);
-	} else {
-	    cwFillRegionTiled(pBackingDrawable, pRegion, pWin->border.pixmap,
-			      x_off, y_off);
-	}
-
-	REGION_TRANSLATE(pScreen, pRegion, -x_screen, -y_screen);
-    }
-
-    SCREEN_EPILOGUE(pScreen, PaintWindowBorder, cwPaintWindowBorder);
-}
 
 static void
 cwCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
@@ -654,8 +511,6 @@ miInitializeCompositeWrapper(ScreenPtr p
     SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage);
     SCREEN_EPILOGUE(pScreen, GetSpans, cwGetSpans);
     SCREEN_EPILOGUE(pScreen, CreateGC, cwCreateGC);
-    SCREEN_EPILOGUE(pScreen, PaintWindowBackground, cwPaintWindowBackground);
-    SCREEN_EPILOGUE(pScreen, PaintWindowBorder, cwPaintWindowBorder);
     SCREEN_EPILOGUE(pScreen, CopyWindow, cwCopyWindow);
 
     SCREEN_EPILOGUE(pScreen, SetWindowPixmap, cwSetWindowPixmap);
@@ -681,8 +536,6 @@ cwCloseScreen (int i, ScreenPtr pScreen)
     pScreen->GetImage = pScreenPriv->GetImage;
     pScreen->GetSpans = pScreenPriv->GetSpans;
     pScreen->CreateGC = pScreenPriv->CreateGC;
-    pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground;
-    pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder;
     pScreen->CopyWindow = pScreenPriv->CopyWindow;
 
 #ifdef RENDER
diff --git a/miext/cw/cw.h b/miext/cw/cw.h
index 0d57b9b..8e42ac2 100644
--- a/miext/cw/cw.h
+++ b/miext/cw/cw.h
@@ -84,8 +84,6 @@ typedef struct {
     GetSpansProcPtr		GetSpans;
     CreateGCProcPtr		CreateGC;
 
-    PaintWindowBackgroundProcPtr PaintWindowBackground;
-    PaintWindowBorderProcPtr	PaintWindowBorder;
     CopyWindowProcPtr		CopyWindow;
 
     GetWindowPixmapProcPtr	GetWindowPixmap;
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 472b1b8..58f37e9 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -1635,35 +1635,6 @@ damageDestroyPixmap (PixmapPtr pPixmap)
 }
 
 static void
-damagePaintWindow(WindowPtr pWindow,
-		  RegionPtr prgn,
-		  int	    what)
-{
-    ScreenPtr pScreen = pWindow->drawable.pScreen;
-    damageScrPriv(pScreen);
-
-    /*
-     * Painting background none doesn't actually *do* anything, so
-     * no damage is recorded
-     */
-    if ((what != PW_BACKGROUND || pWindow->backgroundState != None) &&
-	getWindowDamage (pWindow))
-	damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1);
-    if(what == PW_BACKGROUND) {
-	unwrap (pScrPriv, pScreen, PaintWindowBackground);
-	(*pScreen->PaintWindowBackground) (pWindow, prgn, what);
-	damageReportPostOp (&pWindow->drawable);
-	wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow);
-    } else {
-	unwrap (pScrPriv, pScreen, PaintWindowBorder);
-	(*pScreen->PaintWindowBorder) (pWindow, prgn, what);
-	damageReportPostOp (&pWindow->drawable);
-	wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow);
-    }
-}
-
-
-static void
 damageCopyWindow(WindowPtr	pWindow,
 		 DDXPointRec	ptOldOrg,
 		 RegionPtr	prgnSrc)
@@ -1763,8 +1734,6 @@ damageCloseScreen (int i, ScreenPtr pScr
 
     unwrap (pScrPriv, pScreen, DestroyPixmap);
     unwrap (pScrPriv, pScreen, CreateGC);
-    unwrap (pScrPriv, pScreen, PaintWindowBackground);
-    unwrap (pScrPriv, pScreen, PaintWindowBorder);
     unwrap (pScrPriv, pScreen, CopyWindow);
     unwrap (pScrPriv, pScreen, CloseScreen);
     xfree (pScrPriv);
@@ -1814,8 +1783,6 @@ DamageSetup (ScreenPtr pScreen)
 
     wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap);
     wrap (pScrPriv, pScreen, CreateGC, damageCreateGC);
-    wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow);
-    wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow);
     wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow);
     wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap);
     wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow);
diff --git a/miext/damage/damagestr.h b/miext/damage/damagestr.h
index 1e0efad..e603f02 100755
--- a/miext/damage/damagestr.h
+++ b/miext/damage/damagestr.h
@@ -60,8 +60,6 @@ typedef struct _damageScrPriv {
      */
     DamagePtr			pScreenDamage;
 
-    PaintWindowBackgroundProcPtr PaintWindowBackground;
-    PaintWindowBorderProcPtr	PaintWindowBorder;
     CopyWindowProcPtr		CopyWindow;
     CloseScreenProcPtr		CloseScreen;
     CreateGCProcPtr		CreateGC;
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index 3bf6af0..66b930d 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -86,8 +86,6 @@ typedef struct _RootlessScreenRec {
     ChangeWindowAttributesProcPtr ChangeWindowAttributes;
 
     CreateGCProcPtr CreateGC;
-    PaintWindowBackgroundProcPtr PaintWindowBackground;
-    PaintWindowBorderProcPtr PaintWindowBorder;
     CopyWindowProcPtr CopyWindow;
     GetImageProcPtr GetImage;
     SourceValidateProcPtr SourceValidate;
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 700de6e..0bcd2f7 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -598,8 +598,6 @@ RootlessWrap(ScreenPtr pScreen)
     WRAP(CreateScreenResources);
     WRAP(CloseScreen);
     WRAP(CreateGC);
-    WRAP(PaintWindowBackground);
-    WRAP(PaintWindowBorder);
     WRAP(CopyWindow);
     WRAP(GetImage);
     WRAP(SourceValidate);
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 30b7daa..f712659 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -217,10 +217,8 @@ RootlessSetShape(WindowPtr pWin)
 
 
 /* Disallow ParentRelative background on top-level windows
-   because the root window doesn't really have the right background
-   and fb will try to draw on the root instead of on the window.
-   ParentRelative prevention is also in PaintWindowBackground/Border()
-   so it is no longer really needed here. */
+   because the root window doesn't really have the right background.
+ */
 Bool
 RootlessChangeWindowAttributes(WindowPtr pWin, unsigned long vmask)
 {
@@ -670,7 +668,7 @@ RootlessResizeCopyWindow(WindowPtr pWin,
 /*
  * RootlessCopyWindow
  *  Update *new* location of window. Old location is redrawn with
- *  PaintWindowBackground/Border. Cloned from fbCopyWindow.
+ *  miPaintWindow. Cloned from fbCopyWindow.
  *  The original always draws on the root pixmap, which we don't have.
  *  Instead, draw on the parent window's pixmap.
  */
@@ -1326,96 +1324,6 @@ out:
     }
 }
 
-
-/*
- * SetPixmapOfAncestors
- *  Set the Pixmaps on all ParentRelative windows up the ancestor chain.
- */
-static void
-SetPixmapOfAncestors(WindowPtr pWin)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    WindowPtr topWin = TopLevelParent(pWin);
-    RootlessWindowRec *topWinRec = WINREC(topWin);
-
-    while (pWin->backgroundState == ParentRelative) {
-        if (pWin == topWin) {
-            // disallow ParentRelative background state on top level
-            XID pixel = 0;
-            ChangeWindowAttributes(pWin, CWBackPixel, &pixel, serverClient);
-            RL_DEBUG_MSG("Cleared ParentRelative on 0x%x.\n", pWin);
-            break;
-        }
-
-        pWin = pWin->parent;
-        pScreen->SetWindowPixmap(pWin, topWinRec->pixmap);
-    }
-}
-
-
-/*
- * RootlessPaintWindowBackground
- */
-void
-RootlessPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
- 
-    if (IsRoot(pWin))
-        return;
-
-    RL_DEBUG_MSG("paintwindowbackground start (win 0x%x, framed %i) ",
-                 pWin, IsFramedWindow(pWin));
-
-    if (IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, pRegion);
-
-        // For ParentRelative windows, we have to make sure the window
-        // pixmap is set correctly all the way up the ancestor chain.
-        if (pWin->backgroundState == ParentRelative) {
-            SetPixmapOfAncestors(pWin);
-        }
-    }
-
-    SCREEN_UNWRAP(pScreen, PaintWindowBackground);
-    pScreen->PaintWindowBackground(pWin, pRegion, what);
-    SCREEN_WRAP(pScreen, PaintWindowBackground);
-
-    RL_DEBUG_MSG("paintwindowbackground end\n");
-}
-
-
-/*
- * RootlessPaintWindowBorder
- */
-void
-RootlessPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    RL_DEBUG_MSG("paintwindowborder start (win 0x%x) ", pWin);
-
-    if (IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, pRegion);
-
-        // For ParentRelative windows with tiled borders, we have to make
-        // sure the window pixmap is set correctly all the way up the
-        // ancestor chain.
-        if (!pWin->borderIsPixel &&
-            pWin->backgroundState == ParentRelative)
-        {
-            SetPixmapOfAncestors(pWin);
-        }
-    }
-
-    SCREEN_UNWRAP(pWin->drawable.pScreen, PaintWindowBorder);
-    pWin->drawable.pScreen->PaintWindowBorder(pWin, pRegion, what);
-    SCREEN_WRAP(pWin->drawable.pScreen, PaintWindowBorder);
-
-    RL_DEBUG_MSG("paintwindowborder end\n");
-}
-
-
 /*
  * RootlessChangeBorderWidth
  *  FIXME: untested!
diff --git a/miext/rootless/rootlessWindow.h b/miext/rootless/rootlessWindow.h
index 093a2b3..9573068 100644
--- a/miext/rootless/rootlessWindow.h
+++ b/miext/rootless/rootlessWindow.h
@@ -54,10 +54,6 @@ void RootlessMoveWindow(WindowPtr pWin,i
 void RootlessResizeWindow(WindowPtr pWin, int x, int y,
 			  unsigned int w, unsigned int h, WindowPtr pSib);
 void RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent);
-void RootlessPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion,
-                                   int what);
-void RootlessPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion,
-                               int what);
 void RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width);
 
 #endif
diff --git a/miext/rootless/safeAlpha/Makefile.am b/miext/rootless/safeAlpha/Makefile.am
index 7592c18..823fb77 100644
--- a/miext/rootless/safeAlpha/Makefile.am
+++ b/miext/rootless/safeAlpha/Makefile.am
@@ -6,7 +6,6 @@ INCLUDES = -I$(srcdir)/.. -I$(top_srcdir
 
 
 noinst_LTLIBRARIES = libsafeAlpha.la
-libsafeAlpha_la_SOURCES = safeAlphaPicture.c \
-		       safeAlphaWindow.c
+libsafeAlpha_la_SOURCES = safeAlphaPicture.c
 
 EXTRA_DIST = safeAlpha.h
diff --git a/miext/rootless/safeAlpha/safeAlpha.h b/miext/rootless/safeAlpha/safeAlpha.h
index bd1ce32..9b9b39c 100644
--- a/miext/rootless/safeAlpha/safeAlpha.h
+++ b/miext/rootless/safeAlpha/safeAlpha.h
@@ -32,8 +32,6 @@
 
 #include "picturestr.h"
 
-void SafeAlphaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
-
 #ifdef RENDER
 void
 SafeAlphaComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
diff --git a/miext/rootless/safeAlpha/safeAlphaWindow.c b/miext/rootless/safeAlpha/safeAlphaWindow.c
deleted file mode 100644
index 5226782..0000000
--- a/miext/rootless/safeAlpha/safeAlphaWindow.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Specialized window functions to protect the alpha channel
- */
-/*
- * Copyright (c) 2002-2003 Torrey T. Lyons. 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, 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. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
- */
-/* Portions of this file are based on fbwindow.c, which contains the
- * following copyright:
- *
- * Copyright © 1998 Keith Packard
- */
-
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-#include "fb.h"
-#include "safeAlpha.h"
-#include "rootlessCommon.h"
-
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#include "panoramiXsrv.h"
-#endif
-
-/*
- * SafeAlphaFillRegionTiled
- *  Fill using a tile while leaving the alpha channel untouched.
- *  Based on fbfillRegionTiled.
- */
-void
-SafeAlphaFillRegionTiled(
-    DrawablePtr pDrawable,
-    RegionPtr   pRegion,
-    PixmapPtr   pTile)
-{
-    FbBits      *dst;
-    FbStride    dstStride;
-    int         dstBpp;
-    int         dstXoff, dstYoff;
-    FbBits      *tile;
-    FbStride    tileStride;
-    int         tileBpp;
-    int         tileXoff, tileYoff; /* XXX assumed to be zero */
-    int         tileWidth, tileHeight;
-    int         n = REGION_NUM_RECTS(pRegion);
-    BoxPtr      pbox = REGION_RECTS(pRegion);
-    int         xRot = pDrawable->x;
-    int         yRot = pDrawable->y;
-    FbBits      planeMask;
-
-#ifdef PANORAMIX
-    if(!noPanoramiXExtension)
-    {
-        int index = pDrawable->pScreen->myNum;
-        if(&WindowTable[index]->drawable == pDrawable)
-        {
-            xRot -= panoramiXdataPtr[index].x;
-            yRot -= panoramiXdataPtr[index].y;
-        }
-    }
-#endif
-    fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-    fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp,
-                   tileXoff, tileYoff);
-    tileWidth = pTile->drawable.width;
-    tileHeight = pTile->drawable.height;
-    xRot += dstXoff;
-    yRot += dstYoff;
-    planeMask = FB_ALLONES & ~RootlessAlphaMask(dstBpp);
-
-    while (n--)
-    {
-        fbTile (dst + (pbox->y1 + dstYoff) * dstStride,
-                dstStride,
-                (pbox->x1 + dstXoff) * dstBpp,
-                (pbox->x2 - pbox->x1) * dstBpp,
-                pbox->y2 - pbox->y1,
-                tile,
-                tileStride,
-                tileWidth * dstBpp,
-                tileHeight,
-                GXcopy,
-                planeMask,
-                dstBpp,
-                xRot * dstBpp,
-                yRot - pbox->y1);
-        pbox++;
-    }
-}
-
-
-/*
- * SafeAlphaPaintWindow
- *  Paint the window while filling in the alpha channel with all on.
- *  We can't use fbPaintWindow because it zeros the alpha channel.
- */
-void
-SafeAlphaPaintWindow(
-    WindowPtr pWin,
-    RegionPtr pRegion,
-    int what)
-{
-    switch (what) {
-      case PW_BACKGROUND:
-
-        switch (pWin->backgroundState) {
-            case None:
-                break;
-            case ParentRelative:
-                do {
-                    pWin = pWin->parent;
-                } while (pWin->backgroundState == ParentRelative);
-                (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-                                                                 what);
-                break;
-            case BackgroundPixmap:
-                SafeAlphaFillRegionTiled (&pWin->drawable,
-                                          pRegion,
-                                          pWin->background.pixmap);
-                break;
-            case BackgroundPixel:
-            {
-                Pixel pixel = pWin->background.pixel |
-                              RootlessAlphaMask(pWin->drawable.bitsPerPixel);
-                fbFillRegionSolid (&pWin->drawable, pRegion, 0,
-                                   fbReplicatePixel (pixel,
-                                        pWin->drawable.bitsPerPixel));
-                break;
-            }
-        }
-    	break;
-      case PW_BORDER:
-        if (pWin->borderIsPixel)
-        {
-            Pixel pixel = pWin->border.pixel |
-                          RootlessAlphaMask(pWin->drawable.bitsPerPixel);
-            fbFillRegionSolid (&pWin->drawable, pRegion, 0,
-                               fbReplicatePixel (pixel,
-                                    pWin->drawable.bitsPerPixel));
-        }
-        else
-        {
-            WindowPtr pBgWin;
-            for (pBgWin = pWin; pBgWin->backgroundState == ParentRelative;
-                 pBgWin = pBgWin->parent);
-    
-            SafeAlphaFillRegionTiled (&pBgWin->drawable,
-                                      pRegion,
-                                      pWin->border.pixmap);
-        }
-        break;
-    }
-    fbValidateDrawable (&pWin->drawable);
-}
diff-tree 06d27f8045966c1fb154eafaff308a01b93f265b (from dd3992eb86377684a5dbe86fa19c756a9e53cda2)
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Wed Sep 12 23:57:30 2007 +0100

    Try again to fix drawable and tile offsets in miPaintWindow
    
    Many coordinate spaces are hard. Let's go drinking.

diff --git a/mi/miexpose.c b/mi/miexpose.c
index ad1356f..2dc8f15 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -592,22 +592,30 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     BoxPtr	pbox;
     xRectangle	*prect;
     int		numRects;
-    int		tile_x_off = 0, tile_y_off = 0;
-    int		draw_x_off = 0, draw_y_off = 0;
+    /*
+     * Distance from screen to destination drawable, use this
+     * to adjust rendering coordinates which come in in screen space
+     */
+    int		draw_x_off, draw_y_off;
+    /*
+     * Tile offset for drawing; these need to align the tile
+     * to the appropriate window origin
+     */
+    int		tile_x_off, tile_y_off;
     PixUnion	fill;
     Bool	solid = TRUE;
     DrawablePtr	drawable = &pWin->drawable;
 
-    draw_x_off = pWin->drawable.x;
-    draw_y_off = pWin->drawable.y;
-
     while (pWin->backgroundState == ParentRelative)
         pWin = pWin->parent;
 
     if (what == PW_BACKGROUND)
     {
-	tile_x_off = -pWin->drawable.x;
-	tile_y_off = -pWin->drawable.y;
+	draw_x_off = drawable->x;
+	draw_y_off = drawable->y;
+
+	tile_x_off = 0;
+	tile_y_off = 0;
 	fill = pWin->background;
 	switch (pWin->backgroundState) {
 	case None:
@@ -619,16 +627,21 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     }
     else
     {
-	PixmapPtr   pPixmap;
+	PixmapPtr   pixmap;
 
+	tile_x_off = drawable->x;
+	tile_y_off = drawable->y;
+	
 	/* servers without pixmaps draw their own borders */
 	if (!pScreen->GetWindowPixmap)
 	    return;
-	pPixmap = (*pScreen->GetWindowPixmap) (pWin);
-	drawable = &pPixmap->drawable;
+	pixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) drawable);
+	drawable = &pixmap->drawable;
 #ifdef COMPOSITE
-	draw_x_off = -pPixmap->screen_x;
-	draw_y_off = -pPixmap->screen_y;
+	draw_x_off = pixmap->screen_x;
+	draw_y_off = pixmap->screen_y;
+	tile_x_off -= draw_x_off;
+	tile_y_off -= draw_y_off;
 #else
 	draw_x_off = 0;
 	draw_y_off = 0;
@@ -650,8 +663,8 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     {
 	gcval[1].val = FillTiled;
 	gcval[2].ptr = (pointer)fill.pixmap;
-	gcval[3].val = tile_x_off + draw_x_off;
-	gcval[4].val = tile_y_off + draw_y_off;
+	gcval[3].val = tile_x_off;
+	gcval[4].val = tile_y_off;
 	gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
     }
 
@@ -674,8 +687,8 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     pbox = REGION_RECTS(prgn);
     for (i= numRects; --i >= 0; pbox++, prect++)
     {
-	prect->x = pbox->x1 + draw_x_off;
-	prect->y = pbox->y1 + draw_y_off;
+	prect->x = pbox->x1 - draw_x_off;
+	prect->y = pbox->y1 - draw_y_off;
 	prect->width = pbox->x2 - pbox->x1;
 	prect->height = pbox->y2 - pbox->y1;
     }
diff-tree dd3992eb86377684a5dbe86fa19c756a9e53cda2 (from 6da39c67905500ab2db00a45cda4a9f756cdde96)
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Wed Sep 12 22:39:31 2007 +0100

    miPaintWindow draw to window for background.
    
    Instead of drawing to window pixmap for everything, draw to window for
    background as that works for Xnest and Xdmx; draw to pixmap for borders
    which neither of those X servers use.

diff --git a/mi/miexpose.c b/mi/miexpose.c
index e82a0b5..ad1356f 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -587,62 +587,72 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     ScreenPtr	pScreen = pWin->drawable.pScreen;
     ChangeGCVal gcval[5];
     BITS32	gcmask;
-    PixmapPtr	pPixmap = (*pScreen->GetWindowPixmap) (pWin);
     GCPtr	pGC;
     int		i;
     BoxPtr	pbox;
     xRectangle	*prect;
     int		numRects;
-    int		xoff, yoff;
+    int		tile_x_off = 0, tile_y_off = 0;
+    int		draw_x_off = 0, draw_y_off = 0;
+    PixUnion	fill;
+    Bool	solid = TRUE;
+    DrawablePtr	drawable = &pWin->drawable;
+
+    draw_x_off = pWin->drawable.x;
+    draw_y_off = pWin->drawable.y;
 
     while (pWin->backgroundState == ParentRelative)
         pWin = pWin->parent;
 
-#ifdef COMPOSITE
-    xoff = -pPixmap->screen_x;
-    yoff = -pPixmap->screen_y;
-#else
-    xoff = 0;
-    yoff = 0;
-#endif
-    gcval[0].val = GXcopy;
-    gcmask = GCFunction;
-
     if (what == PW_BACKGROUND)
     {
+	tile_x_off = -pWin->drawable.x;
+	tile_y_off = -pWin->drawable.y;
+	fill = pWin->background;
 	switch (pWin->backgroundState) {
 	case None:
 	    return;
-	case BackgroundPixel:
-	    gcval[1].val = pWin->background.pixel;
-	    gcval[2].val  = FillSolid;
-	    gcmask |= GCForeground | GCFillStyle;
-	    break;
 	case BackgroundPixmap:
-	    gcval[1].val = FillTiled;
-	    gcval[2].ptr = (pointer)pWin->background.pixmap;
-	    gcval[3].val = pWin->drawable.x + xoff;
-	    gcval[4].val = pWin->drawable.y + yoff;
-	    gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
+	    solid = FALSE;
 	    break;
 	}
     }
     else
     {
-	if (pWin->borderIsPixel)
-	{
-	    gcval[1].val = pWin->border.pixel;
-	    gcval[2].val  = FillSolid;
-	    gcmask |= GCForeground | GCFillStyle;
-	}
-	else
-	{
-	    gcval[1].val = FillTiled;
-	    gcval[2].ptr = (pointer)pWin->border.pixmap;
-	    gcval[3].val = pWin->drawable.x + xoff;
-	    gcval[4].val = pWin->drawable.y + yoff;
-	    gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
-	}
+	PixmapPtr   pPixmap;
+
+	/* servers without pixmaps draw their own borders */
+	if (!pScreen->GetWindowPixmap)
+	    return;
+	pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+	drawable = &pPixmap->drawable;
+#ifdef COMPOSITE
+	draw_x_off = -pPixmap->screen_x;
+	draw_y_off = -pPixmap->screen_y;
+#else
+	draw_x_off = 0;
+	draw_y_off = 0;
+#endif
+	fill = pWin->border;
+	solid = pWin->borderIsPixel;
+    }
+    
+    gcval[0].val = GXcopy;
+    gcmask = GCFunction;
+
+    if (solid)
+    {
+	gcval[1].val = fill.pixel;
+	gcval[2].val  = FillSolid;
+	gcmask |= GCForeground | GCFillStyle;
+    }
+    else
+    {
+	gcval[1].val = FillTiled;
+	gcval[2].ptr = (pointer)fill.pixmap;
+	gcval[3].val = tile_x_off + draw_x_off;
+	gcval[4].val = tile_y_off + draw_y_off;
+	gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
     }
 
     prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(prgn) *
@@ -650,27 +660,27 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     if (!prect)
 	return;
 
-    pGC = GetScratchGC(pPixmap->drawable.depth, pPixmap->drawable.pScreen);
+    pGC = GetScratchGC(drawable->depth, drawable->pScreen);
     if (!pGC)
     {
 	DEALLOCATE_LOCAL(prect);
 	return;
     }
     
-    dixChangeGC(NullClient, pGC, gcmask, NULL, gcval);
-    ValidateGC(&pPixmap->drawable, pGC);
+    dixChangeGC (NullClient, pGC, gcmask, NULL, gcval);
+    ValidateGC (drawable, pGC);
 
     numRects = REGION_NUM_RECTS(prgn);
     pbox = REGION_RECTS(prgn);
     for (i= numRects; --i >= 0; pbox++, prect++)
     {
-	prect->x = pbox->x1 + xoff;
-	prect->y = pbox->y1 + yoff;
+	prect->x = pbox->x1 + draw_x_off;
+	prect->y = pbox->y1 + draw_y_off;
 	prect->width = pbox->x2 - pbox->x1;
 	prect->height = pbox->y2 - pbox->y1;
     }
     prect -= numRects;
-    (*pGC->ops->PolyFillRect)(&pPixmap->drawable, pGC, numRects, prect);
+    (*pGC->ops->PolyFillRect)(drawable, pGC, numRects, prect);
     DEALLOCATE_LOCAL(prect);
 
     FreeScratchGC(pGC);
diff-tree 6da39c67905500ab2db00a45cda4a9f756cdde96 (from 257c8ed17f4f908e0d0d5e53aaf13aa3b1313f50)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep 12 13:23:13 2007 +0000

    Fix build on FreeBSD after Popen changes.

diff --git a/os/utils.c b/os/utils.c
index afcaae4..144098b 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1720,7 +1720,7 @@ static struct pid {
     int pid;
 } *pidlist;
 
-static sighandler_t old_alarm = NULL; /* XXX horrible awful hack */
+void (*old_alarm)(int) = NULL; /* XXX horrible awful hack */
 
 pointer
 Popen(char *command, char *type)


More information about the xorg-commit mailing list