xserver: Branch 'glucose-2'
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Wed Sep 26 09:58:47 PDT 2007
Makefile.am | 7 +
configure.ac | 15 +--
glucose/Makefile.am | 25 -----
glucose/symlink-xgl.sh | 166 ---------------------------------------
hw/xgl/Makefile.am | 44 ++--------
hw/xgl/glx/Makefile.am | 1
hw/xgl/glx/module/Makefile.am | 1
hw/xgl/glxext/Makefile.am | 1
hw/xgl/glxext/module/Makefile.am | 1
xgl/Makefile.am | 42 +++++++++
10 files changed, 73 insertions(+), 230 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 (®ion, pSrc, pMask, pDst,
- xSrc, ySrc, xMask, yMask,
- xDst, yDst, width, height))
- return TRUE;
-
- pBox = REGION_RECTS (®ion);
- nBox = REGION_NUM_RECTS (®ion);
- pExt = REGION_EXTENTS (pScreen, ®ion);
-
- 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, ®ion);
- 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, ®ion);
- return FALSE;
- }
-
- pGeometry = xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable,
- xDst - xMask,
- yDst - yMask);
- if (!pGeometry)
- {
- REGION_UNINIT (pScreen, ®ion);
- 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, ®ion);
- 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, ®ion);
- 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, ®ion);
- 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, ®ion);
- 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, ®ion);
-
- 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, ®ion, pBox, 1);
- xglAddSurfaceDamage (pDst, ®ion);
- REGION_UNINIT (pDst->pScreen, ®ion);
-
- 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, ®ion, pBox, 1);
- xglAddSurfaceDamage (pDrawable, ®ion);
- REGION_UNINIT (pDrawable->pScreen, ®ion);
-
- 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, ®ion, &box, 1);
- REGION_INTERSECT (pDrawable->pScreen, ®ion, pClip, ®ion);
-
- xglAddSurfaceDamage (pDrawable, ®ion);
-
- REGION_UNINIT (pDrawable->pScreen, ®ion);
- }
-}
-
-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 (®ion, pSrc, pMask, pDst,
- xSrc, ySrc, xMask, yMask, xDst, yDst,
- width, height))
- return;
-
- xglAddSurfaceDamage (pDst->pDrawable, ®ion);
- REGION_UNINIT (pDst->pDrawable->pScreen, ®ion);
- } 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, ®ion, &box, 1);
- xglAddSurfaceDamage (&pPixmap->drawable, ®ion);
- REGION_UNINIT (pDrawable->pScreen, ®ion);
-
- 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, ®ion, NullBox, 0);
- break;
- case rgnOUT:
- REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
- REGION_UNION (pDrawable->pScreen,
- &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
- ®ion);
- break;
- case rgnPART:
- REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
- REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion,
- &pPixmapPriv->bitRegion);
- REGION_UNION (pDrawable->pScreen,
- &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
- ®ion);
- break;
- }
- }
- else
- {
- REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
- REGION_SUBTRACT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
- ®ion, &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, ®ion, &box, 1);
- REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion,
- &pPixmapPriv->bitRegion);
-
- pPixmapPriv->allBits = TRUE;
- }
-
- if (!pPixmapPriv->buffer)
- if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
- return FALSE;
-
- if (REGION_NOTEMPTY (pDrawable->pScreen, ®ion) && 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 (®ion);
- nBox = REGION_NUM_RECTS (®ion);
- pExt = REGION_EXTENTS (pDrawable->pScreen, ®ion);
-
- 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, ®ion);
-
- 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, ®ion, &pPixmapPriv->damageBox, 1);
-
- if (pPixmapPriv->pDamage)
- {
- RegionPtr pDamageRegion;
-
- pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
-
- REGION_UNION (pDrawable->pScreen,
- pDamageRegion, pDamageRegion,
- ®ion);
- }
-
- REGION_UNION (pDrawable->pScreen,
- &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
- ®ion);
-
- REGION_UNINIT (pDrawable->pScreen, ®ion);
-
- 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, ®ion, &extents, 1);
- REGION_TRANSLATE (pScreen, ®ion,
- pDst->pDrawable->x, pDst->pDrawable->y);
-
- DamageDamageRegion (pDst->pDrawable, ®ion);
-
- REGION_UNINIT (pScreen, ®ion);
- }
-
- 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 (®ion, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask,
+ xDst, yDst, width, height))
+ return TRUE;
+
+ pBox = REGION_RECTS (®ion);
+ nBox = REGION_NUM_RECTS (®ion);
+ pExt = REGION_EXTENTS (pScreen, ®ion);
+
+ 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, ®ion);
+ 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, ®ion);
+ return FALSE;
+ }
+
+ pGeometry = xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable,
+ xDst - xMask,
+ yDst - yMask);
+ if (!pGeometry)
+ {
+ REGION_UNINIT (pScreen, ®ion);
+ 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, ®ion);
+ 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, ®ion);
+ 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, ®ion);
+ 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, ®ion);
+ 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, ®ion);
+
+ 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, ®ion, pBox, 1);
+ xglAddSurfaceDamage (pDst, ®ion);
+ REGION_UNINIT (pDst->pScreen, ®ion);
+
+ 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, ®ion, pBox, 1);
+ xglAddSurfaceDamage (pDrawable, ®ion);
+ REGION_UNINIT (pDrawable->pScreen, ®ion);
+
+ 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, ®ion, &box, 1);
+ REGION_INTERSECT (pDrawable->pScreen, ®ion, pClip, ®ion);
+
+ xglAddSurfaceDamage (pDrawable, ®ion);
+
+ REGION_UNINIT (pDrawable->pScreen, ®ion);
+ }
+}
+
+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 (®ion, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ width, height))
+ return;
+
+ xglAddSurfaceDamage (pDst->pDrawable, ®ion);
+ REGION_UNINIT (pDst->pDrawable->pScreen, ®ion);
+ } 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, ®ion, &box, 1);
+ xglAddSurfaceDamage (&pPixmap->drawable, ®ion);
+ REGION_UNINIT (pDrawable->pScreen, ®ion);
+
+ 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, ®ion, NullBox, 0);
+ break;
+ case rgnOUT:
+ REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
+ REGION_UNION (pDrawable->pScreen,
+ &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
+ ®ion);
+ break;
+ case rgnPART:
+ REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
+ REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion,
+ &pPixmapPriv->bitRegion);
+ REGION_UNION (pDrawable->pScreen,
+ &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
+ ®ion);
+ break;
+ }
+ }
+ else
+ {
+ REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
+ REGION_SUBTRACT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
+ ®ion, &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, ®ion, &box, 1);
+ REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion,
+ &pPixmapPriv->bitRegion);
+
+ pPixmapPriv->allBits = TRUE;
+ }
+
+ if (!pPixmapPriv->buffer)
+ if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
+ return FALSE;
+
+ if (REGION_NOTEMPTY (pDrawable->pScreen, ®ion) && 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 (®ion);
+ nBox = REGION_NUM_RECTS (®ion);
+ pExt = REGION_EXTENTS (pDrawable->pScreen, ®ion);
+
+ 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, ®ion);
+
+ 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, ®ion, &pPixmapPriv->damageBox, 1);
+
+ if (pPixmapPriv->pDamage)
+ {
+ RegionPtr pDamageRegion;
+
+ pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
+
+ REGION_UNION (pDrawable->pScreen,
+ pDamageRegion, pDamageRegion,
+ ®ion);
+ }
+
+ REGION_UNION (pDrawable->pScreen,
+ &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
+ ®ion);
+
+ REGION_UNINIT (pDrawable->pScreen, ®ion);
+
+ 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, ®ion, &extents, 1);
+ REGION_TRANSLATE (pScreen, ®ion,
+ pDst->pDrawable->x, pDst->pDrawable->y);
+
+ DamageDamageRegion (pDst->pDrawable, ®ion);
+
+ REGION_UNINIT (pScreen, ®ion);
+ }
+
+ 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
More information about the xorg-commit
mailing list