aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-04-01 07:17:02 +0000
committermarha <marha@users.sourceforge.net>2011-04-01 07:17:02 +0000
commit5d8e1ad0cd01de0bd0b43dc916c1d39fd293e79d (patch)
treeb7092d8d81a5246dd5cec7fa9742e41eaccb69d6
parent140242b0d4aed1d595d6565d088d9567c456d6b4 (diff)
downloadvcxsrv-5d8e1ad0cd01de0bd0b43dc916c1d39fd293e79d.tar.gz
vcxsrv-5d8e1ad0cd01de0bd0b43dc916c1d39fd293e79d.tar.bz2
vcxsrv-5d8e1ad0cd01de0bd0b43dc916c1d39fd293e79d.zip
libXext xserver libXmu libX11 libXdmcp xextproto libxtrans mesa git update 1 Apr 2011
-rw-r--r--X11/extensions/configure.ac11
-rw-r--r--X11/extensions/docbook.am95
-rw-r--r--X11/xtrans/configure.ac11
-rw-r--r--X11/xtrans/doc/Makefile.am59
-rw-r--r--X11/xtrans/docbook.am95
-rw-r--r--libX11/configure.ac971
-rw-r--r--libX11/docbook.am95
-rw-r--r--libX11/specs/XIM/Makefile.am65
-rw-r--r--libX11/specs/i18n/framework/Makefile.am50
-rw-r--r--libX11/specs/i18n/localedb/Makefile.am47
-rw-r--r--libX11/specs/i18n/trans/Makefile.am47
-rw-r--r--libX11/specs/libX11/Makefile.am94
-rw-r--r--libXdmcp/configure.ac11
-rw-r--r--libXdmcp/doc/Makefile.am76
-rw-r--r--libXdmcp/docbook.am95
-rw-r--r--libXext/configure.ac11
-rw-r--r--libXext/docbook.am95
-rw-r--r--libXext/specs/Makefile.am76
-rw-r--r--libXmu/configure.ac11
-rw-r--r--libXmu/doc/Makefile.am59
-rw-r--r--libXmu/docbook.am95
-rw-r--r--mesalib/src/mesa/program/prog_optimize.c2511
-rw-r--r--xorg-server/fb/fb.h4150
-rw-r--r--xorg-server/fb/fballpriv.c124
-rw-r--r--xorg-server/fb/fbarc.c294
-rw-r--r--xorg-server/fb/fbbits.c2
-rw-r--r--xorg-server/fb/fbblt.c8
-rw-r--r--xorg-server/fb/fbbltone.c22
-rw-r--r--xorg-server/fb/fbcopy.c746
-rw-r--r--xorg-server/fb/fbgc.c616
-rw-r--r--xorg-server/fb/fbgetsp.c2
-rw-r--r--xorg-server/fb/fbglyph.c940
-rw-r--r--xorg-server/fb/fbimage.c732
-rw-r--r--xorg-server/fb/fbline.c342
-rw-r--r--xorg-server/fb/fboverlay.c858
-rw-r--r--xorg-server/fb/fbpixmap.c782
-rw-r--r--xorg-server/fb/fbpoint.c318
-rw-r--r--xorg-server/fb/fbscreen.c570
-rw-r--r--xorg-server/fb/fbseg.c1458
-rw-r--r--xorg-server/fb/fbsetsp.c202
-rw-r--r--xorg-server/fb/fbsolid.c4
-rw-r--r--xorg-server/fb/fbstipple.c4
-rw-r--r--xorg-server/fb/fbwindow.c479
43 files changed, 8744 insertions, 8589 deletions
diff --git a/X11/extensions/configure.ac b/X11/extensions/configure.ac
index dd30292e3..a12f7f452 100644
--- a/X11/extensions/configure.ac
+++ b/X11/extensions/configure.ac
@@ -3,15 +3,16 @@ AC_INIT([XExtProto], [7.2.0], [https://bugs.freedesktop.org/enter_bug.cgi?produc
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
-# Require xorg-macros minimum of 1.10 for DocBook XML documentation
+# Require xorg-macros minimum of 1.12 for DocBook external references
m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.10)
+ [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.12)
XORG_DEFAULT_OPTIONS
XORG_ENABLE_SPECS
-XORG_WITH_XMLTO(0.0.20)
+XORG_WITH_XMLTO(0.0.22)
XORG_WITH_FOP
-XORG_CHECK_SGML_DOCTOOLS(1.5)
+XORG_WITH_XSLTPROC
+XORG_CHECK_SGML_DOCTOOLS(1.7)
AC_OUTPUT([Makefile
specs/Makefile
diff --git a/X11/extensions/docbook.am b/X11/extensions/docbook.am
new file mode 100644
index 000000000..3cf21e879
--- /dev/null
+++ b/X11/extensions/docbook.am
@@ -0,0 +1,95 @@
+#
+# Generate output formats for a single DocBook/XML with/without chapters
+#
+# Variables set by the calling Makefile:
+# shelfdir: the location where the docs/specs are installed. Typically $(docdir)
+# docbook: the main DocBook/XML file, no chapters, appendix or image files
+# chapters: all files pulled in by an XInclude statement and images.
+#
+
+#
+# This makefile is intended for Users Documentation and Functional Specifications.
+# Do not use for Developer Documentation which is not installed and does not require olink.
+# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393
+# for an explanation on documents classification.
+#
+
+# DocBook/XML generated output formats to be installed
+shelf_DATA =
+
+# DocBook/XML file with chapters, appendix and images it includes
+dist_shelf_DATA = $(docbook) $(chapters)
+
+#
+# Generate DocBook/XML output formats with or without stylesheets
+#
+
+# Stylesheets are available if the package xorg-sgml-doctools is installed
+if HAVE_STYLESHEETS
+
+# The location where all cross reference databases are installed
+sgmldbsdir = $(XORG_SGML_PATH)/X11/dbs
+masterdb = "$(sgmldbsdir)/masterdb$(suffix $@).xml"
+XMLTO_FLAGS = \
+ --searchpath "$(XORG_SGML_PATH)/X11" \
+ --stringparam target.database.document=$(masterdb) \
+ --stringparam current.docid="$(<:.xml=)" \
+ --stringparam collect.xref.targets="no"
+
+XMLTO_XHTML_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl \
+ --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
+
+XMLTO_FO_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+endif HAVE_STYLESHEETS
+
+shelf_DATA += $(docbook:.xml=.html)
+%.html: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) xhtml-nochunks $<
+
+if HAVE_FOP
+shelf_DATA += $(docbook:.xml=.pdf) $(docbook:.xml=.ps)
+%.pdf: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop pdf $<
+%.ps: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop ps $<
+endif HAVE_FOP
+
+if HAVE_XMLTO_TEXT
+shelf_DATA += $(docbook:.xml=.txt)
+%.txt: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) txt $<
+endif HAVE_XMLTO_TEXT
+
+#
+# Generate documents cross-reference target databases
+#
+
+# This is only possible if the xorg-sgml-doctools package is installed
+if HAVE_STYLESHEETS
+if HAVE_XSLTPROC
+
+# DocBook/XML generated document cross-reference database
+sgmldbs_DATA = $(docbook:.xml=.html.db) $(docbook:.xml=.fo.db)
+
+# Generate DocBook/XML document cross-reference database
+# Flags for the XSL Transformation processor generating xref target databases
+XSLTPROC_FLAGS = \
+ --path "$(XORG_SGML_PATH)/X11" \
+ --stringparam targets.filename "$@" \
+ --stringparam collect.xref.targets "only" \
+ --nonet --xinclude
+
+%.html.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $<
+
+%.fo.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl $<
+
+endif HAVE_XSLTPROC
+endif HAVE_STYLESHEETS
+
+CLEANFILES = $(shelf_DATA) $(sgmldbs_DATA)
diff --git a/X11/xtrans/configure.ac b/X11/xtrans/configure.ac
index 4928caf83..66a7a975e 100644
--- a/X11/xtrans/configure.ac
+++ b/X11/xtrans/configure.ac
@@ -29,15 +29,16 @@ AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
-# Require xorg-macros minimum of 1.10 for DocBook XML documentation
+# Require xorg-macros minimum of 1.12 for DocBook external references
m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.10)
+ [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.12)
XORG_DEFAULT_OPTIONS
XORG_ENABLE_DOCS
-XORG_WITH_XMLTO(0.0.20)
+XORG_WITH_XMLTO(0.0.22)
XORG_WITH_FOP
-XORG_CHECK_SGML_DOCTOOLS(1.5)
+XORG_WITH_XSLTPROC
+XORG_CHECK_SGML_DOCTOOLS(1.7)
# Because xtrans is included into other modules rather than being linked
# with, these defines have to be added to the cflags line
diff --git a/X11/xtrans/doc/Makefile.am b/X11/xtrans/doc/Makefile.am
index 19ad93910..71b40e4e5 100644
--- a/X11/xtrans/doc/Makefile.am
+++ b/X11/xtrans/doc/Makefile.am
@@ -1,62 +1,15 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
if ENABLE_DOCS
-doc_sources = xtrans.xml
-dist_doc_DATA = $(doc_sources)
-
if HAVE_XMLTO
-doc_DATA = $(doc_sources:.xml=.html)
-
-if HAVE_FOP
-doc_DATA += $(doc_sources:.xml=.ps) $(doc_sources:.xml=.pdf)
-endif
-
-if HAVE_XMLTO_TEXT
-doc_DATA += $(doc_sources:.xml=.txt)
-endif
-
-if HAVE_STYLESHEETS
-XMLTO_FLAGS = \
- -m $(XSL_STYLESHEET) \
- --stringparam html.stylesheet="$(STYLESHEET_SRCDIR)/xorg.css"
-endif
-
-CLEANFILES = $(doc_DATA)
-
-SUFFIXES = .xml .ps .pdf .txt .html
-
-.xml.txt:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) txt $<
-.xml.html:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) xhtml-nochunks $<
+# Main DocBook/XML files (DOCTYPE book)
+docbook = xtrans.xml
-.xml.pdf:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop pdf $<
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)
-.xml.ps:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop ps $<
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
endif HAVE_XMLTO
endif ENABLE_DOCS
diff --git a/X11/xtrans/docbook.am b/X11/xtrans/docbook.am
new file mode 100644
index 000000000..3cf21e879
--- /dev/null
+++ b/X11/xtrans/docbook.am
@@ -0,0 +1,95 @@
+#
+# Generate output formats for a single DocBook/XML with/without chapters
+#
+# Variables set by the calling Makefile:
+# shelfdir: the location where the docs/specs are installed. Typically $(docdir)
+# docbook: the main DocBook/XML file, no chapters, appendix or image files
+# chapters: all files pulled in by an XInclude statement and images.
+#
+
+#
+# This makefile is intended for Users Documentation and Functional Specifications.
+# Do not use for Developer Documentation which is not installed and does not require olink.
+# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393
+# for an explanation on documents classification.
+#
+
+# DocBook/XML generated output formats to be installed
+shelf_DATA =
+
+# DocBook/XML file with chapters, appendix and images it includes
+dist_shelf_DATA = $(docbook) $(chapters)
+
+#
+# Generate DocBook/XML output formats with or without stylesheets
+#
+
+# Stylesheets are available if the package xorg-sgml-doctools is installed
+if HAVE_STYLESHEETS
+
+# The location where all cross reference databases are installed
+sgmldbsdir = $(XORG_SGML_PATH)/X11/dbs
+masterdb = "$(sgmldbsdir)/masterdb$(suffix $@).xml"
+XMLTO_FLAGS = \
+ --searchpath "$(XORG_SGML_PATH)/X11" \
+ --stringparam target.database.document=$(masterdb) \
+ --stringparam current.docid="$(<:.xml=)" \
+ --stringparam collect.xref.targets="no"
+
+XMLTO_XHTML_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl \
+ --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
+
+XMLTO_FO_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+endif HAVE_STYLESHEETS
+
+shelf_DATA += $(docbook:.xml=.html)
+%.html: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) xhtml-nochunks $<
+
+if HAVE_FOP
+shelf_DATA += $(docbook:.xml=.pdf) $(docbook:.xml=.ps)
+%.pdf: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop pdf $<
+%.ps: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop ps $<
+endif HAVE_FOP
+
+if HAVE_XMLTO_TEXT
+shelf_DATA += $(docbook:.xml=.txt)
+%.txt: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) txt $<
+endif HAVE_XMLTO_TEXT
+
+#
+# Generate documents cross-reference target databases
+#
+
+# This is only possible if the xorg-sgml-doctools package is installed
+if HAVE_STYLESHEETS
+if HAVE_XSLTPROC
+
+# DocBook/XML generated document cross-reference database
+sgmldbs_DATA = $(docbook:.xml=.html.db) $(docbook:.xml=.fo.db)
+
+# Generate DocBook/XML document cross-reference database
+# Flags for the XSL Transformation processor generating xref target databases
+XSLTPROC_FLAGS = \
+ --path "$(XORG_SGML_PATH)/X11" \
+ --stringparam targets.filename "$@" \
+ --stringparam collect.xref.targets "only" \
+ --nonet --xinclude
+
+%.html.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $<
+
+%.fo.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl $<
+
+endif HAVE_XSLTPROC
+endif HAVE_STYLESHEETS
+
+CLEANFILES = $(shelf_DATA) $(sgmldbs_DATA)
diff --git a/libX11/configure.ac b/libX11/configure.ac
index 7496f6ca5..f7e81f177 100644
--- a/libX11/configure.ac
+++ b/libX11/configure.ac
@@ -1,485 +1,486 @@
-
-# Initialize Autoconf
-AC_PREREQ([2.60])
-AC_INIT([libX11], [1.4.2],
- [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libX11])
-AC_CONFIG_SRCDIR([Makefile.am])
-AC_CONFIG_HEADERS([src/config.h include/X11/XlibConf.h])
-AC_CONFIG_MACRO_DIR([m4])
-AC_CANONICAL_BUILD
-AC_CANONICAL_HOST
-# Set common system defines for POSIX extensions, such as _GNU_SOURCE
-# Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL)
-# to avoid autoconf errors.
-AC_USE_SYSTEM_EXTENSIONS
-
-# Initialize Automake
-AM_INIT_AUTOMAKE([foreign dist-bzip2])
-AM_MAINTAINER_MODE
-
-# Initialize libtool
-AC_PROG_LIBTOOL
-
-# Require xorg-macros minimum of 1.11 for disabling fop by default
-m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.11 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.11)
-XORG_DEFAULT_OPTIONS
-XORG_ENABLE_SPECS
-XORG_WITH_XMLTO(0.0.20)
-XORG_WITH_FOP([no])
-XORG_CHECK_SGML_DOCTOOLS(1.5)
-XORG_PROG_RAWCPP
-
-# Required when PKG_CHECK_MODULES called within an if statement
-PKG_PROG_PKG_CONFIG
-
-if test x"$CC_FOR_BUILD" = x; then
- if test x"$cross_compiling" = xyes; then
- AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
- else
- CC_FOR_BUILD="$CC"
- fi
-fi
-AC_SUBST([CC_FOR_BUILD])
-
-if test x"$CPPFLAGS_FOR_BUILD" = x; then
- if test ! x"$cross_compiling" = xyes; then
- CPPFLAGS_FOR_BUILD=${CPPFLAGS}
- fi
-fi
-AC_SUBST(CPPFLAGS_FOR_BUILD)
-
-if test x"$CFLAGS_FOR_BUILD" = x; then
- if test ! x"$cross_compiling" = xyes; then
- CFLAGS_FOR_BUILD=${CFLAGS}
- fi
-fi
-AC_SUBST(CFLAGS_FOR_BUILD)
-
-if test x"$LDFLAGS_FOR_BUILD" = x; then
- if test ! x"$cross_compiling" = xyes; then
- LDFLAGS_FOR_BUILD=${LDFLAGS}
- fi
-fi
-AC_SUBST(LDFLAGS_FOR_BUILD)
-
-# Find perl for "make check" tests in nls/Makefile.am
-AC_ARG_WITH(perl,
- AS_HELP_STRING([--with-perl=<path>],
- [path to perl interpreter for build-time tests]),
- [PERL=$withval ; AC_MSG_CHECKING([perl]) ;
- AC_MSG_RESULT([(from --with-perl) $PERL])],
- AC_CHECK_PROGS([PERL], [perl], [no]))
-AM_CONDITIONAL(HAVE_PERL, test x$PERL != xno)
-
-# Checks for pkg-config packages
-
-# Always required
-X11_REQUIRES='xproto >= 7.0.13 xextproto xtrans xcb >= 1.1.92'
-X11_EXTRA_DEPS="xcb >= 1.1.92"
-
-PKG_PROG_PKG_CONFIG()
-
-AC_SUBST(X11_EXTRA_DEPS)
-
-# Issue an error if xtrans.m4 was not found and XTRANS_CONNECTION_FLAGS macro
-# was not expanded, since libX11 with no transport types is rather useless.
-#
-# If you're seeing an error here, be sure you installed the lib/xtrans module
-# first and if it's not in the default location, that you set the ACLOCAL
-# environment variable to find it, such as:
-# ACLOCAL="aclocal -I ${PREFIX}/share/aclocal"
-m4_pattern_forbid([^XTRANS_CONNECTION_FLAGS$])
-
-# Transport selection macro from xtrans.m4
-XTRANS_CONNECTION_FLAGS
-
-# Secure RPC detection macro from xtrans.m4
-XTRANS_SECURE_RPC_FLAGS
-
-# Preferred order to try transports for local connections
-AC_MSG_CHECKING([what order to try transports in for local connections])
-DEFAULT_LOCAL_TRANS=""
-case $host_os in
- solaris*)
- # On Solaris 2.6 through 9, named pipes (LOCAL_TRANS) were
- # faster than Unix domain sockets, but on Solaris 10 & later,
- # Unix domain sockets are faster now.
- if test "$UNIXCONN" = "yes" ; then
- if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
- fi
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}UNIX_TRANS"
- fi
- if test "$LOCALCONN" = "yes" ; then
- if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
- fi
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS"
- fi
- if test "$TCPCONN" = "yes" ; then
- if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
- fi
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS"
- fi
- ;;
- linux*)
- # LOCAL_TRANS is used for abstract sockets.
- if test "$UNIXCONN" = "yes" ; then
- if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
- fi
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS,UNIX_TRANS"
- fi
- if test "$TCPCONN" = "yes" ; then
- if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
- fi
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS"
- fi
- ;;
- *)
- if test "$LOCALCONN" = "yes" ; then
- if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
- fi
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS"
- fi
- if test "$UNIXCONN" = "yes" ; then
- if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
- fi
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}UNIX_TRANS"
- fi
- if test "$TCPCONN" = "yes" ; then
- if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
- fi
- DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS"
- fi
- ;;
-esac
-
-AC_ARG_WITH(local-transport-order,
- AS_HELP_STRING([--with-local-transport-order=LIST], [preference sorted list of transport types to try for local connections]),
- [LOCAL_TRANSPORT_LIST=$withval],
- [LOCAL_TRANSPORT_LIST=$DEFAULT_LOCAL_TRANS])
-AC_DEFINE_UNQUOTED([LOCAL_TRANSPORT_LIST], [$LOCAL_TRANSPORT_LIST],
- [preference sorted list of transport types to try for local connections])
-AC_MSG_RESULT([$LOCAL_TRANSPORT_LIST])
-
-# Check for dlopen
-AC_MSG_CHECKING([if run-time linking is supported])
-AC_SEARCH_LIBS(dlopen,[dl svld])
-if test "x$ac_cv_search_dlopen" = xno; then
- AC_SEARCH_LIBS(shl_load,[dld])
- if test "x$ac_cv_search_shl_load" != xno; then
- AC_DEFINE(HAVE_SHL_LOAD,1,
- [Use shl_load to load shared libraries])
- AC_CHECK_HEADERS([dl.h])
- fi
-else
- AC_DEFINE(HAVE_DLOPEN,1,[Use dlopen to load shared libraries])
- AC_CHECK_HEADERS([dlfcn.h])
-fi
-if test x$ac_cv_header_dlcfn_h -o x$ac_cv_header_dl_h; then
- HAVE_LOADABLE_MODULES=yes
-else
- HAVE_LOADABLE_MODULES=no
-fi
-AC_MSG_RESULT($HAVE_LOADABLE_MODULES)
-
-AC_MSG_CHECKING([if loadable i18n module support should be enabled])
-AC_ARG_ENABLE(loadable-i18n,
- AS_HELP_STRING([--enable-loadable-i18n],
- [Controls loadable i18n module support]),
- [XLIB_LOADABLE_I18N=$enableval],
- [XLIB_LOADABLE_I18N="no"])
-if test x$XLIB_LOADABLE_I18N = xyes; then
- if test x$HAVE_LOADABLE_MODULES = xno; then
- AC_MSG_ERROR([Loadable module support is required to enable loadable i18n module support])
- fi
- AC_DEFINE(USE_DYNAMIC_LC,1,
- [Split some i18n functions into loadable modules])
- AC_SUBST(I18N_MODULE_LIBS,'${top_builddir}/src/libX11.la')
-fi
-AC_MSG_RESULT($XLIB_LOADABLE_I18N)
-
-AM_CONDITIONAL(XLIB_LOADABLE_I18N, test x$XLIB_LOADABLE_I18N = xyes)
-
-AC_MSG_CHECKING([if loadable Xcursor library support should be enabled])
-AC_ARG_ENABLE(loadable-xcursor,
- AS_HELP_STRING([--disable-loadable-xcursor],
- [Controls loadable xcursor library support]),
- [XLIB_LOADABLE_XCURSOR=$enableval],
- [XLIB_LOADABLE_XCURSOR=$HAVE_LOADABLE_MODULES])
-if test x$XLIB_LOADABLE_XCURSOR = xyes; then
- AC_DEFINE(USE_DYNAMIC_XCURSOR,1,
- [Use the X cursor library to load cursors])
-fi
-AC_MSG_RESULT($XLIB_LOADABLE_XCURSOR)
-
-# Checks for header files.
-AC_CHECK_HEADERS([sys/select.h])
-
-# Checks for typedefs, structures, and compiler characteristics.
-
-# Checks for library functions.
-AC_CHECK_FUNCS([strtol])
-# Used in lcFile.c (see also --enable-xlocaledir settings below)
-XLOCALEDIR_IS_SAFE="no"
-AC_CHECK_FUNC([issetugid], [XLOCALEDIR_IS_SAFE="yes"]
- AC_DEFINE(HASSETUGID,1,[Has issetugid() function]))
-AC_CHECK_FUNC([getresuid], [XLOCALEDIR_IS_SAFE="yes"]
- AC_DEFINE(HASGETRESUID,1,[Has getresuid() & getresgid() functions]))
-# Used in Font.c
-AC_CHECK_FUNC([shmat], AC_DEFINE(HAS_SHM,1,[Has shm*() functions]))
-
-# Checks for system services
-# AC_PATH_XTRA
-
-# arch specific things
-WCHAR32="1"
-case $host_os in
- os2*) os2="true" ; WCHAR32="0" ;;
- *) ;;
-esac
-AC_SUBST(WCHAR32)
-
-AM_CONDITIONAL(OS2, test x$os2 = xtrue)
-
-AC_ARG_WITH(launchd, AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto])
-if test "x$LAUNCHD" = xauto; then
- unset LAUNCHD
- AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no], [$PATH$PATH_SEPARATOR/sbin])
-fi
-
-if test "x$LAUNCHD" = xyes ; then
- AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available])
- AC_DEFINE(TRANS_REOPEN, 1, [launchd support available])
-fi
-
-AC_ARG_ENABLE(xthreads,
- AS_HELP_STRING([--disable-xthreads],
- [Disable Xlib support for Multithreading]),
- [xthreads=$enableval],[xthreads=yes])
-
-AC_CHECK_LIB(c, getpwuid_r, [mtsafeapi="yes"], [mtsafeapi="no"])
-
-case x$xthreads in
-xyes)
- AC_DEFINE(XTHREADS,1,[Whether libX11 is compiled with thread support])
- if test x$mtsafeapi = xyes
- then
- AC_DEFINE(XUSE_MTSAFE_API,1,[Whether libX11 needs to use MT safe API's])
- fi
- ;;
-*)
- ;;
-esac
-
-AC_CHECK_LIB(c, pthread_self, [thrstubs="no"], [thrstubs="yes"])
-AM_CONDITIONAL(THRSTUBS, test x$thrstubs = xyes)
-
-# XXX incomplete, please fill this in
-if test x$xthreads = xyes ; then
- case $host_os in
- linux*|openbsd*|gnu*|k*bsd*-gnu)
- XTHREADLIB=-lpthread ;;
- netbsd*)
- XTHREAD_CFLAGS="-D_POSIX_THREAD_SAFE_FUNCTIONS"
- XTHREADLIB="-lpthread" ;;
- freebsd*)
- XTHREAD_CFLAGS="-D_THREAD_SAFE"
- XTHREADLIB="-pthread" ;;
- dragonfly*)
- XTHREADLIB="-pthread" ;;
- solaris*)
- XTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS" ;;
- esac
-fi
-AC_SUBST(XTHREADLIB)
-AC_SUBST(XTHREAD_CFLAGS)
-
-AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
-
-#
-# Find keysymdef.h
-#
-AC_MSG_CHECKING([keysym definitions])
-KEYSYMDEFDIR=`$PKG_CONFIG --variable=includedir xproto`/X11
-FILES="keysymdef.h XF86keysym.h Sunkeysym.h DECkeysym.h HPkeysym.h"
-for i in $FILES; do
- if test -f "$KEYSYMDEFDIR/$i"; then
- KEYSYMDEFS="$KEYSYMDEFS $KEYSYMDEFDIR/$i"
- elif test "x$i" = "xkeysymdef.h"; then
- AC_MSG_ERROR([Cannot find keysymdef.h])
- fi
-done
-AC_MSG_RESULT([$KEYSYMDEFS])
-AC_SUBST(KEYSYMDEFS)
-
-AM_CONDITIONAL(UDC, test xfalse = xtrue)
-
-AC_ARG_ENABLE(xcms,
- AS_HELP_STRING([--disable-xcms],
- [Disable Xlib support for CMS *EXPERIMENTAL*]),
- [XCMS=$enableval],[XCMS=yes])
-AM_CONDITIONAL(XCMS, [test x$XCMS = xyes ])
-if test x"$XCMS" = "xyes"; then
- AC_DEFINE(XCMS,1,[Include support for XCMS])
-fi
-
-AC_ARG_ENABLE(xlocale,
- AS_HELP_STRING([--disable-xlocale],
- [Disable Xlib locale implementation *EXPERIMENTAL*]),
- [XLOCALE=$enableval],[XLOCALE=yes])
-
-AM_CONDITIONAL(XLOCALE, [ test x$XLOCALE = xyes ])
-if test x"$XLOCALE" = "xyes"; then
- AC_DEFINE(XLOCALE,1,[support for X Locales])
-fi
-
-# This disables XLOCALEDIR. Set it if you're using BuildLoadableXlibI18n,
-# don't have either issetugid() or getresuid(), and you need to protect
-# clients that are setgid or setuid to an id other than 0.
-AC_MSG_CHECKING([if XLOCALEDIR support should be enabled])
-AC_ARG_ENABLE(xlocaledir,
- AS_HELP_STRING([--enable-xlocaledir],
- [Enable XLOCALEDIR environment variable support]),
- [ENABLE_XLOCALEDIR=$enableval],[ENABLE_XLOCALEDIR=$XLOCALEDIR_IS_SAFE])
-if test "x$ENABLE_XLOCALEDIR" = "xno"; then
- AC_DEFINE(NO_XLOCALEDIR,1,[Disable XLOCALEDIR environment variable])
-fi
-AC_MSG_RESULT($ENABLE_XLOCALEDIR)
-
-AC_ARG_ENABLE(xf86bigfont,
- AS_HELP_STRING([--disable-xf86bigfont],
- [Disable XF86BigFont extension support]),
- [XF86BIGFONT=$enableval],[XF86BIGFONT="yes"])
-if test "x$XF86BIGFONT" = "xyes"; then
- PKG_CHECK_MODULES(BIGFONT, [xf86bigfontproto >= 1.2.0],
- AC_DEFINE(XF86BIGFONT,1,[Enable XF86BIGFONT extension]),XF86BIGFONT="no")
-fi
-
-AC_ARG_ENABLE(xkb,
- AS_HELP_STRING([--disable-xkb],
- [Disable XKB support *EXPERIMENTAL*]),
- [XKB=$enableval],[XKB=yes])
-
-AM_CONDITIONAL(XKB, [ test x$XKB = xyes ])
-if test x"$XKB" = "xyes"; then
- XKBPROTO_REQUIRES="kbproto"
- X11_REQUIRES="${X11_REQUIRES} kbproto inputproto"
- AC_DEFINE(XKB,1,[Use XKB])
-else
- XKBPROTO_REQUIRES=""
-fi
-AC_SUBST(XKBPROTO_REQUIRES)
-
-AC_FUNC_MMAP()
-composecache_default=$ac_cv_func_mmap_fixed_mapped
-AC_CHECK_FUNC(nl_langinfo, , [composecache_default=no])
-AC_ARG_ENABLE(composecache,
- AS_HELP_STRING([--disable-composecache],
- [Disable compose table cache support]),
- [COMPOSECACHE=$enableval],[COMPOSECACHE=$composecache_default])
-if test x"$COMPOSECACHE" = "xyes"; then
- AC_DEFINE(COMPOSECACHE,1,[Include compose table cache support])
-fi
-
-# Allow checking code with lint, sparse, etc.
-XORG_WITH_LINT
-XORG_LINT_LIBRARY([X11])
-
-X11_DATADIR="${datadir}/X11"
-AX_DEFINE_DIR(X11_DATADIR, X11_DATADIR, [Location of libX11 data])
-AC_SUBST(X11_DATADIR)
-
-X11_LIBDIR="${libdir}/X11"
-AX_DEFINE_DIR(X11_LIBDIR, X11_LIBDIR, [Location of libX11 library data])
-AC_SUBST(X11_LIBDIR)
-
-PKG_CHECK_MODULES(X11, [$X11_REQUIRES])
-X11_CFLAGS="$X11_CFLAGS $XTHREAD_CFLAGS"
-
-#
-# Yes, it would be nice to put the locale data in
-# /usr/share, but the locale stuff includes loadable
-# libraries which must be located in the same directory
-# as the other locale data, so for now, everything lives
-# in ${libdir}
-#
-
-X11_LOCALEDATADIR="${X11_DATADIR}/locale"
-AX_DEFINE_DIR(XLOCALEDATADIR, X11_LOCALEDATADIR, [Location of libX11 locale data])
-AC_SUBST(X11_LOCALEDATADIR)
-
-AC_ARG_WITH(locale-lib-dir, AS_HELP_STRING([--with-locale-lib-dir=DIR],
- [Directory where locale libraries files are installed (default: $libdir/X11/locale)]),
- [ X11_LOCALELIBDIR="$withval" ],
- [ X11_LOCALELIBDIR="${X11_LIBDIR}/locale" ])
-AX_DEFINE_DIR(XLOCALELIBDIR, X11_LOCALELIBDIR, [Location of libX11 locale libraries])
-AC_SUBST(X11_LOCALELIBDIR)
-
-X11_LOCALEDIR="${X11_LOCALEDATADIR}"
-AX_DEFINE_DIR(XLOCALEDIR, X11_LOCALEDIR, [Location of libX11 locale data])
-AC_SUBST(X11_LOCALEDIR)
-
-XKEYSYMDB="${X11_DATADIR}/XKeysymDB"
-AX_DEFINE_DIR(XKEYSYMDB, XKEYSYMDB, [Location of keysym database])
-
-XERRORDB="${X11_DATADIR}/XErrorDB"
-AX_DEFINE_DIR(XERRORDB, XERRORDB, [Location of error message database])
-
-XORG_CHECK_MALLOC_ZERO
-
-AC_CONFIG_FILES([Makefile
- include/Makefile
- man/Makefile
- man/xkb/Makefile
- src/Makefile
- src/util/Makefile
- src/xcms/Makefile
- src/xlibi18n/Makefile
- modules/Makefile
- modules/im/Makefile
- modules/im/ximcp/Makefile
- modules/lc/Makefile
- modules/lc/def/Makefile
- modules/lc/gen/Makefile
- modules/lc/Utf8/Makefile
- modules/lc/xlocale/Makefile
- modules/om/Makefile
- modules/om/generic/Makefile
- src/xkb/Makefile
- nls/Makefile
- specs/Makefile
- specs/i18n/Makefile
- specs/i18n/framework/Makefile
- specs/i18n/localedb/Makefile
- specs/i18n/trans/Makefile
- specs/libX11/Makefile
- specs/XIM/Makefile
- specs/XKB/Makefile
- x11.pc
- x11-xcb.pc])
-AC_OUTPUT
-
-echo ""
-echo "X11 will be built with the following settings:"
-echo " Loadable i18n module support: "$XLIB_LOADABLE_I18N
-echo " Loadable xcursor library support: "$XLIB_LOADABLE_XCURSOR
-echo " Threading support: "$xthreads
-echo " Use Threads safe API: "$mtsafeapi
-echo " Threads stubs in libX11: "$thrstubs
-echo " XCMS: "$XCMS
-echo " Internationalization support: "$XLOCALE
-echo " XF86BigFont support: "$XF86BIGFONT
-echo " XKB support: "$XKB
-echo " XLOCALEDIR environment variable support: "$ENABLE_XLOCALEDIR
-echo " Compose table cache enabled: "$COMPOSECACHE
-echo " Functional specs building enabled: "$build_specs
-echo ""
+
+# Initialize Autoconf
+AC_PREREQ([2.60])
+AC_INIT([libX11], [1.4.2],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libX11])
+AC_CONFIG_SRCDIR([Makefile.am])
+AC_CONFIG_HEADERS([src/config.h include/X11/XlibConf.h])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+# Set common system defines for POSIX extensions, such as _GNU_SOURCE
+# Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL)
+# to avoid autoconf errors.
+AC_USE_SYSTEM_EXTENSIONS
+
+# Initialize Automake
+AM_INIT_AUTOMAKE([foreign dist-bzip2])
+AM_MAINTAINER_MODE
+
+# Initialize libtool
+AC_PROG_LIBTOOL
+
+# Require xorg-macros minimum of 1.12 for DocBook external references
+m4_ifndef([XORG_MACROS_VERSION],
+ [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.12)
+XORG_DEFAULT_OPTIONS
+XORG_ENABLE_SPECS
+XORG_WITH_XMLTO(0.0.22)
+XORG_WITH_FOP([no])
+XORG_WITH_XSLTPROC
+XORG_CHECK_SGML_DOCTOOLS(1.7)
+XORG_PROG_RAWCPP
+
+# Required when PKG_CHECK_MODULES called within an if statement
+PKG_PROG_PKG_CONFIG
+
+if test x"$CC_FOR_BUILD" = x; then
+ if test x"$cross_compiling" = xyes; then
+ AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
+ else
+ CC_FOR_BUILD="$CC"
+ fi
+fi
+AC_SUBST([CC_FOR_BUILD])
+
+if test x"$CPPFLAGS_FOR_BUILD" = x; then
+ if test ! x"$cross_compiling" = xyes; then
+ CPPFLAGS_FOR_BUILD=${CPPFLAGS}
+ fi
+fi
+AC_SUBST(CPPFLAGS_FOR_BUILD)
+
+if test x"$CFLAGS_FOR_BUILD" = x; then
+ if test ! x"$cross_compiling" = xyes; then
+ CFLAGS_FOR_BUILD=${CFLAGS}
+ fi
+fi
+AC_SUBST(CFLAGS_FOR_BUILD)
+
+if test x"$LDFLAGS_FOR_BUILD" = x; then
+ if test ! x"$cross_compiling" = xyes; then
+ LDFLAGS_FOR_BUILD=${LDFLAGS}
+ fi
+fi
+AC_SUBST(LDFLAGS_FOR_BUILD)
+
+# Find perl for "make check" tests in nls/Makefile.am
+AC_ARG_WITH(perl,
+ AS_HELP_STRING([--with-perl=<path>],
+ [path to perl interpreter for build-time tests]),
+ [PERL=$withval ; AC_MSG_CHECKING([perl]) ;
+ AC_MSG_RESULT([(from --with-perl) $PERL])],
+ AC_CHECK_PROGS([PERL], [perl], [no]))
+AM_CONDITIONAL(HAVE_PERL, test x$PERL != xno)
+
+# Checks for pkg-config packages
+
+# Always required
+X11_REQUIRES='xproto >= 7.0.13 xextproto xtrans xcb >= 1.1.92'
+X11_EXTRA_DEPS="xcb >= 1.1.92"
+
+PKG_PROG_PKG_CONFIG()
+
+AC_SUBST(X11_EXTRA_DEPS)
+
+# Issue an error if xtrans.m4 was not found and XTRANS_CONNECTION_FLAGS macro
+# was not expanded, since libX11 with no transport types is rather useless.
+#
+# If you're seeing an error here, be sure you installed the lib/xtrans module
+# first and if it's not in the default location, that you set the ACLOCAL
+# environment variable to find it, such as:
+# ACLOCAL="aclocal -I ${PREFIX}/share/aclocal"
+m4_pattern_forbid([^XTRANS_CONNECTION_FLAGS$])
+
+# Transport selection macro from xtrans.m4
+XTRANS_CONNECTION_FLAGS
+
+# Secure RPC detection macro from xtrans.m4
+XTRANS_SECURE_RPC_FLAGS
+
+# Preferred order to try transports for local connections
+AC_MSG_CHECKING([what order to try transports in for local connections])
+DEFAULT_LOCAL_TRANS=""
+case $host_os in
+ solaris*)
+ # On Solaris 2.6 through 9, named pipes (LOCAL_TRANS) were
+ # faster than Unix domain sockets, but on Solaris 10 & later,
+ # Unix domain sockets are faster now.
+ if test "$UNIXCONN" = "yes" ; then
+ if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
+ fi
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}UNIX_TRANS"
+ fi
+ if test "$LOCALCONN" = "yes" ; then
+ if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
+ fi
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS"
+ fi
+ if test "$TCPCONN" = "yes" ; then
+ if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
+ fi
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS"
+ fi
+ ;;
+ linux*)
+ # LOCAL_TRANS is used for abstract sockets.
+ if test "$UNIXCONN" = "yes" ; then
+ if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
+ fi
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS,UNIX_TRANS"
+ fi
+ if test "$TCPCONN" = "yes" ; then
+ if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
+ fi
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS"
+ fi
+ ;;
+ *)
+ if test "$LOCALCONN" = "yes" ; then
+ if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
+ fi
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS"
+ fi
+ if test "$UNIXCONN" = "yes" ; then
+ if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
+ fi
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}UNIX_TRANS"
+ fi
+ if test "$TCPCONN" = "yes" ; then
+ if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS},"
+ fi
+ DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS"
+ fi
+ ;;
+esac
+
+AC_ARG_WITH(local-transport-order,
+ AS_HELP_STRING([--with-local-transport-order=LIST], [preference sorted list of transport types to try for local connections]),
+ [LOCAL_TRANSPORT_LIST=$withval],
+ [LOCAL_TRANSPORT_LIST=$DEFAULT_LOCAL_TRANS])
+AC_DEFINE_UNQUOTED([LOCAL_TRANSPORT_LIST], [$LOCAL_TRANSPORT_LIST],
+ [preference sorted list of transport types to try for local connections])
+AC_MSG_RESULT([$LOCAL_TRANSPORT_LIST])
+
+# Check for dlopen
+AC_MSG_CHECKING([if run-time linking is supported])
+AC_SEARCH_LIBS(dlopen,[dl svld])
+if test "x$ac_cv_search_dlopen" = xno; then
+ AC_SEARCH_LIBS(shl_load,[dld])
+ if test "x$ac_cv_search_shl_load" != xno; then
+ AC_DEFINE(HAVE_SHL_LOAD,1,
+ [Use shl_load to load shared libraries])
+ AC_CHECK_HEADERS([dl.h])
+ fi
+else
+ AC_DEFINE(HAVE_DLOPEN,1,[Use dlopen to load shared libraries])
+ AC_CHECK_HEADERS([dlfcn.h])
+fi
+if test x$ac_cv_header_dlcfn_h -o x$ac_cv_header_dl_h; then
+ HAVE_LOADABLE_MODULES=yes
+else
+ HAVE_LOADABLE_MODULES=no
+fi
+AC_MSG_RESULT($HAVE_LOADABLE_MODULES)
+
+AC_MSG_CHECKING([if loadable i18n module support should be enabled])
+AC_ARG_ENABLE(loadable-i18n,
+ AS_HELP_STRING([--enable-loadable-i18n],
+ [Controls loadable i18n module support]),
+ [XLIB_LOADABLE_I18N=$enableval],
+ [XLIB_LOADABLE_I18N="no"])
+if test x$XLIB_LOADABLE_I18N = xyes; then
+ if test x$HAVE_LOADABLE_MODULES = xno; then
+ AC_MSG_ERROR([Loadable module support is required to enable loadable i18n module support])
+ fi
+ AC_DEFINE(USE_DYNAMIC_LC,1,
+ [Split some i18n functions into loadable modules])
+ AC_SUBST(I18N_MODULE_LIBS,'${top_builddir}/src/libX11.la')
+fi
+AC_MSG_RESULT($XLIB_LOADABLE_I18N)
+
+AM_CONDITIONAL(XLIB_LOADABLE_I18N, test x$XLIB_LOADABLE_I18N = xyes)
+
+AC_MSG_CHECKING([if loadable Xcursor library support should be enabled])
+AC_ARG_ENABLE(loadable-xcursor,
+ AS_HELP_STRING([--disable-loadable-xcursor],
+ [Controls loadable xcursor library support]),
+ [XLIB_LOADABLE_XCURSOR=$enableval],
+ [XLIB_LOADABLE_XCURSOR=$HAVE_LOADABLE_MODULES])
+if test x$XLIB_LOADABLE_XCURSOR = xyes; then
+ AC_DEFINE(USE_DYNAMIC_XCURSOR,1,
+ [Use the X cursor library to load cursors])
+fi
+AC_MSG_RESULT($XLIB_LOADABLE_XCURSOR)
+
+# Checks for header files.
+AC_CHECK_HEADERS([sys/select.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+AC_CHECK_FUNCS([strtol])
+# Used in lcFile.c (see also --enable-xlocaledir settings below)
+XLOCALEDIR_IS_SAFE="no"
+AC_CHECK_FUNC([issetugid], [XLOCALEDIR_IS_SAFE="yes"]
+ AC_DEFINE(HASSETUGID,1,[Has issetugid() function]))
+AC_CHECK_FUNC([getresuid], [XLOCALEDIR_IS_SAFE="yes"]
+ AC_DEFINE(HASGETRESUID,1,[Has getresuid() & getresgid() functions]))
+# Used in Font.c
+AC_CHECK_FUNC([shmat], AC_DEFINE(HAS_SHM,1,[Has shm*() functions]))
+
+# Checks for system services
+# AC_PATH_XTRA
+
+# arch specific things
+WCHAR32="1"
+case $host_os in
+ os2*) os2="true" ; WCHAR32="0" ;;
+ *) ;;
+esac
+AC_SUBST(WCHAR32)
+
+AM_CONDITIONAL(OS2, test x$os2 = xtrue)
+
+AC_ARG_WITH(launchd, AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto])
+if test "x$LAUNCHD" = xauto; then
+ unset LAUNCHD
+ AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no], [$PATH$PATH_SEPARATOR/sbin])
+fi
+
+if test "x$LAUNCHD" = xyes ; then
+ AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available])
+ AC_DEFINE(TRANS_REOPEN, 1, [launchd support available])
+fi
+
+AC_ARG_ENABLE(xthreads,
+ AS_HELP_STRING([--disable-xthreads],
+ [Disable Xlib support for Multithreading]),
+ [xthreads=$enableval],[xthreads=yes])
+
+AC_CHECK_LIB(c, getpwuid_r, [mtsafeapi="yes"], [mtsafeapi="no"])
+
+case x$xthreads in
+xyes)
+ AC_DEFINE(XTHREADS,1,[Whether libX11 is compiled with thread support])
+ if test x$mtsafeapi = xyes
+ then
+ AC_DEFINE(XUSE_MTSAFE_API,1,[Whether libX11 needs to use MT safe API's])
+ fi
+ ;;
+*)
+ ;;
+esac
+
+AC_CHECK_LIB(c, pthread_self, [thrstubs="no"], [thrstubs="yes"])
+AM_CONDITIONAL(THRSTUBS, test x$thrstubs = xyes)
+
+# XXX incomplete, please fill this in
+if test x$xthreads = xyes ; then
+ case $host_os in
+ linux*|openbsd*|gnu*|k*bsd*-gnu)
+ XTHREADLIB=-lpthread ;;
+ netbsd*)
+ XTHREAD_CFLAGS="-D_POSIX_THREAD_SAFE_FUNCTIONS"
+ XTHREADLIB="-lpthread" ;;
+ freebsd*)
+ XTHREAD_CFLAGS="-D_THREAD_SAFE"
+ XTHREADLIB="-pthread" ;;
+ dragonfly*)
+ XTHREADLIB="-pthread" ;;
+ solaris*)
+ XTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS" ;;
+ esac
+fi
+AC_SUBST(XTHREADLIB)
+AC_SUBST(XTHREAD_CFLAGS)
+
+AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
+
+#
+# Find keysymdef.h
+#
+AC_MSG_CHECKING([keysym definitions])
+KEYSYMDEFDIR=`$PKG_CONFIG --variable=includedir xproto`/X11
+FILES="keysymdef.h XF86keysym.h Sunkeysym.h DECkeysym.h HPkeysym.h"
+for i in $FILES; do
+ if test -f "$KEYSYMDEFDIR/$i"; then
+ KEYSYMDEFS="$KEYSYMDEFS $KEYSYMDEFDIR/$i"
+ elif test "x$i" = "xkeysymdef.h"; then
+ AC_MSG_ERROR([Cannot find keysymdef.h])
+ fi
+done
+AC_MSG_RESULT([$KEYSYMDEFS])
+AC_SUBST(KEYSYMDEFS)
+
+AM_CONDITIONAL(UDC, test xfalse = xtrue)
+
+AC_ARG_ENABLE(xcms,
+ AS_HELP_STRING([--disable-xcms],
+ [Disable Xlib support for CMS *EXPERIMENTAL*]),
+ [XCMS=$enableval],[XCMS=yes])
+AM_CONDITIONAL(XCMS, [test x$XCMS = xyes ])
+if test x"$XCMS" = "xyes"; then
+ AC_DEFINE(XCMS,1,[Include support for XCMS])
+fi
+
+AC_ARG_ENABLE(xlocale,
+ AS_HELP_STRING([--disable-xlocale],
+ [Disable Xlib locale implementation *EXPERIMENTAL*]),
+ [XLOCALE=$enableval],[XLOCALE=yes])
+
+AM_CONDITIONAL(XLOCALE, [ test x$XLOCALE = xyes ])
+if test x"$XLOCALE" = "xyes"; then
+ AC_DEFINE(XLOCALE,1,[support for X Locales])
+fi
+
+# This disables XLOCALEDIR. Set it if you're using BuildLoadableXlibI18n,
+# don't have either issetugid() or getresuid(), and you need to protect
+# clients that are setgid or setuid to an id other than 0.
+AC_MSG_CHECKING([if XLOCALEDIR support should be enabled])
+AC_ARG_ENABLE(xlocaledir,
+ AS_HELP_STRING([--enable-xlocaledir],
+ [Enable XLOCALEDIR environment variable support]),
+ [ENABLE_XLOCALEDIR=$enableval],[ENABLE_XLOCALEDIR=$XLOCALEDIR_IS_SAFE])
+if test "x$ENABLE_XLOCALEDIR" = "xno"; then
+ AC_DEFINE(NO_XLOCALEDIR,1,[Disable XLOCALEDIR environment variable])
+fi
+AC_MSG_RESULT($ENABLE_XLOCALEDIR)
+
+AC_ARG_ENABLE(xf86bigfont,
+ AS_HELP_STRING([--disable-xf86bigfont],
+ [Disable XF86BigFont extension support]),
+ [XF86BIGFONT=$enableval],[XF86BIGFONT="yes"])
+if test "x$XF86BIGFONT" = "xyes"; then
+ PKG_CHECK_MODULES(BIGFONT, [xf86bigfontproto >= 1.2.0],
+ AC_DEFINE(XF86BIGFONT,1,[Enable XF86BIGFONT extension]),XF86BIGFONT="no")
+fi
+
+AC_ARG_ENABLE(xkb,
+ AS_HELP_STRING([--disable-xkb],
+ [Disable XKB support *EXPERIMENTAL*]),
+ [XKB=$enableval],[XKB=yes])
+
+AM_CONDITIONAL(XKB, [ test x$XKB = xyes ])
+if test x"$XKB" = "xyes"; then
+ XKBPROTO_REQUIRES="kbproto"
+ X11_REQUIRES="${X11_REQUIRES} kbproto inputproto"
+ AC_DEFINE(XKB,1,[Use XKB])
+else
+ XKBPROTO_REQUIRES=""
+fi
+AC_SUBST(XKBPROTO_REQUIRES)
+
+AC_FUNC_MMAP()
+composecache_default=$ac_cv_func_mmap_fixed_mapped
+AC_CHECK_FUNC(nl_langinfo, , [composecache_default=no])
+AC_ARG_ENABLE(composecache,
+ AS_HELP_STRING([--disable-composecache],
+ [Disable compose table cache support]),
+ [COMPOSECACHE=$enableval],[COMPOSECACHE=$composecache_default])
+if test x"$COMPOSECACHE" = "xyes"; then
+ AC_DEFINE(COMPOSECACHE,1,[Include compose table cache support])
+fi
+
+# Allow checking code with lint, sparse, etc.
+XORG_WITH_LINT
+XORG_LINT_LIBRARY([X11])
+
+X11_DATADIR="${datadir}/X11"
+AX_DEFINE_DIR(X11_DATADIR, X11_DATADIR, [Location of libX11 data])
+AC_SUBST(X11_DATADIR)
+
+X11_LIBDIR="${libdir}/X11"
+AX_DEFINE_DIR(X11_LIBDIR, X11_LIBDIR, [Location of libX11 library data])
+AC_SUBST(X11_LIBDIR)
+
+PKG_CHECK_MODULES(X11, [$X11_REQUIRES])
+X11_CFLAGS="$X11_CFLAGS $XTHREAD_CFLAGS"
+
+#
+# Yes, it would be nice to put the locale data in
+# /usr/share, but the locale stuff includes loadable
+# libraries which must be located in the same directory
+# as the other locale data, so for now, everything lives
+# in ${libdir}
+#
+
+X11_LOCALEDATADIR="${X11_DATADIR}/locale"
+AX_DEFINE_DIR(XLOCALEDATADIR, X11_LOCALEDATADIR, [Location of libX11 locale data])
+AC_SUBST(X11_LOCALEDATADIR)
+
+AC_ARG_WITH(locale-lib-dir, AS_HELP_STRING([--with-locale-lib-dir=DIR],
+ [Directory where locale libraries files are installed (default: $libdir/X11/locale)]),
+ [ X11_LOCALELIBDIR="$withval" ],
+ [ X11_LOCALELIBDIR="${X11_LIBDIR}/locale" ])
+AX_DEFINE_DIR(XLOCALELIBDIR, X11_LOCALELIBDIR, [Location of libX11 locale libraries])
+AC_SUBST(X11_LOCALELIBDIR)
+
+X11_LOCALEDIR="${X11_LOCALEDATADIR}"
+AX_DEFINE_DIR(XLOCALEDIR, X11_LOCALEDIR, [Location of libX11 locale data])
+AC_SUBST(X11_LOCALEDIR)
+
+XKEYSYMDB="${X11_DATADIR}/XKeysymDB"
+AX_DEFINE_DIR(XKEYSYMDB, XKEYSYMDB, [Location of keysym database])
+
+XERRORDB="${X11_DATADIR}/XErrorDB"
+AX_DEFINE_DIR(XERRORDB, XERRORDB, [Location of error message database])
+
+XORG_CHECK_MALLOC_ZERO
+
+AC_CONFIG_FILES([Makefile
+ include/Makefile
+ man/Makefile
+ man/xkb/Makefile
+ src/Makefile
+ src/util/Makefile
+ src/xcms/Makefile
+ src/xlibi18n/Makefile
+ modules/Makefile
+ modules/im/Makefile
+ modules/im/ximcp/Makefile
+ modules/lc/Makefile
+ modules/lc/def/Makefile
+ modules/lc/gen/Makefile
+ modules/lc/Utf8/Makefile
+ modules/lc/xlocale/Makefile
+ modules/om/Makefile
+ modules/om/generic/Makefile
+ src/xkb/Makefile
+ nls/Makefile
+ specs/Makefile
+ specs/i18n/Makefile
+ specs/i18n/framework/Makefile
+ specs/i18n/localedb/Makefile
+ specs/i18n/trans/Makefile
+ specs/libX11/Makefile
+ specs/XIM/Makefile
+ specs/XKB/Makefile
+ x11.pc
+ x11-xcb.pc])
+AC_OUTPUT
+
+echo ""
+echo "X11 will be built with the following settings:"
+echo " Loadable i18n module support: "$XLIB_LOADABLE_I18N
+echo " Loadable xcursor library support: "$XLIB_LOADABLE_XCURSOR
+echo " Threading support: "$xthreads
+echo " Use Threads safe API: "$mtsafeapi
+echo " Threads stubs in libX11: "$thrstubs
+echo " XCMS: "$XCMS
+echo " Internationalization support: "$XLOCALE
+echo " XF86BigFont support: "$XF86BIGFONT
+echo " XKB support: "$XKB
+echo " XLOCALEDIR environment variable support: "$ENABLE_XLOCALEDIR
+echo " Compose table cache enabled: "$COMPOSECACHE
+echo " Functional specs building enabled: "$build_specs
+echo ""
diff --git a/libX11/docbook.am b/libX11/docbook.am
new file mode 100644
index 000000000..3cf21e879
--- /dev/null
+++ b/libX11/docbook.am
@@ -0,0 +1,95 @@
+#
+# Generate output formats for a single DocBook/XML with/without chapters
+#
+# Variables set by the calling Makefile:
+# shelfdir: the location where the docs/specs are installed. Typically $(docdir)
+# docbook: the main DocBook/XML file, no chapters, appendix or image files
+# chapters: all files pulled in by an XInclude statement and images.
+#
+
+#
+# This makefile is intended for Users Documentation and Functional Specifications.
+# Do not use for Developer Documentation which is not installed and does not require olink.
+# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393
+# for an explanation on documents classification.
+#
+
+# DocBook/XML generated output formats to be installed
+shelf_DATA =
+
+# DocBook/XML file with chapters, appendix and images it includes
+dist_shelf_DATA = $(docbook) $(chapters)
+
+#
+# Generate DocBook/XML output formats with or without stylesheets
+#
+
+# Stylesheets are available if the package xorg-sgml-doctools is installed
+if HAVE_STYLESHEETS
+
+# The location where all cross reference databases are installed
+sgmldbsdir = $(XORG_SGML_PATH)/X11/dbs
+masterdb = "$(sgmldbsdir)/masterdb$(suffix $@).xml"
+XMLTO_FLAGS = \
+ --searchpath "$(XORG_SGML_PATH)/X11" \
+ --stringparam target.database.document=$(masterdb) \
+ --stringparam current.docid="$(<:.xml=)" \
+ --stringparam collect.xref.targets="no"
+
+XMLTO_XHTML_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl \
+ --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
+
+XMLTO_FO_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+endif HAVE_STYLESHEETS
+
+shelf_DATA += $(docbook:.xml=.html)
+%.html: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) xhtml-nochunks $<
+
+if HAVE_FOP
+shelf_DATA += $(docbook:.xml=.pdf) $(docbook:.xml=.ps)
+%.pdf: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop pdf $<
+%.ps: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop ps $<
+endif HAVE_FOP
+
+if HAVE_XMLTO_TEXT
+shelf_DATA += $(docbook:.xml=.txt)
+%.txt: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) txt $<
+endif HAVE_XMLTO_TEXT
+
+#
+# Generate documents cross-reference target databases
+#
+
+# This is only possible if the xorg-sgml-doctools package is installed
+if HAVE_STYLESHEETS
+if HAVE_XSLTPROC
+
+# DocBook/XML generated document cross-reference database
+sgmldbs_DATA = $(docbook:.xml=.html.db) $(docbook:.xml=.fo.db)
+
+# Generate DocBook/XML document cross-reference database
+# Flags for the XSL Transformation processor generating xref target databases
+XSLTPROC_FLAGS = \
+ --path "$(XORG_SGML_PATH)/X11" \
+ --stringparam targets.filename "$@" \
+ --stringparam collect.xref.targets "only" \
+ --nonet --xinclude
+
+%.html.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $<
+
+%.fo.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl $<
+
+endif HAVE_XSLTPROC
+endif HAVE_STYLESHEETS
+
+CLEANFILES = $(shelf_DATA) $(sgmldbs_DATA)
diff --git a/libX11/specs/XIM/Makefile.am b/libX11/specs/XIM/Makefile.am
index c3e191716..a1fa72da5 100644
--- a/libX11/specs/XIM/Makefile.am
+++ b/libX11/specs/XIM/Makefile.am
@@ -1,40 +1,25 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-if ENABLE_SPECS
-
-specdir = $(docdir)/$(subdir)
-doc_sources = xim.xml
-dist_spec_DATA = \
- $(doc_sources) \
- dynamicflowsampleseq.svg \
- dynamicflow.svg \
- eventflow.svg \
- sampleprotocolflow1.svg \
- sampleprotocolflow2.svg \
- staticflowsampleseq.svg \
- staticflow.svg
-
-include $(top_srcdir)/specs/xmlrules.in
-
-endif ENABLE_SPECS
+
+if ENABLE_SPECS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = xim.xml
+
+# Included chapters, appendix, images
+chapters = \
+ dynamicflowsampleseq.svg \
+ dynamicflow.svg \
+ eventflow.svg \
+ sampleprotocolflow1.svg \
+ sampleprotocolflow2.svg \
+ staticflowsampleseq.svg \
+ staticflow.svg
+
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)/XIM
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_SPECS
diff --git a/libX11/specs/i18n/framework/Makefile.am b/libX11/specs/i18n/framework/Makefile.am
index 8f6364a03..6e8b0106a 100644
--- a/libX11/specs/i18n/framework/Makefile.am
+++ b/libX11/specs/i18n/framework/Makefile.am
@@ -1,32 +1,18 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-if ENABLE_SPECS
-
-specdir = $(docdir)/$(subdir)
-doc_sources = framework.xml
-dist_spec_DATA = $(doc_sources) framework.svg
-
-include $(top_srcdir)/specs/xmlrules.in
-
-endif ENABLE_SPECS
+
+if ENABLE_SPECS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = framework.xml
+
+# Included chapters, appendix, images
+chapters = framework.svg
+
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)/framework
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_SPECS
diff --git a/libX11/specs/i18n/localedb/Makefile.am b/libX11/specs/i18n/localedb/Makefile.am
index 99b5086da..8db6a7bda 100644
--- a/libX11/specs/i18n/localedb/Makefile.am
+++ b/libX11/specs/i18n/localedb/Makefile.am
@@ -1,32 +1,15 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-if ENABLE_SPECS
-
-specdir = $(docdir)/$(subdir)
-doc_sources = localedb.xml
-dist_spec_DATA = $(doc_sources)
-
-include $(top_srcdir)/specs/xmlrules.in
-
-endif ENABLE_SPECS
+
+if ENABLE_SPECS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = localedb.xml
+
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)/localedb
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_SPECS
diff --git a/libX11/specs/i18n/trans/Makefile.am b/libX11/specs/i18n/trans/Makefile.am
index dfdf34f05..cdec7509b 100644
--- a/libX11/specs/i18n/trans/Makefile.am
+++ b/libX11/specs/i18n/trans/Makefile.am
@@ -1,32 +1,15 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-if ENABLE_SPECS
-
-specdir = $(docdir)/$(subdir)
-doc_sources = trans.xml
-dist_spec_DATA = $(doc_sources)
-
-include $(top_srcdir)/specs/xmlrules.in
-
-endif ENABLE_SPECS
+
+if ENABLE_SPECS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = trans.xml
+
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)/trans
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_SPECS
diff --git a/libX11/specs/libX11/Makefile.am b/libX11/specs/libX11/Makefile.am
index bd51baf1f..0e59ad887 100644
--- a/libX11/specs/libX11/Makefile.am
+++ b/libX11/specs/libX11/Makefile.am
@@ -1,54 +1,40 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-if ENABLE_SPECS
-
-specdir = $(docdir)/$(subdir)
-doc_sources = libX11.xml
-dist_spec_DATA = $(doc_sources) \
- AppA.xml \
- AppB.xml \
- AppC.xml \
- AppD.xml \
- CH01.xml \
- CH02.xml \
- CH03.xml \
- CH04.xml \
- CH05.xml \
- CH06.xml \
- CH07.xml \
- CH08.xml \
- CH09.xml \
- CH10.xml \
- CH11.xml \
- CH12.xml \
- CH13.xml \
- CH14.xml \
- CH15.xml \
- CH16.xml \
- credits.xml \
- glossary.xml
-
-include $(top_srcdir)/specs/xmlrules.in
-
-endif ENABLE_SPECS
+
+if ENABLE_SPECS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = libX11.xml
+
+# Included chapters, appendix, images
+chapters = \
+ AppA.xml \
+ AppB.xml \
+ AppC.xml \
+ AppD.xml \
+ CH01.xml \
+ CH02.xml \
+ CH03.xml \
+ CH04.xml \
+ CH05.xml \
+ CH06.xml \
+ CH07.xml \
+ CH08.xml \
+ CH09.xml \
+ CH10.xml \
+ CH11.xml \
+ CH12.xml \
+ CH13.xml \
+ CH14.xml \
+ CH15.xml \
+ CH16.xml \
+ credits.xml \
+ glossary.xml
+
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_SPECS
diff --git a/libXdmcp/configure.ac b/libXdmcp/configure.ac
index 97d31a1cd..71e12c99c 100644
--- a/libXdmcp/configure.ac
+++ b/libXdmcp/configure.ac
@@ -35,15 +35,16 @@ AM_MAINTAINER_MODE
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
-# Require xorg-macros minimum of 1.10 for HAVE_STYLESHEETS in XORG_CHECK_SGML_DOCTOOLS
+# Require xorg-macros minimum of 1.12 for DocBook external references
m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.10)
+ [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.12)
XORG_DEFAULT_OPTIONS
XORG_ENABLE_DOCS
-XORG_WITH_XMLTO(0.0.20)
+XORG_WITH_XMLTO(0.0.22)
XORG_WITH_FOP
-XORG_CHECK_SGML_DOCTOOLS(1.5)
+XORG_WITH_XSLTPROC
+XORG_CHECK_SGML_DOCTOOLS(1.7)
# Checks for programs.
AC_PROG_LN_S
diff --git a/libXdmcp/doc/Makefile.am b/libXdmcp/doc/Makefile.am
index c95f6cc7c..9f3bde8ea 100644
--- a/libXdmcp/doc/Makefile.am
+++ b/libXdmcp/doc/Makefile.am
@@ -1,61 +1,15 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-if ENABLE_DOCS
-doc_sources = xdmcp.xml
-dist_doc_DATA = $(doc_sources)
-
-if HAVE_XMLTO
-doc_DATA = $(doc_sources:.xml=.html)
-
-if HAVE_FOP
-doc_DATA += $(doc_sources:.xml=.ps) $(doc_sources:.xml=.pdf)
-endif
-
-if HAVE_XMLTO_TEXT
-doc_DATA += $(doc_sources:.xml=.txt)
-endif
-
-if HAVE_STYLESHEETS
-XMLTO_FLAGS = -m $(XSL_STYLESHEET) \
- --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
-endif
-
-CLEANFILES = $(doc_DATA)
-
-SUFFIXES = .xml .ps .pdf .txt .html
-
-.xml.txt:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) txt $<
-
-.xml.html:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) xhtml-nochunks $<
-
-.xml.pdf:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop pdf $<
-
-.xml.ps:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop ps $<
-
-endif HAVE_XMLTO
-endif ENABLE_DOCS
+
+if ENABLE_DOCS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = xdmcp.xml
+
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_DOCS
diff --git a/libXdmcp/docbook.am b/libXdmcp/docbook.am
new file mode 100644
index 000000000..3cf21e879
--- /dev/null
+++ b/libXdmcp/docbook.am
@@ -0,0 +1,95 @@
+#
+# Generate output formats for a single DocBook/XML with/without chapters
+#
+# Variables set by the calling Makefile:
+# shelfdir: the location where the docs/specs are installed. Typically $(docdir)
+# docbook: the main DocBook/XML file, no chapters, appendix or image files
+# chapters: all files pulled in by an XInclude statement and images.
+#
+
+#
+# This makefile is intended for Users Documentation and Functional Specifications.
+# Do not use for Developer Documentation which is not installed and does not require olink.
+# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393
+# for an explanation on documents classification.
+#
+
+# DocBook/XML generated output formats to be installed
+shelf_DATA =
+
+# DocBook/XML file with chapters, appendix and images it includes
+dist_shelf_DATA = $(docbook) $(chapters)
+
+#
+# Generate DocBook/XML output formats with or without stylesheets
+#
+
+# Stylesheets are available if the package xorg-sgml-doctools is installed
+if HAVE_STYLESHEETS
+
+# The location where all cross reference databases are installed
+sgmldbsdir = $(XORG_SGML_PATH)/X11/dbs
+masterdb = "$(sgmldbsdir)/masterdb$(suffix $@).xml"
+XMLTO_FLAGS = \
+ --searchpath "$(XORG_SGML_PATH)/X11" \
+ --stringparam target.database.document=$(masterdb) \
+ --stringparam current.docid="$(<:.xml=)" \
+ --stringparam collect.xref.targets="no"
+
+XMLTO_XHTML_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl \
+ --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
+
+XMLTO_FO_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+endif HAVE_STYLESHEETS
+
+shelf_DATA += $(docbook:.xml=.html)
+%.html: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) xhtml-nochunks $<
+
+if HAVE_FOP
+shelf_DATA += $(docbook:.xml=.pdf) $(docbook:.xml=.ps)
+%.pdf: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop pdf $<
+%.ps: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop ps $<
+endif HAVE_FOP
+
+if HAVE_XMLTO_TEXT
+shelf_DATA += $(docbook:.xml=.txt)
+%.txt: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) txt $<
+endif HAVE_XMLTO_TEXT
+
+#
+# Generate documents cross-reference target databases
+#
+
+# This is only possible if the xorg-sgml-doctools package is installed
+if HAVE_STYLESHEETS
+if HAVE_XSLTPROC
+
+# DocBook/XML generated document cross-reference database
+sgmldbs_DATA = $(docbook:.xml=.html.db) $(docbook:.xml=.fo.db)
+
+# Generate DocBook/XML document cross-reference database
+# Flags for the XSL Transformation processor generating xref target databases
+XSLTPROC_FLAGS = \
+ --path "$(XORG_SGML_PATH)/X11" \
+ --stringparam targets.filename "$@" \
+ --stringparam collect.xref.targets "only" \
+ --nonet --xinclude
+
+%.html.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $<
+
+%.fo.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl $<
+
+endif HAVE_XSLTPROC
+endif HAVE_STYLESHEETS
+
+CLEANFILES = $(shelf_DATA) $(sgmldbs_DATA)
diff --git a/libXext/configure.ac b/libXext/configure.ac
index 5dae4f695..aa8730726 100644
--- a/libXext/configure.ac
+++ b/libXext/configure.ac
@@ -13,15 +13,16 @@ AM_MAINTAINER_MODE
# Initialize libtool
AC_PROG_LIBTOOL
-# Require xorg-macros minimum of 1.10 for DocBook XML documentation
+# Require xorg-macros minimum of 1.12 for DocBook external references
m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.10)
+ [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.12)
XORG_DEFAULT_OPTIONS
XORG_ENABLE_SPECS
-XORG_WITH_XMLTO(0.0.20)
+XORG_WITH_XMLTO(0.0.22)
XORG_WITH_FOP
-XORG_CHECK_SGML_DOCTOOLS(1.5)
+XORG_WITH_XSLTPROC
+XORG_CHECK_SGML_DOCTOOLS(1.7)
XORG_CHECK_MALLOC_ZERO
# Determine .so library version per platform
diff --git a/libXext/docbook.am b/libXext/docbook.am
new file mode 100644
index 000000000..3cf21e879
--- /dev/null
+++ b/libXext/docbook.am
@@ -0,0 +1,95 @@
+#
+# Generate output formats for a single DocBook/XML with/without chapters
+#
+# Variables set by the calling Makefile:
+# shelfdir: the location where the docs/specs are installed. Typically $(docdir)
+# docbook: the main DocBook/XML file, no chapters, appendix or image files
+# chapters: all files pulled in by an XInclude statement and images.
+#
+
+#
+# This makefile is intended for Users Documentation and Functional Specifications.
+# Do not use for Developer Documentation which is not installed and does not require olink.
+# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393
+# for an explanation on documents classification.
+#
+
+# DocBook/XML generated output formats to be installed
+shelf_DATA =
+
+# DocBook/XML file with chapters, appendix and images it includes
+dist_shelf_DATA = $(docbook) $(chapters)
+
+#
+# Generate DocBook/XML output formats with or without stylesheets
+#
+
+# Stylesheets are available if the package xorg-sgml-doctools is installed
+if HAVE_STYLESHEETS
+
+# The location where all cross reference databases are installed
+sgmldbsdir = $(XORG_SGML_PATH)/X11/dbs
+masterdb = "$(sgmldbsdir)/masterdb$(suffix $@).xml"
+XMLTO_FLAGS = \
+ --searchpath "$(XORG_SGML_PATH)/X11" \
+ --stringparam target.database.document=$(masterdb) \
+ --stringparam current.docid="$(<:.xml=)" \
+ --stringparam collect.xref.targets="no"
+
+XMLTO_XHTML_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl \
+ --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
+
+XMLTO_FO_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+endif HAVE_STYLESHEETS
+
+shelf_DATA += $(docbook:.xml=.html)
+%.html: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) xhtml-nochunks $<
+
+if HAVE_FOP
+shelf_DATA += $(docbook:.xml=.pdf) $(docbook:.xml=.ps)
+%.pdf: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop pdf $<
+%.ps: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop ps $<
+endif HAVE_FOP
+
+if HAVE_XMLTO_TEXT
+shelf_DATA += $(docbook:.xml=.txt)
+%.txt: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) txt $<
+endif HAVE_XMLTO_TEXT
+
+#
+# Generate documents cross-reference target databases
+#
+
+# This is only possible if the xorg-sgml-doctools package is installed
+if HAVE_STYLESHEETS
+if HAVE_XSLTPROC
+
+# DocBook/XML generated document cross-reference database
+sgmldbs_DATA = $(docbook:.xml=.html.db) $(docbook:.xml=.fo.db)
+
+# Generate DocBook/XML document cross-reference database
+# Flags for the XSL Transformation processor generating xref target databases
+XSLTPROC_FLAGS = \
+ --path "$(XORG_SGML_PATH)/X11" \
+ --stringparam targets.filename "$@" \
+ --stringparam collect.xref.targets "only" \
+ --nonet --xinclude
+
+%.html.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $<
+
+%.fo.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl $<
+
+endif HAVE_XSLTPROC
+endif HAVE_STYLESHEETS
+
+CLEANFILES = $(shelf_DATA) $(sgmldbs_DATA)
diff --git a/libXext/specs/Makefile.am b/libXext/specs/Makefile.am
index 10dbed24f..659b5d217 100644
--- a/libXext/specs/Makefile.am
+++ b/libXext/specs/Makefile.am
@@ -1,61 +1,15 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-if ENABLE_SPECS
-doc_sources = dbelib.xml dpmslib.xml shapelib.xml synclib.xml xtest1.xml
-dist_doc_DATA = $(doc_sources)
-
-if HAVE_XMLTO
-doc_DATA = $(doc_sources:.xml=.html)
-
-if HAVE_FOP
-doc_DATA += $(doc_sources:.xml=.ps) $(doc_sources:.xml=.pdf)
-endif
-
-if HAVE_XMLTO_TEXT
-doc_DATA += $(doc_sources:.xml=.txt)
-endif
-
-if HAVE_STYLESHEETS
-XMLTO_FLAGS = -m $(XSL_STYLESHEET) \
- --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
-endif
-
-CLEANFILES = $(doc_DATA)
-
-SUFFIXES = .xml .ps .pdf .txt .html
-
-.xml.txt:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) txt $<
-
-.xml.html:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) xhtml-nochunks $<
-
-.xml.pdf:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop pdf $<
-
-.xml.ps:
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop ps $<
-
-endif HAVE_XMLTO
-endif ENABLE_SPECS
+
+if ENABLE_SPECS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = dbelib.xml dpmslib.xml shapelib.xml synclib.xml xtest1.xml
+
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_SPECS
diff --git a/libXmu/configure.ac b/libXmu/configure.ac
index 880fc5a2e..a665dbca5 100644
--- a/libXmu/configure.ac
+++ b/libXmu/configure.ac
@@ -13,15 +13,16 @@ AM_MAINTAINER_MODE
# Initialize libtool
AC_PROG_LIBTOOL
-# Require xorg-macros minimum of 1.10 for HAVE_STYLESHEETS in XORG_CHECK_SGML_DOCTOOLS
+# Require xorg-macros minimum of 1.12 for DocBook external references
m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.10)
+ [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.12)
XORG_DEFAULT_OPTIONS
XORG_ENABLE_DOCS
-XORG_WITH_XMLTO(0.0.20)
+XORG_WITH_XMLTO(0.0.22)
XORG_WITH_FOP
-XORG_CHECK_SGML_DOCTOOLS(1.5)
+XORG_WITH_XSLTPROC
+XORG_CHECK_SGML_DOCTOOLS(1.7)
# Obtain compiler/linker options for depedencies
PKG_CHECK_MODULES(XMU, xt xext x11 xextproto)
diff --git a/libXmu/doc/Makefile.am b/libXmu/doc/Makefile.am
index 83685dcc7..a8363ca3e 100644
--- a/libXmu/doc/Makefile.am
+++ b/libXmu/doc/Makefile.am
@@ -1,61 +1,18 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
if ENABLE_DOCS
-dist_doc_DATA = Xmu.xml xlogo.svg
-
if HAVE_XMLTO
-doc_DATA = Xmu.html
-
-if HAVE_FOP
-doc_DATA += Xmu.pdf Xmu.ps
-endif
-
-if HAVE_XMLTO_TEXT
-doc_DATA += Xmu.txt
-endif
-
-CLEANFILES = Xmu.txt Xmu.html Xmu.pdf Xmu.ps xorg.css
-
-if HAVE_STYLESHEETS
-XMLTO_FLAGS = \
- -m $(XSL_STYLESHEET) \
- --stringparam img.src.path=$(abs_builddir)/ \
- --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
-endif
-XML_SOURCEFILES = $(srcdir)/Xmu.xml $(XSL_STYLESHEET)
+# Main DocBook/XML files (DOCTYPE book)
+docbook = Xmu.xml
-Xmu.txt: $(XML_SOURCEFILES)
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) txt $(srcdir)/Xmu.xml
+# Included chapters, appendix, images
+chapters = xlogo.svg
-Xmu.html: $(XML_SOURCEFILES)
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) xhtml-nochunks $(srcdir)/Xmu.xml
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)
-Xmu.pdf: $(XML_SOURCEFILES)
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop pdf $(srcdir)/Xmu.xml
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
-Xmu.ps: $(XML_SOURCEFILES)
- $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop ps $(srcdir)/Xmu.xml
endif HAVE_XMLTO
endif ENABLE_DOCS
diff --git a/libXmu/docbook.am b/libXmu/docbook.am
new file mode 100644
index 000000000..3cf21e879
--- /dev/null
+++ b/libXmu/docbook.am
@@ -0,0 +1,95 @@
+#
+# Generate output formats for a single DocBook/XML with/without chapters
+#
+# Variables set by the calling Makefile:
+# shelfdir: the location where the docs/specs are installed. Typically $(docdir)
+# docbook: the main DocBook/XML file, no chapters, appendix or image files
+# chapters: all files pulled in by an XInclude statement and images.
+#
+
+#
+# This makefile is intended for Users Documentation and Functional Specifications.
+# Do not use for Developer Documentation which is not installed and does not require olink.
+# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393
+# for an explanation on documents classification.
+#
+
+# DocBook/XML generated output formats to be installed
+shelf_DATA =
+
+# DocBook/XML file with chapters, appendix and images it includes
+dist_shelf_DATA = $(docbook) $(chapters)
+
+#
+# Generate DocBook/XML output formats with or without stylesheets
+#
+
+# Stylesheets are available if the package xorg-sgml-doctools is installed
+if HAVE_STYLESHEETS
+
+# The location where all cross reference databases are installed
+sgmldbsdir = $(XORG_SGML_PATH)/X11/dbs
+masterdb = "$(sgmldbsdir)/masterdb$(suffix $@).xml"
+XMLTO_FLAGS = \
+ --searchpath "$(XORG_SGML_PATH)/X11" \
+ --stringparam target.database.document=$(masterdb) \
+ --stringparam current.docid="$(<:.xml=)" \
+ --stringparam collect.xref.targets="no"
+
+XMLTO_XHTML_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl \
+ --stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
+
+XMLTO_FO_FLAGS = \
+ -x $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+endif HAVE_STYLESHEETS
+
+shelf_DATA += $(docbook:.xml=.html)
+%.html: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) xhtml-nochunks $<
+
+if HAVE_FOP
+shelf_DATA += $(docbook:.xml=.pdf) $(docbook:.xml=.ps)
+%.pdf: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop pdf $<
+%.ps: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop ps $<
+endif HAVE_FOP
+
+if HAVE_XMLTO_TEXT
+shelf_DATA += $(docbook:.xml=.txt)
+%.txt: %.xml $(chapters)
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) txt $<
+endif HAVE_XMLTO_TEXT
+
+#
+# Generate documents cross-reference target databases
+#
+
+# This is only possible if the xorg-sgml-doctools package is installed
+if HAVE_STYLESHEETS
+if HAVE_XSLTPROC
+
+# DocBook/XML generated document cross-reference database
+sgmldbs_DATA = $(docbook:.xml=.html.db) $(docbook:.xml=.fo.db)
+
+# Generate DocBook/XML document cross-reference database
+# Flags for the XSL Transformation processor generating xref target databases
+XSLTPROC_FLAGS = \
+ --path "$(XORG_SGML_PATH)/X11" \
+ --stringparam targets.filename "$@" \
+ --stringparam collect.xref.targets "only" \
+ --nonet --xinclude
+
+%.html.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $<
+
+%.fo.db: %.xml $(chapters)
+ $(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+ http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl $<
+
+endif HAVE_XSLTPROC
+endif HAVE_STYLESHEETS
+
+CLEANFILES = $(shelf_DATA) $(sgmldbs_DATA)
diff --git a/mesalib/src/mesa/program/prog_optimize.c b/mesalib/src/mesa/program/prog_optimize.c
index 892f5b6ec..164297a34 100644
--- a/mesalib/src/mesa/program/prog_optimize.c
+++ b/mesalib/src/mesa/program/prog_optimize.c
@@ -1,1250 +1,1261 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.5
- *
- * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VMWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-
-#include "main/glheader.h"
-#include "main/context.h"
-#include "main/macros.h"
-#include "program.h"
-#include "prog_instruction.h"
-#include "prog_optimize.h"
-#include "prog_print.h"
-
-
-#define MAX_LOOP_NESTING 50
-/* MAX_PROGRAM_TEMPS is a low number (256), and we want to be able to
- * register allocate many temporary values into that small number of
- * temps. So allow large temporary indices coming into the register
- * allocator.
- */
-#define REG_ALLOCATE_MAX_PROGRAM_TEMPS ((1 << INST_INDEX_BITS) - 1)
-
-static GLboolean dbg = GL_FALSE;
-
-#define NO_MASK 0xf
-
-/**
- * Returns the mask of channels (bitmask of WRITEMASK_X,Y,Z,W) which
- * are read from the given src in this instruction, We also provide
- * one optional masks which may mask other components in the dst
- * register
- */
-static GLuint
-get_src_arg_mask(const struct prog_instruction *inst,
- GLuint arg, GLuint dst_mask)
-{
- GLuint read_mask, channel_mask;
- GLuint comp;
-
- ASSERT(arg < _mesa_num_inst_src_regs(inst->Opcode));
-
- /* Form the dst register, find the written channels */
- if (inst->CondUpdate) {
- channel_mask = WRITEMASK_XYZW;
- }
- else {
- switch (inst->Opcode) {
- case OPCODE_MOV:
- case OPCODE_MIN:
- case OPCODE_MAX:
- case OPCODE_ABS:
- case OPCODE_ADD:
- case OPCODE_MAD:
- case OPCODE_MUL:
- case OPCODE_SUB:
- channel_mask = inst->DstReg.WriteMask & dst_mask;
- break;
- case OPCODE_RCP:
- case OPCODE_SIN:
- case OPCODE_COS:
- case OPCODE_RSQ:
- case OPCODE_POW:
- case OPCODE_EX2:
- case OPCODE_LOG:
- channel_mask = WRITEMASK_X;
- break;
- case OPCODE_DP2:
- channel_mask = WRITEMASK_XY;
- break;
- case OPCODE_DP3:
- case OPCODE_XPD:
- channel_mask = WRITEMASK_XYZ;
- break;
- default:
- channel_mask = WRITEMASK_XYZW;
- break;
- }
- }
-
- /* Now, given the src swizzle and the written channels, find which
- * components are actually read
- */
- read_mask = 0x0;
- for (comp = 0; comp < 4; ++comp) {
- const GLuint coord = GET_SWZ(inst->SrcReg[arg].Swizzle, comp);
- ASSERT(coord < 4);
- if (channel_mask & (1 << comp) && coord <= SWIZZLE_W)
- read_mask |= 1 << coord;
- }
-
- return read_mask;
-}
-
-
-/**
- * For a MOV instruction, compute a write mask when src register also has
- * a mask
- */
-static GLuint
-get_dst_mask_for_mov(const struct prog_instruction *mov, GLuint src_mask)
-{
- const GLuint mask = mov->DstReg.WriteMask;
- GLuint comp;
- GLuint updated_mask = 0x0;
-
- ASSERT(mov->Opcode == OPCODE_MOV);
-
- for (comp = 0; comp < 4; ++comp) {
- GLuint src_comp;
- if ((mask & (1 << comp)) == 0)
- continue;
- src_comp = GET_SWZ(mov->SrcReg[0].Swizzle, comp);
- if ((src_mask & (1 << src_comp)) == 0)
- continue;
- updated_mask |= 1 << comp;
- }
-
- return updated_mask;
-}
-
-
-/**
- * Ensure that the swizzle is regular. That is, all of the swizzle
- * terms are SWIZZLE_X,Y,Z,W and not SWIZZLE_ZERO or SWIZZLE_ONE.
- */
-static GLboolean
-is_swizzle_regular(GLuint swz)
-{
- return GET_SWZ(swz,0) <= SWIZZLE_W &&
- GET_SWZ(swz,1) <= SWIZZLE_W &&
- GET_SWZ(swz,2) <= SWIZZLE_W &&
- GET_SWZ(swz,3) <= SWIZZLE_W;
-}
-
-
-/**
- * In 'prog' remove instruction[i] if removeFlags[i] == TRUE.
- * \return number of instructions removed
- */
-static GLuint
-remove_instructions(struct gl_program *prog, const GLboolean *removeFlags)
-{
- GLint i, removeEnd = 0, removeCount = 0;
- GLuint totalRemoved = 0;
-
- /* go backward */
- for (i = prog->NumInstructions - 1; i >= 0; i--) {
- if (removeFlags[i]) {
- totalRemoved++;
- if (removeCount == 0) {
- /* begin a run of instructions to remove */
- removeEnd = i;
- removeCount = 1;
- }
- else {
- /* extend the run of instructions to remove */
- removeCount++;
- }
- }
- else {
- /* don't remove this instruction, but check if the preceeding
- * instructions are to be removed.
- */
- if (removeCount > 0) {
- GLint removeStart = removeEnd - removeCount + 1;
- _mesa_delete_instructions(prog, removeStart, removeCount);
- removeStart = removeCount = 0; /* reset removal info */
- }
- }
- }
- /* Finish removing if the first instruction was to be removed. */
- if (removeCount > 0) {
- GLint removeStart = removeEnd - removeCount + 1;
- _mesa_delete_instructions(prog, removeStart, removeCount);
- }
- return totalRemoved;
-}
-
-
-/**
- * Remap register indexes according to map.
- * \param prog the program to search/replace
- * \param file the type of register file to search/replace
- * \param map maps old register indexes to new indexes
- */
-static void
-replace_regs(struct gl_program *prog, gl_register_file file, const GLint map[])
-{
- GLuint i;
-
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
- const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
- GLuint j;
- for (j = 0; j < numSrc; j++) {
- if (inst->SrcReg[j].File == file) {
- GLuint index = inst->SrcReg[j].Index;
- ASSERT(map[index] >= 0);
- inst->SrcReg[j].Index = map[index];
- }
- }
- if (inst->DstReg.File == file) {
- const GLuint index = inst->DstReg.Index;
- ASSERT(map[index] >= 0);
- inst->DstReg.Index = map[index];
- }
- }
-}
-
-
-/**
- * Remove dead instructions from the given program.
- * This is very primitive for now. Basically look for temp registers
- * that are written to but never read. Remove any instructions that
- * write to such registers. Be careful with condition code setters.
- */
-static GLboolean
-_mesa_remove_dead_code_global(struct gl_program *prog)
-{
- GLboolean tempRead[REG_ALLOCATE_MAX_PROGRAM_TEMPS][4];
- GLboolean *removeInst; /* per-instruction removal flag */
- GLuint i, rem = 0, comp;
-
- memset(tempRead, 0, sizeof(tempRead));
-
- if (dbg) {
- printf("Optimize: Begin dead code removal\n");
- /*_mesa_print_program(prog);*/
- }
-
- removeInst = (GLboolean *)
- calloc(1, prog->NumInstructions * sizeof(GLboolean));
-
- /* Determine which temps are read and written */
- for (i = 0; i < prog->NumInstructions; i++) {
- const struct prog_instruction *inst = prog->Instructions + i;
- const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
- GLuint j;
-
- /* check src regs */
- for (j = 0; j < numSrc; j++) {
- if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
- const GLuint index = inst->SrcReg[j].Index;
- GLuint read_mask;
- ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
- read_mask = get_src_arg_mask(inst, j, NO_MASK);
-
- if (inst->SrcReg[j].RelAddr) {
- if (dbg)
- printf("abort remove dead code (indirect temp)\n");
- goto done;
- }
-
- for (comp = 0; comp < 4; comp++) {
- const GLuint swz = GET_SWZ(inst->SrcReg[j].Swizzle, comp);
- ASSERT(swz < 4);
- if ((read_mask & (1 << swz)) == 0)
- continue;
- if (swz <= SWIZZLE_W)
- tempRead[index][swz] = GL_TRUE;
- }
- }
- }
-
- /* check dst reg */
- if (inst->DstReg.File == PROGRAM_TEMPORARY) {
- const GLuint index = inst->DstReg.Index;
- ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
-
- if (inst->DstReg.RelAddr) {
- if (dbg)
- printf("abort remove dead code (indirect temp)\n");
- goto done;
- }
-
- if (inst->CondUpdate) {
- /* If we're writing to this register and setting condition
- * codes we cannot remove the instruction. Prevent removal
- * by setting the 'read' flag.
- */
- tempRead[index][0] = GL_TRUE;
- tempRead[index][1] = GL_TRUE;
- tempRead[index][2] = GL_TRUE;
- tempRead[index][3] = GL_TRUE;
- }
- }
- }
-
- /* find instructions that write to dead registers, flag for removal */
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
- const GLuint numDst = _mesa_num_inst_dst_regs(inst->Opcode);
-
- if (numDst != 0 && inst->DstReg.File == PROGRAM_TEMPORARY) {
- GLint chan, index = inst->DstReg.Index;
-
- for (chan = 0; chan < 4; chan++) {
- if (!tempRead[index][chan] &&
- inst->DstReg.WriteMask & (1 << chan)) {
- if (dbg) {
- printf("Remove writemask on %u.%c\n", i,
- chan == 3 ? 'w' : 'x' + chan);
- }
- inst->DstReg.WriteMask &= ~(1 << chan);
- rem++;
- }
- }
-
- if (inst->DstReg.WriteMask == 0) {
- /* If we cleared all writes, the instruction can be removed. */
- if (dbg)
- printf("Remove instruction %u: \n", i);
- removeInst[i] = GL_TRUE;
- }
- }
- }
-
- /* now remove the instructions which aren't needed */
- rem = remove_instructions(prog, removeInst);
-
- if (dbg) {
- printf("Optimize: End dead code removal.\n");
- printf(" %u channel writes removed\n", rem);
- printf(" %u instructions removed\n", rem);
- /*_mesa_print_program(prog);*/
- }
-
-done:
- free(removeInst);
- return rem != 0;
-}
-
-
-enum inst_use
-{
- READ,
- WRITE,
- FLOW,
- END
-};
-
-
-/**
- * Scan forward in program from 'start' for the next occurances of TEMP[index].
- * We look if an instruction reads the component given by the masks and if they
- * are overwritten.
- * Return READ, WRITE, FLOW or END to indicate the next usage or an indicator
- * that we can't look further.
- */
-static enum inst_use
-find_next_use(const struct gl_program *prog,
- GLuint start,
- GLuint index,
- GLuint mask)
-{
- GLuint i;
-
- for (i = start; i < prog->NumInstructions; i++) {
- const struct prog_instruction *inst = prog->Instructions + i;
- switch (inst->Opcode) {
- case OPCODE_BGNLOOP:
- case OPCODE_BGNSUB:
- case OPCODE_BRA:
- case OPCODE_CAL:
- case OPCODE_CONT:
- case OPCODE_IF:
- case OPCODE_ELSE:
- case OPCODE_ENDIF:
- case OPCODE_ENDLOOP:
- case OPCODE_ENDSUB:
- case OPCODE_RET:
- return FLOW;
- case OPCODE_END:
- return END;
- default:
- {
- const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
- GLuint j;
- for (j = 0; j < numSrc; j++) {
- if (inst->SrcReg[j].RelAddr ||
- (inst->SrcReg[j].File == PROGRAM_TEMPORARY &&
- inst->SrcReg[j].Index == index &&
- (get_src_arg_mask(inst,j,NO_MASK) & mask)))
- return READ;
- }
- if (_mesa_num_inst_dst_regs(inst->Opcode) == 1 &&
- inst->DstReg.File == PROGRAM_TEMPORARY &&
- inst->DstReg.Index == index) {
- mask &= ~inst->DstReg.WriteMask;
- if (mask == 0)
- return WRITE;
- }
- }
- }
- }
- return END;
-}
-
-
-/**
- * Is the given instruction opcode a flow-control opcode?
- * XXX maybe move this into prog_instruction.[ch]
- */
-static GLboolean
-_mesa_is_flow_control_opcode(enum prog_opcode opcode)
-{
- switch (opcode) {
- case OPCODE_BGNLOOP:
- case OPCODE_BGNSUB:
- case OPCODE_BRA:
- case OPCODE_CAL:
- case OPCODE_CONT:
- case OPCODE_IF:
- case OPCODE_ELSE:
- case OPCODE_END:
- case OPCODE_ENDIF:
- case OPCODE_ENDLOOP:
- case OPCODE_ENDSUB:
- case OPCODE_RET:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given instruction is a simple MOV (no conditional updating,
- * not relative addressing, no negation/abs, etc).
- */
-static GLboolean
-can_downward_mov_be_modifed(const struct prog_instruction *mov)
-{
- return
- mov->Opcode == OPCODE_MOV &&
- mov->CondUpdate == GL_FALSE &&
- mov->SrcReg[0].RelAddr == 0 &&
- mov->SrcReg[0].Negate == 0 &&
- mov->SrcReg[0].Abs == 0 &&
- mov->SrcReg[0].HasIndex2 == 0 &&
- mov->SrcReg[0].RelAddr2 == 0 &&
- mov->DstReg.RelAddr == 0 &&
- mov->DstReg.CondMask == COND_TR &&
- mov->SaturateMode == SATURATE_OFF;
-}
-
-
-static GLboolean
-can_upward_mov_be_modifed(const struct prog_instruction *mov)
-{
- return
- can_downward_mov_be_modifed(mov) &&
- mov->DstReg.File == PROGRAM_TEMPORARY;
-}
-
-
-/**
- * Try to remove use of extraneous MOV instructions, to free them up for dead
- * code removal.
- */
-static void
-_mesa_remove_extra_move_use(struct gl_program *prog)
-{
- GLuint i, j;
-
- if (dbg) {
- printf("Optimize: Begin remove extra move use\n");
- _mesa_print_program(prog);
- }
-
- /*
- * Look for sequences such as this:
- * MOV tmpX, arg0;
- * ...
- * FOO tmpY, tmpX, arg1;
- * and convert into:
- * MOV tmpX, arg0;
- * ...
- * FOO tmpY, arg0, arg1;
- */
-
- for (i = 0; i + 1 < prog->NumInstructions; i++) {
- const struct prog_instruction *mov = prog->Instructions + i;
- GLuint dst_mask, src_mask;
- if (can_upward_mov_be_modifed(mov) == GL_FALSE)
- continue;
-
- /* Scanning the code, we maintain the components which are still active in
- * these two masks
- */
- dst_mask = mov->DstReg.WriteMask;
- src_mask = get_src_arg_mask(mov, 0, NO_MASK);
-
- /* Walk through remaining instructions until the or src reg gets
- * rewritten or we get into some flow-control, eliminating the use of
- * this MOV.
- */
- for (j = i + 1; j < prog->NumInstructions; j++) {
- struct prog_instruction *inst2 = prog->Instructions + j;
- GLuint arg;
-
- if (_mesa_is_flow_control_opcode(inst2->Opcode))
- break;
-
- /* First rewrite this instruction's args if appropriate. */
- for (arg = 0; arg < _mesa_num_inst_src_regs(inst2->Opcode); arg++) {
- GLuint comp, read_mask;
-
- if (inst2->SrcReg[arg].File != mov->DstReg.File ||
- inst2->SrcReg[arg].Index != mov->DstReg.Index ||
- inst2->SrcReg[arg].RelAddr ||
- inst2->SrcReg[arg].Abs)
- continue;
- read_mask = get_src_arg_mask(inst2, arg, NO_MASK);
-
- /* Adjust the swizzles of inst2 to point at MOV's source if ALL the
- * components read still come from the mov instructions
- */
- if (is_swizzle_regular(inst2->SrcReg[arg].Swizzle) &&
- (read_mask & dst_mask) == read_mask) {
- for (comp = 0; comp < 4; comp++) {
- const GLuint inst2_swz =
- GET_SWZ(inst2->SrcReg[arg].Swizzle, comp);
- const GLuint s = GET_SWZ(mov->SrcReg[0].Swizzle, inst2_swz);
- inst2->SrcReg[arg].Swizzle &= ~(7 << (3 * comp));
- inst2->SrcReg[arg].Swizzle |= s << (3 * comp);
- inst2->SrcReg[arg].Negate ^= (((mov->SrcReg[0].Negate >>
- inst2_swz) & 0x1) << comp);
- }
- inst2->SrcReg[arg].File = mov->SrcReg[0].File;
- inst2->SrcReg[arg].Index = mov->SrcReg[0].Index;
- }
- }
-
- /* The source of MOV is written. This potentially deactivates some
- * components from the src and dst of the MOV instruction
- */
- if (inst2->DstReg.File == mov->DstReg.File &&
- (inst2->DstReg.RelAddr ||
- inst2->DstReg.Index == mov->DstReg.Index)) {
- dst_mask &= ~inst2->DstReg.WriteMask;
- src_mask = get_src_arg_mask(mov, 0, dst_mask);
- }
-
- /* Idem when the destination of mov is written */
- if (inst2->DstReg.File == mov->SrcReg[0].File &&
- (inst2->DstReg.RelAddr ||
- inst2->DstReg.Index == mov->SrcReg[0].Index)) {
- src_mask &= ~inst2->DstReg.WriteMask;
- dst_mask &= get_dst_mask_for_mov(mov, src_mask);
- }
- if (dst_mask == 0)
- break;
- }
- }
-
- if (dbg) {
- printf("Optimize: End remove extra move use.\n");
- /*_mesa_print_program(prog);*/
- }
-}
-
-
-/**
- * Complements dead_code_global. Try to remove code in block of code by
- * carefully monitoring the swizzles. Both functions should be merged into one
- * with a proper control flow graph
- */
-static GLboolean
-_mesa_remove_dead_code_local(struct gl_program *prog)
-{
- GLboolean *removeInst;
- GLuint i, arg, rem = 0;
-
- removeInst = (GLboolean *)
- calloc(1, prog->NumInstructions * sizeof(GLboolean));
-
- for (i = 0; i < prog->NumInstructions; i++) {
- const struct prog_instruction *inst = prog->Instructions + i;
- const GLuint index = inst->DstReg.Index;
- const GLuint mask = inst->DstReg.WriteMask;
- enum inst_use use;
-
- /* We must deactivate the pass as soon as some indirection is used */
- if (inst->DstReg.RelAddr)
- goto done;
- for (arg = 0; arg < _mesa_num_inst_src_regs(inst->Opcode); arg++)
- if (inst->SrcReg[arg].RelAddr)
- goto done;
-
- if (_mesa_is_flow_control_opcode(inst->Opcode) ||
- _mesa_num_inst_dst_regs(inst->Opcode) == 0 ||
- inst->DstReg.File != PROGRAM_TEMPORARY ||
- inst->DstReg.RelAddr)
- continue;
-
- use = find_next_use(prog, i+1, index, mask);
- if (use == WRITE || use == END)
- removeInst[i] = GL_TRUE;
- }
-
- rem = remove_instructions(prog, removeInst);
-
-done:
- free(removeInst);
- return rem != 0;
-}
-
-
-/**
- * Try to inject the destination of mov as the destination of inst and recompute
- * the swizzles operators for the sources of inst if required. Return GL_TRUE
- * of the substitution was possible, GL_FALSE otherwise
- */
-static GLboolean
-_mesa_merge_mov_into_inst(struct prog_instruction *inst,
- const struct prog_instruction *mov)
-{
- /* Indirection table which associates destination and source components for
- * the mov instruction
- */
- const GLuint mask = get_src_arg_mask(mov, 0, NO_MASK);
-
- /* Some components are not written by inst. We cannot remove the mov */
- if (mask != (inst->DstReg.WriteMask & mask))
- return GL_FALSE;
-
- /* Depending on the instruction, we may need to recompute the swizzles.
- * Also, some other instructions (like TEX) are not linear. We will only
- * consider completely active sources and destinations
- */
- switch (inst->Opcode) {
-
- /* Carstesian instructions: we compute the swizzle */
- case OPCODE_MOV:
- case OPCODE_MIN:
- case OPCODE_MAX:
- case OPCODE_ABS:
- case OPCODE_ADD:
- case OPCODE_MAD:
- case OPCODE_MUL:
- case OPCODE_SUB:
- {
- GLuint dst_to_src_comp[4] = {0,0,0,0};
- GLuint dst_comp, arg;
- for (dst_comp = 0; dst_comp < 4; ++dst_comp) {
- if (mov->DstReg.WriteMask & (1 << dst_comp)) {
- const GLuint src_comp = GET_SWZ(mov->SrcReg[0].Swizzle, dst_comp);
- ASSERT(src_comp < 4);
- dst_to_src_comp[dst_comp] = src_comp;
- }
- }
-
- /* Patch each source of the instruction */
- for (arg = 0; arg < _mesa_num_inst_src_regs(inst->Opcode); arg++) {
- const GLuint arg_swz = inst->SrcReg[arg].Swizzle;
- inst->SrcReg[arg].Swizzle = 0;
-
- /* Reset each active component of the swizzle */
- for (dst_comp = 0; dst_comp < 4; ++dst_comp) {
- GLuint src_comp, arg_comp;
- if ((mov->DstReg.WriteMask & (1 << dst_comp)) == 0)
- continue;
- src_comp = dst_to_src_comp[dst_comp];
- ASSERT(src_comp < 4);
- arg_comp = GET_SWZ(arg_swz, src_comp);
- ASSERT(arg_comp < 4);
- inst->SrcReg[arg].Swizzle |= arg_comp << (3*dst_comp);
- }
- }
- inst->DstReg = mov->DstReg;
- return GL_TRUE;
- }
-
- /* Dot products and scalar instructions: we only change the destination */
- case OPCODE_RCP:
- case OPCODE_SIN:
- case OPCODE_COS:
- case OPCODE_RSQ:
- case OPCODE_POW:
- case OPCODE_EX2:
- case OPCODE_LOG:
- case OPCODE_DP2:
- case OPCODE_DP3:
- case OPCODE_DP4:
- inst->DstReg = mov->DstReg;
- return GL_TRUE;
-
- /* All other instructions require fully active components with no swizzle */
- default:
- if (mov->SrcReg[0].Swizzle != SWIZZLE_XYZW ||
- inst->DstReg.WriteMask != WRITEMASK_XYZW)
- return GL_FALSE;
- inst->DstReg = mov->DstReg;
- return GL_TRUE;
- }
-}
-
-
-/**
- * Try to remove extraneous MOV instructions from the given program.
- */
-static GLboolean
-_mesa_remove_extra_moves(struct gl_program *prog)
-{
- GLboolean *removeInst; /* per-instruction removal flag */
- GLuint i, rem = 0, nesting = 0;
-
- if (dbg) {
- printf("Optimize: Begin remove extra moves\n");
- _mesa_print_program(prog);
- }
-
- removeInst = (GLboolean *)
- calloc(1, prog->NumInstructions * sizeof(GLboolean));
-
- /*
- * Look for sequences such as this:
- * FOO tmpX, arg0, arg1;
- * MOV tmpY, tmpX;
- * and convert into:
- * FOO tmpY, arg0, arg1;
- */
-
- for (i = 0; i < prog->NumInstructions; i++) {
- const struct prog_instruction *mov = prog->Instructions + i;
-
- switch (mov->Opcode) {
- case OPCODE_BGNLOOP:
- case OPCODE_BGNSUB:
- case OPCODE_IF:
- nesting++;
- break;
- case OPCODE_ENDLOOP:
- case OPCODE_ENDSUB:
- case OPCODE_ENDIF:
- nesting--;
- break;
- case OPCODE_MOV:
- if (i > 0 &&
- can_downward_mov_be_modifed(mov) &&
- mov->SrcReg[0].File == PROGRAM_TEMPORARY &&
- nesting == 0)
- {
-
- /* see if this MOV can be removed */
- const GLuint id = mov->SrcReg[0].Index;
- struct prog_instruction *prevInst;
- GLuint prevI;
-
- /* get pointer to previous instruction */
- prevI = i - 1;
- while (prevI > 0 && removeInst[prevI])
- prevI--;
- prevInst = prog->Instructions + prevI;
-
- if (prevInst->DstReg.File == PROGRAM_TEMPORARY &&
- prevInst->DstReg.Index == id &&
- prevInst->DstReg.RelAddr == 0 &&
- prevInst->DstReg.CondSrc == 0 &&
- prevInst->DstReg.CondMask == COND_TR) {
-
- const GLuint dst_mask = prevInst->DstReg.WriteMask;
- enum inst_use next_use = find_next_use(prog, i+1, id, dst_mask);
-
- if (next_use == WRITE || next_use == END) {
- /* OK, we can safely remove this MOV instruction.
- * Transform:
- * prevI: FOO tempIndex, x, y;
- * i: MOV z, tempIndex;
- * Into:
- * prevI: FOO z, x, y;
- */
- if (_mesa_merge_mov_into_inst(prevInst, mov)) {
- removeInst[i] = GL_TRUE;
- if (dbg) {
- printf("Remove MOV at %u\n", i);
- printf("new prev inst %u: ", prevI);
- _mesa_print_instruction(prevInst);
- }
- }
- }
- }
- }
- break;
- default:
- ; /* nothing */
- }
- }
-
- /* now remove the instructions which aren't needed */
- rem = remove_instructions(prog, removeInst);
-
- free(removeInst);
-
- if (dbg) {
- printf("Optimize: End remove extra moves. %u instructions removed\n", rem);
- /*_mesa_print_program(prog);*/
- }
-
- return rem != 0;
-}
-
-
-/** A live register interval */
-struct interval
-{
- GLuint Reg; /** The temporary register index */
- GLuint Start, End; /** Start/end instruction numbers */
-};
-
-
-/** A list of register intervals */
-struct interval_list
-{
- GLuint Num;
- struct interval Intervals[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
-};
-
-
-static void
-append_interval(struct interval_list *list, const struct interval *inv)
-{
- list->Intervals[list->Num++] = *inv;
-}
-
-
-/** Insert interval inv into list, sorted by interval end */
-static void
-insert_interval_by_end(struct interval_list *list, const struct interval *inv)
-{
- /* XXX we could do a binary search insertion here since list is sorted */
- GLint i = list->Num - 1;
- while (i >= 0 && list->Intervals[i].End > inv->End) {
- list->Intervals[i + 1] = list->Intervals[i];
- i--;
- }
- list->Intervals[i + 1] = *inv;
- list->Num++;
-
-#ifdef DEBUG
- {
- GLuint i;
- for (i = 0; i + 1 < list->Num; i++) {
- ASSERT(list->Intervals[i].End <= list->Intervals[i + 1].End);
- }
- }
-#endif
-}
-
-
-/** Remove the given interval from the interval list */
-static void
-remove_interval(struct interval_list *list, const struct interval *inv)
-{
- /* XXX we could binary search since list is sorted */
- GLuint k;
- for (k = 0; k < list->Num; k++) {
- if (list->Intervals[k].Reg == inv->Reg) {
- /* found, remove it */
- ASSERT(list->Intervals[k].Start == inv->Start);
- ASSERT(list->Intervals[k].End == inv->End);
- while (k < list->Num - 1) {
- list->Intervals[k] = list->Intervals[k + 1];
- k++;
- }
- list->Num--;
- return;
- }
- }
-}
-
-
-/** called by qsort() */
-static int
-compare_start(const void *a, const void *b)
-{
- const struct interval *ia = (const struct interval *) a;
- const struct interval *ib = (const struct interval *) b;
- if (ia->Start < ib->Start)
- return -1;
- else if (ia->Start > ib->Start)
- return +1;
- else
- return 0;
-}
-
-
-/** sort the interval list according to interval starts */
-static void
-sort_interval_list_by_start(struct interval_list *list)
-{
- qsort(list->Intervals, list->Num, sizeof(struct interval), compare_start);
-#ifdef DEBUG
- {
- GLuint i;
- for (i = 0; i + 1 < list->Num; i++) {
- ASSERT(list->Intervals[i].Start <= list->Intervals[i + 1].Start);
- }
- }
-#endif
-}
-
-struct loop_info
-{
- GLuint Start, End; /**< Start, end instructions of loop */
-};
-
-/**
- * Update the intermediate interval info for register 'index' and
- * instruction 'ic'.
- */
-static void
-update_interval(GLint intBegin[], GLint intEnd[],
- struct loop_info *loopStack, GLuint loopStackDepth,
- GLuint index, GLuint ic)
-{
- int i;
-
- /* If the register is used in a loop, extend its lifetime through the end
- * of the outermost loop that doesn't contain its definition.
- */
- for (i = 0; i < loopStackDepth; i++) {
- if (intBegin[index] < loopStack[i].Start) {
- ic = loopStack[i].End;
- break;
- }
- }
-
- ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
- if (intBegin[index] == -1) {
- ASSERT(intEnd[index] == -1);
- intBegin[index] = intEnd[index] = ic;
- }
- else {
- intEnd[index] = ic;
- }
-}
-
-
-/**
- * Find first/last instruction that references each temporary register.
- */
-GLboolean
-_mesa_find_temp_intervals(const struct prog_instruction *instructions,
- GLuint numInstructions,
- GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS],
- GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS])
-{
- struct loop_info loopStack[MAX_LOOP_NESTING];
- GLuint loopStackDepth = 0;
- GLuint i;
-
- for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){
- intBegin[i] = intEnd[i] = -1;
- }
-
- /* Scan instructions looking for temporary registers */
- for (i = 0; i < numInstructions; i++) {
- const struct prog_instruction *inst = instructions + i;
- if (inst->Opcode == OPCODE_BGNLOOP) {
- loopStack[loopStackDepth].Start = i;
- loopStack[loopStackDepth].End = inst->BranchTarget;
- loopStackDepth++;
- }
- else if (inst->Opcode == OPCODE_ENDLOOP) {
- loopStackDepth--;
- }
- else if (inst->Opcode == OPCODE_CAL) {
- return GL_FALSE;
- }
- else {
- const GLuint numSrc = 3;/*_mesa_num_inst_src_regs(inst->Opcode);*/
- GLuint j;
- for (j = 0; j < numSrc; j++) {
- if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
- const GLuint index = inst->SrcReg[j].Index;
- if (inst->SrcReg[j].RelAddr)
- return GL_FALSE;
- update_interval(intBegin, intEnd, loopStack, loopStackDepth,
- index, i);
- }
- }
- if (inst->DstReg.File == PROGRAM_TEMPORARY) {
- const GLuint index = inst->DstReg.Index;
- if (inst->DstReg.RelAddr)
- return GL_FALSE;
- update_interval(intBegin, intEnd, loopStack, loopStackDepth,
- index, i);
- }
- }
- }
-
- return GL_TRUE;
-}
-
-
-/**
- * Find the live intervals for each temporary register in the program.
- * For register R, the interval [A,B] indicates that R is referenced
- * from instruction A through instruction B.
- * Special consideration is needed for loops and subroutines.
- * \return GL_TRUE if success, GL_FALSE if we cannot proceed for some reason
- */
-static GLboolean
-find_live_intervals(struct gl_program *prog,
- struct interval_list *liveIntervals)
-{
- GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
- GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
- GLuint i;
-
- /*
- * Note: we'll return GL_FALSE below if we find relative indexing
- * into the TEMP register file. We can't handle that yet.
- * We also give up on subroutines for now.
- */
-
- if (dbg) {
- printf("Optimize: Begin find intervals\n");
- }
-
- /* build intermediate arrays */
- if (!_mesa_find_temp_intervals(prog->Instructions, prog->NumInstructions,
- intBegin, intEnd))
- return GL_FALSE;
-
- /* Build live intervals list from intermediate arrays */
- liveIntervals->Num = 0;
- for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++) {
- if (intBegin[i] >= 0) {
- struct interval inv;
- inv.Reg = i;
- inv.Start = intBegin[i];
- inv.End = intEnd[i];
- append_interval(liveIntervals, &inv);
- }
- }
-
- /* Sort the list according to interval starts */
- sort_interval_list_by_start(liveIntervals);
-
- if (dbg) {
- /* print interval info */
- for (i = 0; i < liveIntervals->Num; i++) {
- const struct interval *inv = liveIntervals->Intervals + i;
- printf("Reg[%d] live [%d, %d]:",
- inv->Reg, inv->Start, inv->End);
- if (1) {
- GLuint j;
- for (j = 0; j < inv->Start; j++)
- printf(" ");
- for (j = inv->Start; j <= inv->End; j++)
- printf("x");
- }
- printf("\n");
- }
- }
-
- return GL_TRUE;
-}
-
-
-/** Scan the array of used register flags to find free entry */
-static GLint
-alloc_register(GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS])
-{
- GLuint k;
- for (k = 0; k < REG_ALLOCATE_MAX_PROGRAM_TEMPS; k++) {
- if (!usedRegs[k]) {
- usedRegs[k] = GL_TRUE;
- return k;
- }
- }
- return -1;
-}
-
-
-/**
- * This function implements "Linear Scan Register Allocation" to reduce
- * the number of temporary registers used by the program.
- *
- * We compute the "live interval" for all temporary registers then
- * examine the overlap of the intervals to allocate new registers.
- * Basically, if two intervals do not overlap, they can use the same register.
- */
-static void
-_mesa_reallocate_registers(struct gl_program *prog)
-{
- struct interval_list liveIntervals;
- GLint registerMap[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
- GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
- GLuint i;
- GLint maxTemp = -1;
-
- if (dbg) {
- printf("Optimize: Begin live-interval register reallocation\n");
- _mesa_print_program(prog);
- }
-
- for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){
- registerMap[i] = -1;
- usedRegs[i] = GL_FALSE;
- }
-
- if (!find_live_intervals(prog, &liveIntervals)) {
- if (dbg)
- printf("Aborting register reallocation\n");
- return;
- }
-
- {
- struct interval_list activeIntervals;
- activeIntervals.Num = 0;
-
- /* loop over live intervals, allocating a new register for each */
- for (i = 0; i < liveIntervals.Num; i++) {
- const struct interval *live = liveIntervals.Intervals + i;
-
- if (dbg)
- printf("Consider register %u\n", live->Reg);
-
- /* Expire old intervals. Intervals which have ended with respect
- * to the live interval can have their remapped registers freed.
- */
- {
- GLint j;
- for (j = 0; j < (GLint) activeIntervals.Num; j++) {
- const struct interval *inv = activeIntervals.Intervals + j;
- if (inv->End >= live->Start) {
- /* Stop now. Since the activeInterval list is sorted
- * we know we don't have to go further.
- */
- break;
- }
- else {
- /* Interval 'inv' has expired */
- const GLint regNew = registerMap[inv->Reg];
- ASSERT(regNew >= 0);
-
- if (dbg)
- printf(" expire interval for reg %u\n", inv->Reg);
-
- /* remove interval j from active list */
- remove_interval(&activeIntervals, inv);
- j--; /* counter-act j++ in for-loop above */
-
- /* return register regNew to the free pool */
- if (dbg)
- printf(" free reg %d\n", regNew);
- ASSERT(usedRegs[regNew] == GL_TRUE);
- usedRegs[regNew] = GL_FALSE;
- }
- }
- }
-
- /* find a free register for this live interval */
- {
- const GLint k = alloc_register(usedRegs);
- if (k < 0) {
- /* out of registers, give up */
- return;
- }
- registerMap[live->Reg] = k;
- maxTemp = MAX2(maxTemp, k);
- if (dbg)
- printf(" remap register %u -> %d\n", live->Reg, k);
- }
-
- /* Insert this live interval into the active list which is sorted
- * by increasing end points.
- */
- insert_interval_by_end(&activeIntervals, live);
- }
- }
-
- if (maxTemp + 1 < (GLint) liveIntervals.Num) {
- /* OK, we've reduced the number of registers needed.
- * Scan the program and replace all the old temporary register
- * indexes with the new indexes.
- */
- replace_regs(prog, PROGRAM_TEMPORARY, registerMap);
-
- prog->NumTemporaries = maxTemp + 1;
- }
-
- if (dbg) {
- printf("Optimize: End live-interval register reallocation\n");
- printf("Num temp regs before: %u after: %u\n",
- liveIntervals.Num, maxTemp + 1);
- _mesa_print_program(prog);
- }
-}
-
-
-#if 0
-static void
-print_it(struct gl_context *ctx, struct gl_program *program, const char *txt) {
- fprintf(stderr, "%s (%u inst):\n", txt, program->NumInstructions);
- _mesa_print_program(program);
- _mesa_print_program_parameters(ctx, program);
- fprintf(stderr, "\n\n");
-}
-#endif
-
-
-/**
- * Apply optimizations to the given program to eliminate unnecessary
- * instructions, temp regs, etc.
- */
-void
-_mesa_optimize_program(struct gl_context *ctx, struct gl_program *program)
-{
- GLboolean any_change;
-
- /* Stop when no modifications were output */
- do {
- any_change = GL_FALSE;
- _mesa_remove_extra_move_use(program);
- if (_mesa_remove_dead_code_global(program))
- any_change = GL_TRUE;
- if (_mesa_remove_extra_moves(program))
- any_change = GL_TRUE;
- if (_mesa_remove_dead_code_local(program))
- any_change = GL_TRUE;
- _mesa_reallocate_registers(program);
- } while (any_change);
-}
-
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.5
+ *
+ * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * VMWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "program.h"
+#include "prog_instruction.h"
+#include "prog_optimize.h"
+#include "prog_print.h"
+
+
+#define MAX_LOOP_NESTING 50
+/* MAX_PROGRAM_TEMPS is a low number (256), and we want to be able to
+ * register allocate many temporary values into that small number of
+ * temps. So allow large temporary indices coming into the register
+ * allocator.
+ */
+#define REG_ALLOCATE_MAX_PROGRAM_TEMPS ((1 << INST_INDEX_BITS) - 1)
+
+static GLboolean dbg = GL_FALSE;
+
+#define NO_MASK 0xf
+
+/**
+ * Returns the mask of channels (bitmask of WRITEMASK_X,Y,Z,W) which
+ * are read from the given src in this instruction, We also provide
+ * one optional masks which may mask other components in the dst
+ * register
+ */
+static GLuint
+get_src_arg_mask(const struct prog_instruction *inst,
+ GLuint arg, GLuint dst_mask)
+{
+ GLuint read_mask, channel_mask;
+ GLuint comp;
+
+ ASSERT(arg < _mesa_num_inst_src_regs(inst->Opcode));
+
+ /* Form the dst register, find the written channels */
+ if (inst->CondUpdate) {
+ channel_mask = WRITEMASK_XYZW;
+ }
+ else {
+ switch (inst->Opcode) {
+ case OPCODE_MOV:
+ case OPCODE_MIN:
+ case OPCODE_MAX:
+ case OPCODE_ABS:
+ case OPCODE_ADD:
+ case OPCODE_MAD:
+ case OPCODE_MUL:
+ case OPCODE_SUB:
+ channel_mask = inst->DstReg.WriteMask & dst_mask;
+ break;
+ case OPCODE_RCP:
+ case OPCODE_SIN:
+ case OPCODE_COS:
+ case OPCODE_RSQ:
+ case OPCODE_POW:
+ case OPCODE_EX2:
+ case OPCODE_LOG:
+ channel_mask = WRITEMASK_X;
+ break;
+ case OPCODE_DP2:
+ channel_mask = WRITEMASK_XY;
+ break;
+ case OPCODE_DP3:
+ case OPCODE_XPD:
+ channel_mask = WRITEMASK_XYZ;
+ break;
+ default:
+ channel_mask = WRITEMASK_XYZW;
+ break;
+ }
+ }
+
+ /* Now, given the src swizzle and the written channels, find which
+ * components are actually read
+ */
+ read_mask = 0x0;
+ for (comp = 0; comp < 4; ++comp) {
+ const GLuint coord = GET_SWZ(inst->SrcReg[arg].Swizzle, comp);
+ ASSERT(coord < 4);
+ if (channel_mask & (1 << comp) && coord <= SWIZZLE_W)
+ read_mask |= 1 << coord;
+ }
+
+ return read_mask;
+}
+
+
+/**
+ * For a MOV instruction, compute a write mask when src register also has
+ * a mask
+ */
+static GLuint
+get_dst_mask_for_mov(const struct prog_instruction *mov, GLuint src_mask)
+{
+ const GLuint mask = mov->DstReg.WriteMask;
+ GLuint comp;
+ GLuint updated_mask = 0x0;
+
+ ASSERT(mov->Opcode == OPCODE_MOV);
+
+ for (comp = 0; comp < 4; ++comp) {
+ GLuint src_comp;
+ if ((mask & (1 << comp)) == 0)
+ continue;
+ src_comp = GET_SWZ(mov->SrcReg[0].Swizzle, comp);
+ if ((src_mask & (1 << src_comp)) == 0)
+ continue;
+ updated_mask |= 1 << comp;
+ }
+
+ return updated_mask;
+}
+
+
+/**
+ * Ensure that the swizzle is regular. That is, all of the swizzle
+ * terms are SWIZZLE_X,Y,Z,W and not SWIZZLE_ZERO or SWIZZLE_ONE.
+ */
+static GLboolean
+is_swizzle_regular(GLuint swz)
+{
+ return GET_SWZ(swz,0) <= SWIZZLE_W &&
+ GET_SWZ(swz,1) <= SWIZZLE_W &&
+ GET_SWZ(swz,2) <= SWIZZLE_W &&
+ GET_SWZ(swz,3) <= SWIZZLE_W;
+}
+
+
+/**
+ * In 'prog' remove instruction[i] if removeFlags[i] == TRUE.
+ * \return number of instructions removed
+ */
+static GLuint
+remove_instructions(struct gl_program *prog, const GLboolean *removeFlags)
+{
+ GLint i, removeEnd = 0, removeCount = 0;
+ GLuint totalRemoved = 0;
+
+ /* go backward */
+ for (i = prog->NumInstructions - 1; i >= 0; i--) {
+ if (removeFlags[i]) {
+ totalRemoved++;
+ if (removeCount == 0) {
+ /* begin a run of instructions to remove */
+ removeEnd = i;
+ removeCount = 1;
+ }
+ else {
+ /* extend the run of instructions to remove */
+ removeCount++;
+ }
+ }
+ else {
+ /* don't remove this instruction, but check if the preceeding
+ * instructions are to be removed.
+ */
+ if (removeCount > 0) {
+ GLint removeStart = removeEnd - removeCount + 1;
+ _mesa_delete_instructions(prog, removeStart, removeCount);
+ removeStart = removeCount = 0; /* reset removal info */
+ }
+ }
+ }
+ /* Finish removing if the first instruction was to be removed. */
+ if (removeCount > 0) {
+ GLint removeStart = removeEnd - removeCount + 1;
+ _mesa_delete_instructions(prog, removeStart, removeCount);
+ }
+ return totalRemoved;
+}
+
+
+/**
+ * Remap register indexes according to map.
+ * \param prog the program to search/replace
+ * \param file the type of register file to search/replace
+ * \param map maps old register indexes to new indexes
+ */
+static void
+replace_regs(struct gl_program *prog, gl_register_file file, const GLint map[])
+{
+ GLuint i;
+
+ for (i = 0; i < prog->NumInstructions; i++) {
+ struct prog_instruction *inst = prog->Instructions + i;
+ const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
+ GLuint j;
+ for (j = 0; j < numSrc; j++) {
+ if (inst->SrcReg[j].File == file) {
+ GLuint index = inst->SrcReg[j].Index;
+ ASSERT(map[index] >= 0);
+ inst->SrcReg[j].Index = map[index];
+ }
+ }
+ if (inst->DstReg.File == file) {
+ const GLuint index = inst->DstReg.Index;
+ ASSERT(map[index] >= 0);
+ inst->DstReg.Index = map[index];
+ }
+ }
+}
+
+
+/**
+ * Remove dead instructions from the given program.
+ * This is very primitive for now. Basically look for temp registers
+ * that are written to but never read. Remove any instructions that
+ * write to such registers. Be careful with condition code setters.
+ */
+static GLboolean
+_mesa_remove_dead_code_global(struct gl_program *prog)
+{
+ GLboolean tempRead[REG_ALLOCATE_MAX_PROGRAM_TEMPS][4];
+ GLboolean *removeInst; /* per-instruction removal flag */
+ GLuint i, rem = 0, comp;
+
+ memset(tempRead, 0, sizeof(tempRead));
+
+ if (dbg) {
+ printf("Optimize: Begin dead code removal\n");
+ /*_mesa_print_program(prog);*/
+ }
+
+ removeInst = (GLboolean *)
+ calloc(1, prog->NumInstructions * sizeof(GLboolean));
+
+ /* Determine which temps are read and written */
+ for (i = 0; i < prog->NumInstructions; i++) {
+ const struct prog_instruction *inst = prog->Instructions + i;
+ const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
+ GLuint j;
+
+ /* check src regs */
+ for (j = 0; j < numSrc; j++) {
+ if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
+ const GLuint index = inst->SrcReg[j].Index;
+ GLuint read_mask;
+ ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
+ read_mask = get_src_arg_mask(inst, j, NO_MASK);
+
+ if (inst->SrcReg[j].RelAddr) {
+ if (dbg)
+ printf("abort remove dead code (indirect temp)\n");
+ goto done;
+ }
+
+ for (comp = 0; comp < 4; comp++) {
+ const GLuint swz = GET_SWZ(inst->SrcReg[j].Swizzle, comp);
+ ASSERT(swz < 4);
+ if ((read_mask & (1 << swz)) == 0)
+ continue;
+ if (swz <= SWIZZLE_W)
+ tempRead[index][swz] = GL_TRUE;
+ }
+ }
+ }
+
+ /* check dst reg */
+ if (inst->DstReg.File == PROGRAM_TEMPORARY) {
+ const GLuint index = inst->DstReg.Index;
+ ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
+
+ if (inst->DstReg.RelAddr) {
+ if (dbg)
+ printf("abort remove dead code (indirect temp)\n");
+ goto done;
+ }
+
+ if (inst->CondUpdate) {
+ /* If we're writing to this register and setting condition
+ * codes we cannot remove the instruction. Prevent removal
+ * by setting the 'read' flag.
+ */
+ tempRead[index][0] = GL_TRUE;
+ tempRead[index][1] = GL_TRUE;
+ tempRead[index][2] = GL_TRUE;
+ tempRead[index][3] = GL_TRUE;
+ }
+ }
+ }
+
+ /* find instructions that write to dead registers, flag for removal */
+ for (i = 0; i < prog->NumInstructions; i++) {
+ struct prog_instruction *inst = prog->Instructions + i;
+ const GLuint numDst = _mesa_num_inst_dst_regs(inst->Opcode);
+
+ if (numDst != 0 && inst->DstReg.File == PROGRAM_TEMPORARY) {
+ GLint chan, index = inst->DstReg.Index;
+
+ for (chan = 0; chan < 4; chan++) {
+ if (!tempRead[index][chan] &&
+ inst->DstReg.WriteMask & (1 << chan)) {
+ if (dbg) {
+ printf("Remove writemask on %u.%c\n", i,
+ chan == 3 ? 'w' : 'x' + chan);
+ }
+ inst->DstReg.WriteMask &= ~(1 << chan);
+ rem++;
+ }
+ }
+
+ if (inst->DstReg.WriteMask == 0) {
+ /* If we cleared all writes, the instruction can be removed. */
+ if (dbg)
+ printf("Remove instruction %u: \n", i);
+ removeInst[i] = GL_TRUE;
+ }
+ }
+ }
+
+ /* now remove the instructions which aren't needed */
+ rem = remove_instructions(prog, removeInst);
+
+ if (dbg) {
+ printf("Optimize: End dead code removal.\n");
+ printf(" %u channel writes removed\n", rem);
+ printf(" %u instructions removed\n", rem);
+ /*_mesa_print_program(prog);*/
+ }
+
+done:
+ free(removeInst);
+ return rem != 0;
+}
+
+
+enum inst_use
+{
+ READ,
+ WRITE,
+ FLOW,
+ END
+};
+
+
+/**
+ * Scan forward in program from 'start' for the next occurances of TEMP[index].
+ * We look if an instruction reads the component given by the masks and if they
+ * are overwritten.
+ * Return READ, WRITE, FLOW or END to indicate the next usage or an indicator
+ * that we can't look further.
+ */
+static enum inst_use
+find_next_use(const struct gl_program *prog,
+ GLuint start,
+ GLuint index,
+ GLuint mask)
+{
+ GLuint i;
+
+ for (i = start; i < prog->NumInstructions; i++) {
+ const struct prog_instruction *inst = prog->Instructions + i;
+ switch (inst->Opcode) {
+ case OPCODE_BGNLOOP:
+ case OPCODE_BGNSUB:
+ case OPCODE_BRA:
+ case OPCODE_CAL:
+ case OPCODE_CONT:
+ case OPCODE_IF:
+ case OPCODE_ELSE:
+ case OPCODE_ENDIF:
+ case OPCODE_ENDLOOP:
+ case OPCODE_ENDSUB:
+ case OPCODE_RET:
+ return FLOW;
+ case OPCODE_END:
+ return END;
+ default:
+ {
+ const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
+ GLuint j;
+ for (j = 0; j < numSrc; j++) {
+ if (inst->SrcReg[j].RelAddr ||
+ (inst->SrcReg[j].File == PROGRAM_TEMPORARY &&
+ inst->SrcReg[j].Index == index &&
+ (get_src_arg_mask(inst,j,NO_MASK) & mask)))
+ return READ;
+ }
+ if (_mesa_num_inst_dst_regs(inst->Opcode) == 1 &&
+ inst->DstReg.File == PROGRAM_TEMPORARY &&
+ inst->DstReg.Index == index) {
+ mask &= ~inst->DstReg.WriteMask;
+ if (mask == 0)
+ return WRITE;
+ }
+ }
+ }
+ }
+ return END;
+}
+
+
+/**
+ * Is the given instruction opcode a flow-control opcode?
+ * XXX maybe move this into prog_instruction.[ch]
+ */
+static GLboolean
+_mesa_is_flow_control_opcode(enum prog_opcode opcode)
+{
+ switch (opcode) {
+ case OPCODE_BGNLOOP:
+ case OPCODE_BGNSUB:
+ case OPCODE_BRA:
+ case OPCODE_CAL:
+ case OPCODE_CONT:
+ case OPCODE_IF:
+ case OPCODE_ELSE:
+ case OPCODE_END:
+ case OPCODE_ENDIF:
+ case OPCODE_ENDLOOP:
+ case OPCODE_ENDSUB:
+ case OPCODE_RET:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given instruction is a simple MOV (no conditional updating,
+ * not relative addressing, no negation/abs, etc).
+ */
+static GLboolean
+can_downward_mov_be_modifed(const struct prog_instruction *mov)
+{
+ return
+ mov->Opcode == OPCODE_MOV &&
+ mov->CondUpdate == GL_FALSE &&
+ mov->SrcReg[0].RelAddr == 0 &&
+ mov->SrcReg[0].Negate == 0 &&
+ mov->SrcReg[0].Abs == 0 &&
+ mov->SrcReg[0].HasIndex2 == 0 &&
+ mov->SrcReg[0].RelAddr2 == 0 &&
+ mov->DstReg.RelAddr == 0 &&
+ mov->DstReg.CondMask == COND_TR &&
+ mov->SaturateMode == SATURATE_OFF;
+}
+
+
+static GLboolean
+can_upward_mov_be_modifed(const struct prog_instruction *mov)
+{
+ return
+ can_downward_mov_be_modifed(mov) &&
+ mov->DstReg.File == PROGRAM_TEMPORARY;
+}
+
+
+/**
+ * Try to remove use of extraneous MOV instructions, to free them up for dead
+ * code removal.
+ */
+static void
+_mesa_remove_extra_move_use(struct gl_program *prog)
+{
+ GLuint i, j;
+
+ if (dbg) {
+ printf("Optimize: Begin remove extra move use\n");
+ _mesa_print_program(prog);
+ }
+
+ /*
+ * Look for sequences such as this:
+ * MOV tmpX, arg0;
+ * ...
+ * FOO tmpY, tmpX, arg1;
+ * and convert into:
+ * MOV tmpX, arg0;
+ * ...
+ * FOO tmpY, arg0, arg1;
+ */
+
+ for (i = 0; i + 1 < prog->NumInstructions; i++) {
+ const struct prog_instruction *mov = prog->Instructions + i;
+ GLuint dst_mask, src_mask;
+ if (can_upward_mov_be_modifed(mov) == GL_FALSE)
+ continue;
+
+ /* Scanning the code, we maintain the components which are still active in
+ * these two masks
+ */
+ dst_mask = mov->DstReg.WriteMask;
+ src_mask = get_src_arg_mask(mov, 0, NO_MASK);
+
+ /* Walk through remaining instructions until the or src reg gets
+ * rewritten or we get into some flow-control, eliminating the use of
+ * this MOV.
+ */
+ for (j = i + 1; j < prog->NumInstructions; j++) {
+ struct prog_instruction *inst2 = prog->Instructions + j;
+ GLuint arg;
+
+ if (_mesa_is_flow_control_opcode(inst2->Opcode))
+ break;
+
+ /* First rewrite this instruction's args if appropriate. */
+ for (arg = 0; arg < _mesa_num_inst_src_regs(inst2->Opcode); arg++) {
+ GLuint comp, read_mask;
+
+ if (inst2->SrcReg[arg].File != mov->DstReg.File ||
+ inst2->SrcReg[arg].Index != mov->DstReg.Index ||
+ inst2->SrcReg[arg].RelAddr ||
+ inst2->SrcReg[arg].Abs)
+ continue;
+ read_mask = get_src_arg_mask(inst2, arg, NO_MASK);
+
+ /* Adjust the swizzles of inst2 to point at MOV's source if ALL the
+ * components read still come from the mov instructions
+ */
+ if (is_swizzle_regular(inst2->SrcReg[arg].Swizzle) &&
+ (read_mask & dst_mask) == read_mask) {
+ for (comp = 0; comp < 4; comp++) {
+ const GLuint inst2_swz =
+ GET_SWZ(inst2->SrcReg[arg].Swizzle, comp);
+ const GLuint s = GET_SWZ(mov->SrcReg[0].Swizzle, inst2_swz);
+ inst2->SrcReg[arg].Swizzle &= ~(7 << (3 * comp));
+ inst2->SrcReg[arg].Swizzle |= s << (3 * comp);
+ inst2->SrcReg[arg].Negate ^= (((mov->SrcReg[0].Negate >>
+ inst2_swz) & 0x1) << comp);
+ }
+ inst2->SrcReg[arg].File = mov->SrcReg[0].File;
+ inst2->SrcReg[arg].Index = mov->SrcReg[0].Index;
+ }
+ }
+
+ /* The source of MOV is written. This potentially deactivates some
+ * components from the src and dst of the MOV instruction
+ */
+ if (inst2->DstReg.File == mov->DstReg.File &&
+ (inst2->DstReg.RelAddr ||
+ inst2->DstReg.Index == mov->DstReg.Index)) {
+ dst_mask &= ~inst2->DstReg.WriteMask;
+ src_mask = get_src_arg_mask(mov, 0, dst_mask);
+ }
+
+ /* Idem when the destination of mov is written */
+ if (inst2->DstReg.File == mov->SrcReg[0].File &&
+ (inst2->DstReg.RelAddr ||
+ inst2->DstReg.Index == mov->SrcReg[0].Index)) {
+ src_mask &= ~inst2->DstReg.WriteMask;
+ dst_mask &= get_dst_mask_for_mov(mov, src_mask);
+ }
+ if (dst_mask == 0)
+ break;
+ }
+ }
+
+ if (dbg) {
+ printf("Optimize: End remove extra move use.\n");
+ /*_mesa_print_program(prog);*/
+ }
+}
+
+
+/**
+ * Complements dead_code_global. Try to remove code in block of code by
+ * carefully monitoring the swizzles. Both functions should be merged into one
+ * with a proper control flow graph
+ */
+static GLboolean
+_mesa_remove_dead_code_local(struct gl_program *prog)
+{
+ GLboolean *removeInst;
+ GLuint i, arg, rem = 0;
+
+ removeInst = (GLboolean *)
+ calloc(1, prog->NumInstructions * sizeof(GLboolean));
+
+ for (i = 0; i < prog->NumInstructions; i++) {
+ const struct prog_instruction *inst = prog->Instructions + i;
+ const GLuint index = inst->DstReg.Index;
+ const GLuint mask = inst->DstReg.WriteMask;
+ enum inst_use use;
+
+ /* We must deactivate the pass as soon as some indirection is used */
+ if (inst->DstReg.RelAddr)
+ goto done;
+ for (arg = 0; arg < _mesa_num_inst_src_regs(inst->Opcode); arg++)
+ if (inst->SrcReg[arg].RelAddr)
+ goto done;
+
+ if (_mesa_is_flow_control_opcode(inst->Opcode) ||
+ _mesa_num_inst_dst_regs(inst->Opcode) == 0 ||
+ inst->DstReg.File != PROGRAM_TEMPORARY ||
+ inst->DstReg.RelAddr)
+ continue;
+
+ use = find_next_use(prog, i+1, index, mask);
+ if (use == WRITE || use == END)
+ removeInst[i] = GL_TRUE;
+ }
+
+ rem = remove_instructions(prog, removeInst);
+
+done:
+ free(removeInst);
+ return rem != 0;
+}
+
+
+/**
+ * Try to inject the destination of mov as the destination of inst and recompute
+ * the swizzles operators for the sources of inst if required. Return GL_TRUE
+ * of the substitution was possible, GL_FALSE otherwise
+ */
+static GLboolean
+_mesa_merge_mov_into_inst(struct prog_instruction *inst,
+ const struct prog_instruction *mov)
+{
+ /* Indirection table which associates destination and source components for
+ * the mov instruction
+ */
+ const GLuint mask = get_src_arg_mask(mov, 0, NO_MASK);
+
+ /* Some components are not written by inst. We cannot remove the mov */
+ if (mask != (inst->DstReg.WriteMask & mask))
+ return GL_FALSE;
+
+ /* Depending on the instruction, we may need to recompute the swizzles.
+ * Also, some other instructions (like TEX) are not linear. We will only
+ * consider completely active sources and destinations
+ */
+ switch (inst->Opcode) {
+
+ /* Carstesian instructions: we compute the swizzle */
+ case OPCODE_MOV:
+ case OPCODE_MIN:
+ case OPCODE_MAX:
+ case OPCODE_ABS:
+ case OPCODE_ADD:
+ case OPCODE_MAD:
+ case OPCODE_MUL:
+ case OPCODE_SUB:
+ {
+ GLuint dst_to_src_comp[4] = {0,0,0,0};
+ GLuint dst_comp, arg;
+ for (dst_comp = 0; dst_comp < 4; ++dst_comp) {
+ if (mov->DstReg.WriteMask & (1 << dst_comp)) {
+ const GLuint src_comp = GET_SWZ(mov->SrcReg[0].Swizzle, dst_comp);
+ ASSERT(src_comp < 4);
+ dst_to_src_comp[dst_comp] = src_comp;
+ }
+ }
+
+ /* Patch each source of the instruction */
+ for (arg = 0; arg < _mesa_num_inst_src_regs(inst->Opcode); arg++) {
+ const GLuint arg_swz = inst->SrcReg[arg].Swizzle;
+ inst->SrcReg[arg].Swizzle = 0;
+
+ /* Reset each active component of the swizzle */
+ for (dst_comp = 0; dst_comp < 4; ++dst_comp) {
+ GLuint src_comp, arg_comp;
+ if ((mov->DstReg.WriteMask & (1 << dst_comp)) == 0)
+ continue;
+ src_comp = dst_to_src_comp[dst_comp];
+ ASSERT(src_comp < 4);
+ arg_comp = GET_SWZ(arg_swz, src_comp);
+ ASSERT(arg_comp < 4);
+ inst->SrcReg[arg].Swizzle |= arg_comp << (3*dst_comp);
+ }
+ }
+ inst->DstReg = mov->DstReg;
+ return GL_TRUE;
+ }
+
+ /* Dot products and scalar instructions: we only change the destination */
+ case OPCODE_RCP:
+ case OPCODE_SIN:
+ case OPCODE_COS:
+ case OPCODE_RSQ:
+ case OPCODE_POW:
+ case OPCODE_EX2:
+ case OPCODE_LOG:
+ case OPCODE_DP2:
+ case OPCODE_DP3:
+ case OPCODE_DP4:
+ inst->DstReg = mov->DstReg;
+ return GL_TRUE;
+
+ /* All other instructions require fully active components with no swizzle */
+ default:
+ if (mov->SrcReg[0].Swizzle != SWIZZLE_XYZW ||
+ inst->DstReg.WriteMask != WRITEMASK_XYZW)
+ return GL_FALSE;
+ inst->DstReg = mov->DstReg;
+ return GL_TRUE;
+ }
+}
+
+
+/**
+ * Try to remove extraneous MOV instructions from the given program.
+ */
+static GLboolean
+_mesa_remove_extra_moves(struct gl_program *prog)
+{
+ GLboolean *removeInst; /* per-instruction removal flag */
+ GLuint i, rem = 0, nesting = 0;
+
+ if (dbg) {
+ printf("Optimize: Begin remove extra moves\n");
+ _mesa_print_program(prog);
+ }
+
+ removeInst = (GLboolean *)
+ calloc(1, prog->NumInstructions * sizeof(GLboolean));
+
+ /*
+ * Look for sequences such as this:
+ * FOO tmpX, arg0, arg1;
+ * MOV tmpY, tmpX;
+ * and convert into:
+ * FOO tmpY, arg0, arg1;
+ */
+
+ for (i = 0; i < prog->NumInstructions; i++) {
+ const struct prog_instruction *mov = prog->Instructions + i;
+
+ switch (mov->Opcode) {
+ case OPCODE_BGNLOOP:
+ case OPCODE_BGNSUB:
+ case OPCODE_IF:
+ nesting++;
+ break;
+ case OPCODE_ENDLOOP:
+ case OPCODE_ENDSUB:
+ case OPCODE_ENDIF:
+ nesting--;
+ break;
+ case OPCODE_MOV:
+ if (i > 0 &&
+ can_downward_mov_be_modifed(mov) &&
+ mov->SrcReg[0].File == PROGRAM_TEMPORARY &&
+ nesting == 0)
+ {
+
+ /* see if this MOV can be removed */
+ const GLuint id = mov->SrcReg[0].Index;
+ struct prog_instruction *prevInst;
+ GLuint prevI;
+
+ /* get pointer to previous instruction */
+ prevI = i - 1;
+ while (prevI > 0 && removeInst[prevI])
+ prevI--;
+ prevInst = prog->Instructions + prevI;
+
+ if (prevInst->DstReg.File == PROGRAM_TEMPORARY &&
+ prevInst->DstReg.Index == id &&
+ prevInst->DstReg.RelAddr == 0 &&
+ prevInst->DstReg.CondSrc == 0 &&
+ prevInst->DstReg.CondMask == COND_TR) {
+
+ const GLuint dst_mask = prevInst->DstReg.WriteMask;
+ enum inst_use next_use = find_next_use(prog, i+1, id, dst_mask);
+
+ if (next_use == WRITE || next_use == END) {
+ /* OK, we can safely remove this MOV instruction.
+ * Transform:
+ * prevI: FOO tempIndex, x, y;
+ * i: MOV z, tempIndex;
+ * Into:
+ * prevI: FOO z, x, y;
+ */
+ if (_mesa_merge_mov_into_inst(prevInst, mov)) {
+ removeInst[i] = GL_TRUE;
+ if (dbg) {
+ printf("Remove MOV at %u\n", i);
+ printf("new prev inst %u: ", prevI);
+ _mesa_print_instruction(prevInst);
+ }
+ }
+ }
+ }
+ }
+ break;
+ default:
+ ; /* nothing */
+ }
+ }
+
+ /* now remove the instructions which aren't needed */
+ rem = remove_instructions(prog, removeInst);
+
+ free(removeInst);
+
+ if (dbg) {
+ printf("Optimize: End remove extra moves. %u instructions removed\n", rem);
+ /*_mesa_print_program(prog);*/
+ }
+
+ return rem != 0;
+}
+
+
+/** A live register interval */
+struct interval
+{
+ GLuint Reg; /** The temporary register index */
+ GLuint Start, End; /** Start/end instruction numbers */
+};
+
+
+/** A list of register intervals */
+struct interval_list
+{
+ GLuint Num;
+ struct interval Intervals[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
+};
+
+
+static void
+append_interval(struct interval_list *list, const struct interval *inv)
+{
+ list->Intervals[list->Num++] = *inv;
+}
+
+
+/** Insert interval inv into list, sorted by interval end */
+static void
+insert_interval_by_end(struct interval_list *list, const struct interval *inv)
+{
+ /* XXX we could do a binary search insertion here since list is sorted */
+ GLint i = list->Num - 1;
+ while (i >= 0 && list->Intervals[i].End > inv->End) {
+ list->Intervals[i + 1] = list->Intervals[i];
+ i--;
+ }
+ list->Intervals[i + 1] = *inv;
+ list->Num++;
+
+#ifdef DEBUG
+ {
+ GLuint i;
+ for (i = 0; i + 1 < list->Num; i++) {
+ ASSERT(list->Intervals[i].End <= list->Intervals[i + 1].End);
+ }
+ }
+#endif
+}
+
+
+/** Remove the given interval from the interval list */
+static void
+remove_interval(struct interval_list *list, const struct interval *inv)
+{
+ /* XXX we could binary search since list is sorted */
+ GLuint k;
+ for (k = 0; k < list->Num; k++) {
+ if (list->Intervals[k].Reg == inv->Reg) {
+ /* found, remove it */
+ ASSERT(list->Intervals[k].Start == inv->Start);
+ ASSERT(list->Intervals[k].End == inv->End);
+ while (k < list->Num - 1) {
+ list->Intervals[k] = list->Intervals[k + 1];
+ k++;
+ }
+ list->Num--;
+ return;
+ }
+ }
+}
+
+
+/** called by qsort() */
+static int
+compare_start(const void *a, const void *b)
+{
+ const struct interval *ia = (const struct interval *) a;
+ const struct interval *ib = (const struct interval *) b;
+ if (ia->Start < ib->Start)
+ return -1;
+ else if (ia->Start > ib->Start)
+ return +1;
+ else
+ return 0;
+}
+
+
+/** sort the interval list according to interval starts */
+static void
+sort_interval_list_by_start(struct interval_list *list)
+{
+ qsort(list->Intervals, list->Num, sizeof(struct interval), compare_start);
+#ifdef DEBUG
+ {
+ GLuint i;
+ for (i = 0; i + 1 < list->Num; i++) {
+ ASSERT(list->Intervals[i].Start <= list->Intervals[i + 1].Start);
+ }
+ }
+#endif
+}
+
+struct loop_info
+{
+ GLuint Start, End; /**< Start, end instructions of loop */
+};
+
+/**
+ * Update the intermediate interval info for register 'index' and
+ * instruction 'ic'.
+ */
+static void
+update_interval(GLint intBegin[], GLint intEnd[],
+ struct loop_info *loopStack, GLuint loopStackDepth,
+ GLuint index, GLuint ic)
+{
+ int i;
+ GLuint begin = ic;
+ GLuint end = ic;
+
+ /* If the register is used in a loop, extend its lifetime through the end
+ * of the outermost loop that doesn't contain its definition.
+ */
+ for (i = 0; i < loopStackDepth; i++) {
+ if (intBegin[index] < loopStack[i].Start) {
+ end = loopStack[i].End;
+ break;
+ }
+ }
+
+ /* Variables that are live at the end of a loop will also be live at the
+ * beginning, so an instruction inside of a loop should have its live
+ * interval begin at the start of the outermost loop.
+ */
+ if (loopStackDepth > 0 && ic > loopStack[0].Start && ic < loopStack[0].End) {
+ begin = loopStack[0].Start;
+ }
+
+ ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
+ if (intBegin[index] == -1) {
+ ASSERT(intEnd[index] == -1);
+ intBegin[index] = begin;
+ intEnd[index] = end;
+ }
+ else {
+ intEnd[index] = end;
+ }
+}
+
+
+/**
+ * Find first/last instruction that references each temporary register.
+ */
+GLboolean
+_mesa_find_temp_intervals(const struct prog_instruction *instructions,
+ GLuint numInstructions,
+ GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS],
+ GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS])
+{
+ struct loop_info loopStack[MAX_LOOP_NESTING];
+ GLuint loopStackDepth = 0;
+ GLuint i;
+
+ for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){
+ intBegin[i] = intEnd[i] = -1;
+ }
+
+ /* Scan instructions looking for temporary registers */
+ for (i = 0; i < numInstructions; i++) {
+ const struct prog_instruction *inst = instructions + i;
+ if (inst->Opcode == OPCODE_BGNLOOP) {
+ loopStack[loopStackDepth].Start = i;
+ loopStack[loopStackDepth].End = inst->BranchTarget;
+ loopStackDepth++;
+ }
+ else if (inst->Opcode == OPCODE_ENDLOOP) {
+ loopStackDepth--;
+ }
+ else if (inst->Opcode == OPCODE_CAL) {
+ return GL_FALSE;
+ }
+ else {
+ const GLuint numSrc = 3;/*_mesa_num_inst_src_regs(inst->Opcode);*/
+ GLuint j;
+ for (j = 0; j < numSrc; j++) {
+ if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
+ const GLuint index = inst->SrcReg[j].Index;
+ if (inst->SrcReg[j].RelAddr)
+ return GL_FALSE;
+ update_interval(intBegin, intEnd, loopStack, loopStackDepth,
+ index, i);
+ }
+ }
+ if (inst->DstReg.File == PROGRAM_TEMPORARY) {
+ const GLuint index = inst->DstReg.Index;
+ if (inst->DstReg.RelAddr)
+ return GL_FALSE;
+ update_interval(intBegin, intEnd, loopStack, loopStackDepth,
+ index, i);
+ }
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Find the live intervals for each temporary register in the program.
+ * For register R, the interval [A,B] indicates that R is referenced
+ * from instruction A through instruction B.
+ * Special consideration is needed for loops and subroutines.
+ * \return GL_TRUE if success, GL_FALSE if we cannot proceed for some reason
+ */
+static GLboolean
+find_live_intervals(struct gl_program *prog,
+ struct interval_list *liveIntervals)
+{
+ GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
+ GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
+ GLuint i;
+
+ /*
+ * Note: we'll return GL_FALSE below if we find relative indexing
+ * into the TEMP register file. We can't handle that yet.
+ * We also give up on subroutines for now.
+ */
+
+ if (dbg) {
+ printf("Optimize: Begin find intervals\n");
+ }
+
+ /* build intermediate arrays */
+ if (!_mesa_find_temp_intervals(prog->Instructions, prog->NumInstructions,
+ intBegin, intEnd))
+ return GL_FALSE;
+
+ /* Build live intervals list from intermediate arrays */
+ liveIntervals->Num = 0;
+ for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++) {
+ if (intBegin[i] >= 0) {
+ struct interval inv;
+ inv.Reg = i;
+ inv.Start = intBegin[i];
+ inv.End = intEnd[i];
+ append_interval(liveIntervals, &inv);
+ }
+ }
+
+ /* Sort the list according to interval starts */
+ sort_interval_list_by_start(liveIntervals);
+
+ if (dbg) {
+ /* print interval info */
+ for (i = 0; i < liveIntervals->Num; i++) {
+ const struct interval *inv = liveIntervals->Intervals + i;
+ printf("Reg[%d] live [%d, %d]:",
+ inv->Reg, inv->Start, inv->End);
+ if (1) {
+ GLuint j;
+ for (j = 0; j < inv->Start; j++)
+ printf(" ");
+ for (j = inv->Start; j <= inv->End; j++)
+ printf("x");
+ }
+ printf("\n");
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+/** Scan the array of used register flags to find free entry */
+static GLint
+alloc_register(GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS])
+{
+ GLuint k;
+ for (k = 0; k < REG_ALLOCATE_MAX_PROGRAM_TEMPS; k++) {
+ if (!usedRegs[k]) {
+ usedRegs[k] = GL_TRUE;
+ return k;
+ }
+ }
+ return -1;
+}
+
+
+/**
+ * This function implements "Linear Scan Register Allocation" to reduce
+ * the number of temporary registers used by the program.
+ *
+ * We compute the "live interval" for all temporary registers then
+ * examine the overlap of the intervals to allocate new registers.
+ * Basically, if two intervals do not overlap, they can use the same register.
+ */
+static void
+_mesa_reallocate_registers(struct gl_program *prog)
+{
+ struct interval_list liveIntervals;
+ GLint registerMap[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
+ GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
+ GLuint i;
+ GLint maxTemp = -1;
+
+ if (dbg) {
+ printf("Optimize: Begin live-interval register reallocation\n");
+ _mesa_print_program(prog);
+ }
+
+ for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){
+ registerMap[i] = -1;
+ usedRegs[i] = GL_FALSE;
+ }
+
+ if (!find_live_intervals(prog, &liveIntervals)) {
+ if (dbg)
+ printf("Aborting register reallocation\n");
+ return;
+ }
+
+ {
+ struct interval_list activeIntervals;
+ activeIntervals.Num = 0;
+
+ /* loop over live intervals, allocating a new register for each */
+ for (i = 0; i < liveIntervals.Num; i++) {
+ const struct interval *live = liveIntervals.Intervals + i;
+
+ if (dbg)
+ printf("Consider register %u\n", live->Reg);
+
+ /* Expire old intervals. Intervals which have ended with respect
+ * to the live interval can have their remapped registers freed.
+ */
+ {
+ GLint j;
+ for (j = 0; j < (GLint) activeIntervals.Num; j++) {
+ const struct interval *inv = activeIntervals.Intervals + j;
+ if (inv->End >= live->Start) {
+ /* Stop now. Since the activeInterval list is sorted
+ * we know we don't have to go further.
+ */
+ break;
+ }
+ else {
+ /* Interval 'inv' has expired */
+ const GLint regNew = registerMap[inv->Reg];
+ ASSERT(regNew >= 0);
+
+ if (dbg)
+ printf(" expire interval for reg %u\n", inv->Reg);
+
+ /* remove interval j from active list */
+ remove_interval(&activeIntervals, inv);
+ j--; /* counter-act j++ in for-loop above */
+
+ /* return register regNew to the free pool */
+ if (dbg)
+ printf(" free reg %d\n", regNew);
+ ASSERT(usedRegs[regNew] == GL_TRUE);
+ usedRegs[regNew] = GL_FALSE;
+ }
+ }
+ }
+
+ /* find a free register for this live interval */
+ {
+ const GLint k = alloc_register(usedRegs);
+ if (k < 0) {
+ /* out of registers, give up */
+ return;
+ }
+ registerMap[live->Reg] = k;
+ maxTemp = MAX2(maxTemp, k);
+ if (dbg)
+ printf(" remap register %u -> %d\n", live->Reg, k);
+ }
+
+ /* Insert this live interval into the active list which is sorted
+ * by increasing end points.
+ */
+ insert_interval_by_end(&activeIntervals, live);
+ }
+ }
+
+ if (maxTemp + 1 < (GLint) liveIntervals.Num) {
+ /* OK, we've reduced the number of registers needed.
+ * Scan the program and replace all the old temporary register
+ * indexes with the new indexes.
+ */
+ replace_regs(prog, PROGRAM_TEMPORARY, registerMap);
+
+ prog->NumTemporaries = maxTemp + 1;
+ }
+
+ if (dbg) {
+ printf("Optimize: End live-interval register reallocation\n");
+ printf("Num temp regs before: %u after: %u\n",
+ liveIntervals.Num, maxTemp + 1);
+ _mesa_print_program(prog);
+ }
+}
+
+
+#if 0
+static void
+print_it(struct gl_context *ctx, struct gl_program *program, const char *txt) {
+ fprintf(stderr, "%s (%u inst):\n", txt, program->NumInstructions);
+ _mesa_print_program(program);
+ _mesa_print_program_parameters(ctx, program);
+ fprintf(stderr, "\n\n");
+}
+#endif
+
+
+/**
+ * Apply optimizations to the given program to eliminate unnecessary
+ * instructions, temp regs, etc.
+ */
+void
+_mesa_optimize_program(struct gl_context *ctx, struct gl_program *program)
+{
+ GLboolean any_change;
+
+ /* Stop when no modifications were output */
+ do {
+ any_change = GL_FALSE;
+ _mesa_remove_extra_move_use(program);
+ if (_mesa_remove_dead_code_global(program))
+ any_change = GL_TRUE;
+ if (_mesa_remove_extra_moves(program))
+ any_change = GL_TRUE;
+ if (_mesa_remove_dead_code_local(program))
+ any_change = GL_TRUE;
+ _mesa_reallocate_registers(program);
+ } while (any_change);
+}
+
diff --git a/xorg-server/fb/fb.h b/xorg-server/fb/fb.h
index cefd410dd..eaa21ad75 100644
--- a/xorg-server/fb/fb.h
+++ b/xorg-server/fb/fb.h
@@ -1,2090 +1,2060 @@
-/*
- *
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-
-#ifndef _FB_H_
-#define _FB_H_
-
-#include <X11/X.h>
-#include <pixman.h>
-
-#include "scrnintstr.h"
-#include "pixmap.h"
-#include "pixmapstr.h"
-#include "region.h"
-#include "gcstruct.h"
-#include "colormap.h"
-#include "miscstruct.h"
-#include "servermd.h"
-#include "windowstr.h"
-#include "privates.h"
-#include "mi.h"
-#include "migc.h"
-#include "mibstore.h"
-#include "picturestr.h"
-
-#ifdef FB_ACCESS_WRAPPER
-
-#include "wfbrename.h"
-#define FBPREFIX(x) wfb##x
-#define WRITE(ptr, val) ((*wfbWriteMemory)((ptr), (val), sizeof(*(ptr))))
-#define READ(ptr) ((*wfbReadMemory)((ptr), sizeof(*(ptr))))
-
-#define MEMCPY_WRAPPED(dst, src, size) do { \
- size_t _i; \
- CARD8 *_dst = (CARD8*)(dst), *_src = (CARD8*)(src); \
- for(_i = 0; _i < size; _i++) { \
- WRITE(_dst +_i, READ(_src + _i)); \
- } \
-} while(0)
-
-#define MEMSET_WRAPPED(dst, val, size) do { \
- size_t _i; \
- CARD8 *_dst = (CARD8*)(dst); \
- for(_i = 0; _i < size; _i++) { \
- WRITE(_dst +_i, (val)); \
- } \
-} while(0)
-
-#else
-
-#define FBPREFIX(x) fb##x
-#define WRITE(ptr, val) (*(ptr) = (val))
-#define READ(ptr) (*(ptr))
-#define MEMCPY_WRAPPED(dst, src, size) memcpy((dst), (src), (size))
-#define MEMSET_WRAPPED(dst, val, size) memset((dst), (val), (size))
-
-#endif
-
-/*
- * This single define controls the basic size of data manipulated
- * by this software; it must be log2(sizeof (FbBits) * 8)
- */
-
-#ifndef FB_SHIFT
-#define FB_SHIFT LOG2_BITMAP_PAD
-#endif
-
-#if FB_SHIFT < LOG2_BITMAP_PAD
- error FB_SHIFT must be >= LOG2_BITMAP_PAD
-#endif
-
-#define FB_UNIT (1 << FB_SHIFT)
-#define FB_HALFUNIT (1 << (FB_SHIFT-1))
-#define FB_MASK (FB_UNIT - 1)
-#define FB_ALLONES ((FbBits) -1)
-
-#if GLYPHPADBYTES != 4
-#error "GLYPHPADBYTES must be 4"
-#endif
-/* whether to bother to include 24bpp support */
-#ifndef FBNO24BIT
-#define FB_24BIT
-#endif
-
-/*
- * Unless otherwise instructed, fb includes code to advertise 24bpp
- * windows with 32bpp image format for application compatibility
- */
-
-#ifdef FB_24BIT
-#ifndef FBNO24_32
-#define FB_24_32BIT
-#endif
-#endif
-
-#define FB_STIP_SHIFT LOG2_BITMAP_PAD
-#define FB_STIP_UNIT (1 << FB_STIP_SHIFT)
-#define FB_STIP_MASK (FB_STIP_UNIT - 1)
-#define FB_STIP_ALLONES ((FbStip) -1)
-
-#define FB_STIP_ODDSTRIDE(s) (((s) & (FB_MASK >> FB_STIP_SHIFT)) != 0)
-#define FB_STIP_ODDPTR(p) ((((long) (p)) & (FB_MASK >> 3)) != 0)
-
-#define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))
-#define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))
-
-#define FbFullMask(n) ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))
-
-#if FB_SHIFT == 6
-# ifdef WIN32
-typedef unsigned __int64 FbBits;
-# else
-# if defined(__alpha__) || defined(__alpha) || \
- defined(ia64) || defined(__ia64__) || \
- defined(__sparc64__) || defined(_LP64) || \
- defined(__s390x__) || \
- defined(amd64) || defined (__amd64__) || \
- defined (__powerpc64__)
-typedef unsigned long FbBits;
-# else
-typedef unsigned long long FbBits;
-# endif
-# endif
-#endif
-
-#if FB_SHIFT == 5
-typedef CARD32 FbBits;
-#endif
-
-#if FB_SHIFT == 4
-typedef CARD16 FbBits;
-#endif
-
-#if LOG2_BITMAP_PAD == FB_SHIFT
-typedef FbBits FbStip;
-#else
-# if LOG2_BITMAP_PAD == 5
-typedef CARD32 FbStip;
-# endif
-#endif
-
-typedef int FbStride;
-
-
-#ifdef FB_DEBUG
-extern _X_EXPORT void fbValidateDrawable(DrawablePtr d);
-extern _X_EXPORT void fbInitializeDrawable(DrawablePtr d);
-extern _X_EXPORT void fbSetBits (FbStip *bits, int stride, FbStip data);
-#define FB_HEAD_BITS (FbStip) (0xbaadf00d)
-#define FB_TAIL_BITS (FbStip) (0xbaddf0ad)
-#else
-#define fbValidateDrawable(d)
-#define fdInitializeDrawable(d)
-#endif
-
-#include "fbrop.h"
-
-#if BITMAP_BIT_ORDER == LSBFirst
-#define FbScrLeft(x,n) ((x) >> (n))
-#define FbScrRight(x,n) ((x) << (n))
-/* #define FbLeftBits(x,n) ((x) & ((((FbBits) 1) << (n)) - 1)) */
-#define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1))
-#define FbStipMoveLsb(x,s,n) (FbStipRight (x,(s)-(n)))
-#define FbPatternOffsetBits 0
-#else
-#define FbScrLeft(x,n) ((x) << (n))
-#define FbScrRight(x,n) ((x) >> (n))
-/* #define FbLeftBits(x,n) ((x) >> (FB_UNIT - (n))) */
-#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
-#define FbStipMoveLsb(x,s,n) (x)
-#define FbPatternOffsetBits (sizeof (FbBits) - 1)
-#endif
-
-#include "micoord.h"
-
-#define FbStipLeft(x,n) FbScrLeft(x,n)
-#define FbStipRight(x,n) FbScrRight(x,n)
-
-#define FbRotLeft(x,n) FbScrLeft(x,n) | (n ? FbScrRight(x,FB_UNIT-n) : 0)
-#define FbRotRight(x,n) FbScrRight(x,n) | (n ? FbScrLeft(x,FB_UNIT-n) : 0)
-
-#define FbRotStipLeft(x,n) FbStipLeft(x,n) | (n ? FbStipRight(x,FB_STIP_UNIT-n) : 0)
-#define FbRotStipRight(x,n) FbStipRight(x,n) | (n ? FbStipLeft(x,FB_STIP_UNIT-n) : 0)
-
-#define FbLeftMask(x) ( ((x) & FB_MASK) ? \
- FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
-#define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \
- FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
-
-#define FbLeftStipMask(x) ( ((x) & FB_STIP_MASK) ? \
- FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0)
-#define FbRightStipMask(x) ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \
- FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0)
-
-#define FbBitsMask(x,w) (FbScrRight(FB_ALLONES,(x) & FB_MASK) & \
- FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK))
-
-#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \
- FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))
-
-
-#define FbMaskBits(x,w,l,n,r) { \
- n = (w); \
- r = FbRightMask((x)+n); \
- l = FbLeftMask(x); \
- if (l) { \
- n -= FB_UNIT - ((x) & FB_MASK); \
- if (n < 0) { \
- n = 0; \
- l &= r; \
- r = 0; \
- } \
- } \
- n >>= FB_SHIFT; \
-}
-
-#ifdef FBNOPIXADDR
-#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) FbMaskBits(x,w,l,n,r)
-#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
- *dst = FbDoMaskRRop(*dst,and,xor,l); \
-}
-#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
- *dst = FbDoMaskRRop(*dst,and,xor,r); \
-}
-#else
-
-#define FbByteMaskInvalid 0x10
-
-#define FbPatternOffset(o,t) ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1)))
-
-#define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o)))
-#define FbSelectPatternPart(xor,o,t) ((xor) >> (FbPatternOffset (o,t) << 3))
-#define FbStorePart(dst,off,t,xor) (WRITE(FbPtrOffset(dst,off,t), \
- FbSelectPart(xor,off,t)))
-#ifndef FbSelectPart
-#define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t)
-#endif
-
-#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \
- n = (w); \
- lb = 0; \
- rb = 0; \
- r = FbRightMask((x)+n); \
- if (r) { \
- /* compute right byte length */ \
- if ((copy) && (((x) + n) & 7) == 0) { \
- rb = (((x) + n) & FB_MASK) >> 3; \
- } else { \
- rb = FbByteMaskInvalid; \
- } \
- } \
- l = FbLeftMask(x); \
- if (l) { \
- /* compute left byte length */ \
- if ((copy) && ((x) & 7) == 0) { \
- lb = ((x) & FB_MASK) >> 3; \
- } else { \
- lb = FbByteMaskInvalid; \
- } \
- /* subtract out the portion painted by leftMask */ \
- n -= FB_UNIT - ((x) & FB_MASK); \
- if (n < 0) { \
- if (lb != FbByteMaskInvalid) { \
- if (rb == FbByteMaskInvalid) { \
- lb = FbByteMaskInvalid; \
- } else if (rb) { \
- lb |= (rb - lb) << (FB_SHIFT - 3); \
- rb = 0; \
- } \
- } \
- n = 0; \
- l &= r; \
- r = 0; \
- }\
- } \
- n >>= FB_SHIFT; \
-}
-
-#if FB_SHIFT == 6
-#define FbDoLeftMaskByteRRop6Cases(dst,xor) \
- case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
- break; \
- case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
- break; \
- case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 7): \
- FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
- break; \
- case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
- break; \
- case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
- break; \
- case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 6): \
- FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
- break; \
- case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
- break; \
- case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 5): \
- FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
- break; \
- case (sizeof (FbBits) - 4) | (1 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 4) | (2 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
- break; \
- case (sizeof (FbBits) - 4) | (3 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
- FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 4): \
- FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
- break;
-
-#define FbDoRightMaskByteRRop6Cases(dst,xor) \
- case 4: \
- FbStorePart(dst,0,CARD32,xor); \
- break; \
- case 5: \
- FbStorePart(dst,0,CARD32,xor); \
- FbStorePart(dst,4,CARD8,xor); \
- break; \
- case 6: \
- FbStorePart(dst,0,CARD32,xor); \
- FbStorePart(dst,4,CARD16,xor); \
- break; \
- case 7: \
- FbStorePart(dst,0,CARD32,xor); \
- FbStorePart(dst,4,CARD16,xor); \
- FbStorePart(dst,6,CARD8,xor); \
- break;
-#else
-#define FbDoLeftMaskByteRRop6Cases(dst,xor)
-#define FbDoRightMaskByteRRop6Cases(dst,xor)
-#endif
-
-#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
- switch (lb) { \
- FbDoLeftMaskByteRRop6Cases(dst,xor) \
- case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 3) | (2 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
- FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
- break; \
- case (sizeof (FbBits) - 2) | (1 << (FB_SHIFT - 3)): \
- FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
- break; \
- case sizeof (FbBits) - 3: \
- FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
- case sizeof (FbBits) - 2: \
- FbStorePart(dst,sizeof (FbBits) - 2,CARD16,xor); \
- break; \
- case sizeof (FbBits) - 1: \
- FbStorePart(dst,sizeof (FbBits) - 1,CARD8,xor); \
- break; \
- default: \
- WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, l)); \
- break; \
- } \
-}
-
-
-#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
- switch (rb) { \
- case 1: \
- FbStorePart(dst,0,CARD8,xor); \
- break; \
- case 2: \
- FbStorePart(dst,0,CARD16,xor); \
- break; \
- case 3: \
- FbStorePart(dst,0,CARD16,xor); \
- FbStorePart(dst,2,CARD8,xor); \
- break; \
- FbDoRightMaskByteRRop6Cases(dst,xor) \
- default: \
- WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, r)); \
- } \
-}
-#endif
-
-#define FbMaskStip(x,w,l,n,r) { \
- n = (w); \
- r = FbRightStipMask((x)+n); \
- l = FbLeftStipMask(x); \
- if (l) { \
- n -= FB_STIP_UNIT - ((x) & FB_STIP_MASK); \
- if (n < 0) { \
- n = 0; \
- l &= r; \
- r = 0; \
- } \
- } \
- n >>= FB_STIP_SHIFT; \
-}
-
-/*
- * These macros are used to transparently stipple
- * in copy mode; the expected usage is with 'n' constant
- * so all of the conditional parts collapse into a minimal
- * sequence of partial word writes
- *
- * 'n' is the bytemask of which bytes to store, 'a' is the address
- * of the FbBits base unit, 'o' is the offset within that unit
- *
- * The term "lane" comes from the hardware term "byte-lane" which
- */
-
-#define FbLaneCase1(n,a,o) \
- if ((n) == 0x01) { \
- WRITE((CARD8 *) ((a)+FbPatternOffset(o,CARD8)), fgxor); \
- }
-
-#define FbLaneCase2(n,a,o) \
- if ((n) == 0x03) { \
- WRITE((CARD16 *) ((a)+FbPatternOffset(o,CARD16)), fgxor); \
- } else { \
- FbLaneCase1((n)&1,a,o) \
- FbLaneCase1((n)>>1,a,(o)+1) \
- }
-
-#define FbLaneCase4(n,a,o) \
- if ((n) == 0x0f) { \
- WRITE((CARD32 *) ((a)+FbPatternOffset(o,CARD32)), fgxor); \
- } else { \
- FbLaneCase2((n)&3,a,o) \
- FbLaneCase2((n)>>2,a,(o)+2) \
- }
-
-#define FbLaneCase8(n,a,o) \
- if ((n) == 0x0ff) { \
- *(FbBits *) ((a)+(o)) = fgxor; \
- } else { \
- FbLaneCase4((n)&15,a,o) \
- FbLaneCase4((n)>>4,a,(o)+4) \
- }
-
-#if FB_SHIFT == 6
-#define FbLaneCase(n,a) FbLaneCase8(n,(CARD8 *) (a),0)
-#endif
-
-#if FB_SHIFT == 5
-#define FbLaneCase(n,a) FbLaneCase4(n,(CARD8 *) (a),0)
-#endif
-
-/* Rotate a filled pixel value to the specified alignement */
-#define FbRot24(p,b) (FbScrRight(p,b) | FbScrLeft(p,24-(b)))
-#define FbRot24Stip(p,b) (FbStipRight(p,b) | FbStipLeft(p,24-(b)))
-
-/* step a filled pixel value to the next/previous FB_UNIT alignment */
-#define FbNext24Pix(p) (FbRot24(p,(24-FB_UNIT%24)))
-#define FbPrev24Pix(p) (FbRot24(p,FB_UNIT%24))
-#define FbNext24Stip(p) (FbRot24(p,(24-FB_STIP_UNIT%24)))
-#define FbPrev24Stip(p) (FbRot24(p,FB_STIP_UNIT%24))
-
-/* step a rotation value to the next/previous rotation value */
-#if FB_UNIT == 64
-#define FbNext24Rot(r) ((r) == 16 ? 0 : (r) + 8)
-#define FbPrev24Rot(r) ((r) == 0 ? 16 : (r) - 8)
-
-#if IMAGE_BYTE_ORDER == MSBFirst
-#define FbFirst24Rot(x) (((x) + 8) % 24)
-#else
-#define FbFirst24Rot(x) ((x) % 24)
-#endif
-
-#endif
-
-#if FB_UNIT == 32
-#define FbNext24Rot(r) ((r) == 0 ? 16 : (r) - 8)
-#define FbPrev24Rot(r) ((r) == 16 ? 0 : (r) + 8)
-
-#if IMAGE_BYTE_ORDER == MSBFirst
-#define FbFirst24Rot(x) (((x) + 16) % 24)
-#else
-#define FbFirst24Rot(x) ((x) % 24)
-#endif
-#endif
-
-#define FbNext24RotStip(r) ((r) == 0 ? 16 : (r) - 8)
-#define FbPrev24RotStip(r) ((r) == 16 ? 0 : (r) + 8)
-
-/* Whether 24-bit specific code is needed for this filled pixel value */
-#define FbCheck24Pix(p) ((p) == FbNext24Pix(p))
-
-/* Macros for dealing with dashing */
-
-#define FbDashDeclare \
- unsigned char *__dash, *__firstDash, *__lastDash
-
-#define FbDashInit(pGC,pPriv,dashOffset,dashlen,even) { \
- (even) = TRUE; \
- __firstDash = (pGC)->dash; \
- __lastDash = __firstDash + (pGC)->numInDashList; \
- (dashOffset) %= (pPriv)->dashLength; \
- \
- __dash = __firstDash; \
- while ((dashOffset) >= ((dashlen) = *__dash)) \
- { \
- (dashOffset) -= (dashlen); \
- (even) = 1-(even); \
- if (++__dash == __lastDash) \
- __dash = __firstDash; \
- } \
- (dashlen) -= (dashOffset); \
-}
-
-#define FbDashNext(dashlen) { \
- if (++__dash == __lastDash) \
- __dash = __firstDash; \
- (dashlen) = *__dash; \
-}
-
-/* as numInDashList is always even, this case can skip a test */
-
-#define FbDashNextEven(dashlen) { \
- (dashlen) = *++__dash; \
-}
-
-#define FbDashNextOdd(dashlen) FbDashNext(dashlen)
-
-#define FbDashStep(dashlen,even) { \
- if (!--(dashlen)) { \
- FbDashNext(dashlen); \
- (even) = 1-(even); \
- } \
-}
-
-extern _X_EXPORT DevPrivateKey
-fbGetGCPrivateKey (void);
-
-extern _X_EXPORT DevPrivateKey
-fbGetWinPrivateKey (void);
-
-extern _X_EXPORT const GCOps fbGCOps;
-extern _X_EXPORT const GCFuncs fbGCFuncs;
-
-#ifdef FB_24_32BIT
-#define FB_SCREEN_PRIVATE
-#endif
-
-/* Framebuffer access wrapper */
-typedef FbBits (*ReadMemoryProcPtr)(const void *src, int size);
-typedef void (*WriteMemoryProcPtr)(void *dst, FbBits value, int size);
-typedef void (*SetupWrapProcPtr)(ReadMemoryProcPtr *pRead,
- WriteMemoryProcPtr *pWrite,
- DrawablePtr pDraw);
-typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw);
-
-#ifdef FB_ACCESS_WRAPPER
-
-#define fbPrepareAccess(pDraw) \
- fbGetScreenPrivate((pDraw)->pScreen)->setupWrap( \
- &wfbReadMemory, \
- &wfbWriteMemory, \
- (pDraw))
-#define fbFinishAccess(pDraw) \
- fbGetScreenPrivate((pDraw)->pScreen)->finishWrap(pDraw)
-
-#else
-
-#define fbPrepareAccess(pPix)
-#define fbFinishAccess(pDraw)
-
-#endif
-
-
-#ifdef FB_SCREEN_PRIVATE
-extern _X_EXPORT DevPrivateKey
-fbGetScreenPrivateKey(void);
-
-/* private field of a screen */
-typedef struct {
- unsigned char win32bpp; /* window bpp for 32-bpp images */
- unsigned char pix32bpp; /* pixmap bpp for 32-bpp images */
-#ifdef FB_ACCESS_WRAPPER
- SetupWrapProcPtr setupWrap; /* driver hook to set pixmap access wrapping */
- FinishWrapProcPtr finishWrap; /* driver hook to clean up pixmap access wrapping */
-#endif
-} FbScreenPrivRec, *FbScreenPrivPtr;
-
-#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
- dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
-#endif
-
-/* private field of GC */
-typedef struct {
- FbBits and, xor; /* reduced rop values */
- FbBits bgand, bgxor; /* for stipples */
- FbBits fg, bg, pm; /* expanded and filled */
- unsigned int dashLength; /* total of all dash elements */
- unsigned char evenStipple; /* stipple is even */
- unsigned char bpp; /* current drawable bpp */
-} FbGCPrivRec, *FbGCPrivPtr;
-
-#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
- dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey()))
-
-#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
-#define fbGetExpose(pGC) ((pGC)->fExpose)
-#define fbGetFreeCompClip(pGC) ((pGC)->freeCompClip)
-#define fbGetRotatedPixmap(pGC) ((pGC)->pRotatedPixmap)
-
-#define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate)
-#define fbGetWindowPixmap(pWin) ((PixmapPtr)\
- dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey()))
-
-#ifdef ROOTLESS
-#define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
-#define __fbPixDrawableY(pPix) ((pPix)->drawable.y)
-#else
-#define __fbPixDrawableX(pPix) 0
-#define __fbPixDrawableY(pPix) 0
-#endif
-
-#ifdef COMPOSITE
-#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x)
-#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y)
-#else
-#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix))
-#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix))
-#endif
-#define __fbPixOffXPix(pPix) (__fbPixDrawableX(pPix))
-#define __fbPixOffYPix(pPix) (__fbPixDrawableY(pPix))
-
-#define fbGetDrawablePixmap(pDrawable, pixmap, xoff, yoff) { \
- if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
- (pixmap) = fbGetWindowPixmap(pDrawable); \
- (xoff) = __fbPixOffXWin(pixmap); \
- (yoff) = __fbPixOffYWin(pixmap); \
- } else { \
- (pixmap) = (PixmapPtr) (pDrawable); \
- (xoff) = __fbPixOffXPix(pixmap); \
- (yoff) = __fbPixOffYPix(pixmap); \
- } \
- fbPrepareAccess(pDrawable); \
-}
-
-#define fbGetPixmapBitsData(pixmap, pointer, stride, bpp) { \
- (pointer) = (FbBits *) (pixmap)->devPrivate.ptr; \
- (stride) = ((int) (pixmap)->devKind) / sizeof (FbBits); (void)(stride); \
- (bpp) = (pixmap)->drawable.bitsPerPixel; (void)(bpp); \
-}
-
-#define fbGetPixmapStipData(pixmap, pointer, stride, bpp) { \
- (pointer) = (FbStip *) (pixmap)->devPrivate.ptr; \
- (stride) = ((int) (pixmap)->devKind) / sizeof (FbStip); (void)(stride); \
- (bpp) = (pixmap)->drawable.bitsPerPixel; (void)(bpp); \
-}
-
-#define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
- PixmapPtr _pPix; \
- fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff); \
- fbGetPixmapBitsData(_pPix, pointer, stride, bpp); \
-}
-
-#define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
- PixmapPtr _pPix; \
- fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff); \
- fbGetPixmapStipData(_pPix, pointer, stride, bpp); \
-}
-
-/*
- * XFree86 empties the root BorderClip when the VT is inactive,
- * here's a macro which uses that to disable GetImage and GetSpans
- */
-
-#define fbWindowEnabled(pWin) \
- RegionNotEmpty(&(pWin)->drawable.pScreen->root->borderClip)
-
-#define fbDrawableEnabled(pDrawable) \
- ((pDrawable)->type == DRAWABLE_PIXMAP ? \
- TRUE : fbWindowEnabled((WindowPtr) pDrawable))
-
-#define FbPowerOfTwo(w) (((w) & ((w) - 1)) == 0)
-/*
- * Accelerated tiles are power of 2 width <= FB_UNIT
- */
-#define FbEvenTile(w) ((w) <= FB_UNIT && FbPowerOfTwo(w))
-/*
- * Accelerated stipples are power of 2 width and <= FB_UNIT/dstBpp
- * with dstBpp a power of 2 as well
- */
-#define FbEvenStip(w,bpp) ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp))
-
-/*
- * fb24_32.c
- */
-extern _X_EXPORT void
-fb24_32GetSpans(DrawablePtr pDrawable,
- int wMax,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- char *pchardstStart);
-
-extern _X_EXPORT void
-fb24_32SetSpans (DrawablePtr pDrawable,
- GCPtr pGC,
- char *src,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted);
-
-extern _X_EXPORT void
-fb24_32PutZImage (DrawablePtr pDrawable,
- RegionPtr pClip,
- int alu,
- FbBits pm,
- int x,
- int y,
- int width,
- int height,
- CARD8 *src,
- FbStride srcStride);
-
-extern _X_EXPORT void
-fb24_32GetImage (DrawablePtr pDrawable,
- int x,
- int y,
- int w,
- int h,
- unsigned int format,
- unsigned long planeMask,
- char *d);
-
-extern _X_EXPORT void
-fb24_32CopyMtoN (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pbox,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown,
- Pixel bitplane,
- void *closure);
-
-extern _X_EXPORT PixmapPtr
-fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel);
-
-extern _X_EXPORT Bool
-fb24_32CreateScreenResources(ScreenPtr pScreen);
-
-extern _X_EXPORT Bool
-fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
- int width,
- int height,
- int depth,
- int bitsPerPixel,
- int devKind,
- pointer pPixData);
-
-/*
- * fballpriv.c
- */
-extern _X_EXPORT Bool
-fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex);
-
-/*
- * fbarc.c
- */
-
-extern _X_EXPORT void
-fbPolyArc (DrawablePtr pDrawable,
- GCPtr pGC,
- int narcs,
- xArc *parcs);
-
-/*
- * fbbits.c
- */
-
-extern _X_EXPORT void
-fbBresSolid8(DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x,
- int y,
- int e,
- int e1,
- int e3,
- int len);
-
-extern _X_EXPORT void
-fbBresDash8 (DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x,
- int y,
- int e,
- int e1,
- int e3,
- int len);
-
-extern _X_EXPORT void
-fbDots8 (FbBits *dst,
- FbStride dstStride,
- int dstBpp,
- BoxPtr pBox,
- xPoint *pts,
- int npt,
- int xorg,
- int yorg,
- int xoff,
- int yoff,
- FbBits and,
- FbBits xor);
-
-extern _X_EXPORT void
-fbArc8 (FbBits *dst,
- FbStride dstStride,
- int dstBpp,
- xArc *arc,
- int dx,
- int dy,
- FbBits and,
- FbBits xor);
-
-extern _X_EXPORT void
-fbGlyph8 (FbBits *dstLine,
- FbStride dstStride,
- int dstBpp,
- FbStip *stipple,
- FbBits fg,
- int height,
- int shift);
-
-extern _X_EXPORT void
-fbPolyline8 (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr ptsOrig);
-
-extern _X_EXPORT void
-fbPolySegment8 (DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pseg);
-
-extern _X_EXPORT void
-fbBresSolid16(DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x,
- int y,
- int e,
- int e1,
- int e3,
- int len);
-
-extern _X_EXPORT void
-fbBresDash16(DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x,
- int y,
- int e,
- int e1,
- int e3,
- int len);
-
-extern _X_EXPORT void
-fbDots16(FbBits *dst,
- FbStride dstStride,
- int dstBpp,
- BoxPtr pBox,
- xPoint *pts,
- int npt,
- int xorg,
- int yorg,
- int xoff,
- int yoff,
- FbBits and,
- FbBits xor);
-
-extern _X_EXPORT void
-fbArc16(FbBits *dst,
- FbStride dstStride,
- int dstBpp,
- xArc *arc,
- int dx,
- int dy,
- FbBits and,
- FbBits xor);
-
-extern _X_EXPORT void
-fbGlyph16(FbBits *dstLine,
- FbStride dstStride,
- int dstBpp,
- FbStip *stipple,
- FbBits fg,
- int height,
- int shift);
-
-extern _X_EXPORT void
-fbPolyline16 (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr ptsOrig);
-
-extern _X_EXPORT void
-fbPolySegment16 (DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pseg);
-
-
-extern _X_EXPORT void
-fbBresSolid24(DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x,
- int y,
- int e,
- int e1,
- int e3,
- int len);
-
-extern _X_EXPORT void
-fbBresDash24(DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x,
- int y,
- int e,
- int e1,
- int e3,
- int len);
-
-extern _X_EXPORT void
-fbDots24(FbBits *dst,
- FbStride dstStride,
- int dstBpp,
- BoxPtr pBox,
- xPoint *pts,
- int npt,
- int xorg,
- int yorg,
- int xoff,
- int yoff,
- FbBits and,
- FbBits xor);
-
-extern _X_EXPORT void
-fbArc24(FbBits *dst,
- FbStride dstStride,
- int dstBpp,
- xArc *arc,
- int dx,
- int dy,
- FbBits and,
- FbBits xor);
-
-extern _X_EXPORT void
-fbGlyph24(FbBits *dstLine,
- FbStride dstStride,
- int dstBpp,
- FbStip *stipple,
- FbBits fg,
- int height,
- int shift);
-
-extern _X_EXPORT void
-fbPolyline24 (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr ptsOrig);
-
-extern _X_EXPORT void
-fbPolySegment24 (DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pseg);
-
-
-extern _X_EXPORT void
-fbBresSolid32(DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x,
- int y,
- int e,
- int e1,
- int e3,
- int len);
-
-extern _X_EXPORT void
-fbBresDash32(DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x,
- int y,
- int e,
- int e1,
- int e3,
- int len);
-
-extern _X_EXPORT void
-fbDots32(FbBits *dst,
- FbStride dstStride,
- int dstBpp,
- BoxPtr pBox,
- xPoint *pts,
- int npt,
- int xorg,
- int yorg,
- int xoff,
- int yoff,
- FbBits and,
- FbBits xor);
-
-extern _X_EXPORT void
-fbArc32(FbBits *dst,
- FbStride dstStride,
- int dstBpp,
- xArc *arc,
- int dx,
- int dy,
- FbBits and,
- FbBits xor);
-
-extern _X_EXPORT void
-fbGlyph32(FbBits *dstLine,
- FbStride dstStride,
- int dstBpp,
- FbStip *stipple,
- FbBits fg,
- int height,
- int shift);
-extern _X_EXPORT void
-fbPolyline32 (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr ptsOrig);
-
-extern _X_EXPORT void
-fbPolySegment32 (DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pseg);
-
-/*
- * fbblt.c
- */
-extern _X_EXPORT void
-fbBlt (FbBits *src,
- FbStride srcStride,
- int srcX,
-
- FbBits *dst,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- int alu,
- FbBits pm,
- int bpp,
-
- Bool reverse,
- Bool upsidedown);
-
-extern _X_EXPORT void
-fbBlt24 (FbBits *srcLine,
- FbStride srcStride,
- int srcX,
-
- FbBits *dstLine,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- int alu,
- FbBits pm,
-
- Bool reverse,
- Bool upsidedown);
-
-extern _X_EXPORT void
-fbBltStip (FbStip *src,
- FbStride srcStride, /* in FbStip units, not FbBits units */
- int srcX,
-
- FbStip *dst,
- FbStride dstStride, /* in FbStip units, not FbBits units */
- int dstX,
-
- int width,
- int height,
-
- int alu,
- FbBits pm,
- int bpp);
-
-/*
- * fbbltone.c
- */
-extern _X_EXPORT void
-fbBltOne (FbStip *src,
- FbStride srcStride,
- int srcX,
- FbBits *dst,
- FbStride dstStride,
- int dstX,
- int dstBpp,
-
- int width,
- int height,
-
- FbBits fgand,
- FbBits fbxor,
- FbBits bgand,
- FbBits bgxor);
-
-#ifdef FB_24BIT
-extern _X_EXPORT void
-fbBltOne24 (FbStip *src,
- FbStride srcStride, /* FbStip units per scanline */
- int srcX, /* bit position of source */
- FbBits *dst,
- FbStride dstStride, /* FbBits units per scanline */
- int dstX, /* bit position of dest */
- int dstBpp, /* bits per destination unit */
-
- int width, /* width in bits of destination */
- int height, /* height in scanlines */
-
- FbBits fgand, /* rrop values */
- FbBits fgxor,
- FbBits bgand,
- FbBits bgxor);
-#endif
-
-extern _X_EXPORT void
-fbBltPlane (FbBits *src,
- FbStride srcStride,
- int srcX,
- int srcBpp,
-
- FbStip *dst,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- FbStip fgand,
- FbStip fgxor,
- FbStip bgand,
- FbStip bgxor,
- Pixel planeMask);
-
-/*
- * fbcmap_mi.c
- */
-extern _X_EXPORT int
-fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps);
-
-extern _X_EXPORT void
-fbInstallColormap(ColormapPtr pmap);
-
-extern _X_EXPORT void
-fbUninstallColormap(ColormapPtr pmap);
-
-extern _X_EXPORT void
-fbResolveColor(unsigned short *pred,
- unsigned short *pgreen,
- unsigned short *pblue,
- VisualPtr pVisual);
-
-extern _X_EXPORT Bool
-fbInitializeColormap(ColormapPtr pmap);
-
-extern _X_EXPORT int
-fbExpandDirectColors (ColormapPtr pmap,
- int ndef,
- xColorItem *indefs,
- xColorItem *outdefs);
-
-extern _X_EXPORT Bool
-fbCreateDefColormap(ScreenPtr pScreen);
-
-extern _X_EXPORT void
-fbClearVisualTypes(void);
-
-extern _X_EXPORT Bool
-fbHasVisualTypes (int depth);
-
-extern _X_EXPORT Bool
-fbSetVisualTypes (int depth, int visuals, int bitsPerRGB);
-
-extern _X_EXPORT Bool
-fbSetVisualTypesAndMasks (int depth, int visuals, int bitsPerRGB,
- Pixel redMask, Pixel greenMask, Pixel blueMask);
-
-extern _X_EXPORT Bool
-fbInitVisuals (VisualPtr *visualp,
- DepthPtr *depthp,
- int *nvisualp,
- int *ndepthp,
- int *rootDepthp,
- VisualID *defaultVisp,
- unsigned long sizes,
- int bitsPerRGB);
-
-/*
- * fbcopy.c
- */
-
-/* Compatibility definition, to be removed at next ABI change. */
-typedef void (*fbCopyProc) (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pDstBox,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown,
- Pixel bitplane,
- void *closure);
-
-extern _X_EXPORT void
-fbCopyNtoN (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pbox,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown,
- Pixel bitplane,
- void *closure);
-
-/* Compatibility wrapper, to be removed at next ABI change. */
-extern _X_EXPORT void
-fbCopyRegion (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- RegionPtr pDstRegion,
- int dx,
- int dy,
- fbCopyProc copyProc,
- Pixel bitPlane,
- void *closure);
-
-/* Compatibility wrapper, to be removed at next ABI change. */
-extern _X_EXPORT RegionPtr
-fbDoCopy (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- int xIn,
- int yIn,
- int widthSrc,
- int heightSrc,
- int xOut,
- int yOut,
- fbCopyProc copyProc,
- Pixel bitplane,
- void *closure);
-
-extern _X_EXPORT void
-fbCopy1toN (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pbox,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown,
- Pixel bitplane,
- void *closure);
-
-extern _X_EXPORT void
-fbCopyNto1 (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pbox,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown,
- Pixel bitplane,
- void *closure);
-
-extern _X_EXPORT RegionPtr
-fbCopyArea (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- int xIn,
- int yIn,
- int widthSrc,
- int heightSrc,
- int xOut,
- int yOut);
-
-extern _X_EXPORT RegionPtr
-fbCopyPlane (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- int xIn,
- int yIn,
- int widthSrc,
- int heightSrc,
- int xOut,
- int yOut,
- unsigned long bitplane);
-
-/*
- * fbfill.c
- */
-extern _X_EXPORT void
-fbFill (DrawablePtr pDrawable,
- GCPtr pGC,
- int x,
- int y,
- int width,
- int height);
-
-extern _X_EXPORT void
-fbSolidBoxClipped (DrawablePtr pDrawable,
- RegionPtr pClip,
- int xa,
- int ya,
- int xb,
- int yb,
- FbBits and,
- FbBits xor);
-
-/*
- * fbfillrect.c
- */
-extern _X_EXPORT void
-fbPolyFillRect(DrawablePtr pDrawable,
- GCPtr pGC,
- int nrectInit,
- xRectangle *prectInit);
-
-#define fbPolyFillArc miPolyFillArc
-
-#define fbFillPolygon miFillPolygon
-
-/*
- * fbfillsp.c
- */
-extern _X_EXPORT void
-fbFillSpans (DrawablePtr pDrawable,
- GCPtr pGC,
- int nInit,
- DDXPointPtr pptInit,
- int *pwidthInit,
- int fSorted);
-
-
-/*
- * fbgc.c
- */
-
-extern _X_EXPORT Bool
-fbCreateGC(GCPtr pGC);
-
-extern _X_EXPORT void
-fbPadPixmap (PixmapPtr pPixmap);
-
-extern _X_EXPORT void
-fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
-
-/*
- * fbgetsp.c
- */
-extern _X_EXPORT void
-fbGetSpans(DrawablePtr pDrawable,
- int wMax,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- char *pchardstStart);
-
-/*
- * fbglyph.c
- */
-
-extern _X_EXPORT Bool
-fbGlyphIn (RegionPtr pRegion,
- int x,
- int y,
- int width,
- int height);
-
-extern _X_EXPORT void
-fbPolyGlyphBlt (DrawablePtr pDrawable,
- GCPtr pGC,
- int x,
- int y,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase);
-
-extern _X_EXPORT void
-fbImageGlyphBlt (DrawablePtr pDrawable,
- GCPtr pGC,
- int x,
- int y,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase);
-
-/*
- * fbimage.c
- */
-
-extern _X_EXPORT void
-fbPutImage (DrawablePtr pDrawable,
- GCPtr pGC,
- int depth,
- int x,
- int y,
- int w,
- int h,
- int leftPad,
- int format,
- char *pImage);
-
-extern _X_EXPORT void
-fbPutZImage (DrawablePtr pDrawable,
- RegionPtr pClip,
- int alu,
- FbBits pm,
- int x,
- int y,
- int width,
- int height,
- FbStip *src,
- FbStride srcStride);
-
-extern _X_EXPORT void
-fbPutXYImage (DrawablePtr pDrawable,
- RegionPtr pClip,
- FbBits fg,
- FbBits bg,
- FbBits pm,
- int alu,
- Bool opaque,
-
- int x,
- int y,
- int width,
- int height,
-
- FbStip *src,
- FbStride srcStride,
- int srcX);
-
-extern _X_EXPORT void
-fbGetImage (DrawablePtr pDrawable,
- int x,
- int y,
- int w,
- int h,
- unsigned int format,
- unsigned long planeMask,
- char *d);
-/*
- * fbline.c
- */
-
-extern _X_EXPORT void
-fbZeroLine (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr ppt);
-
-extern _X_EXPORT void
-fbZeroSegment (DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSegs);
-
-extern _X_EXPORT void
-fbPolyLine (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr ppt);
-
-extern _X_EXPORT void
-fbFixCoordModePrevious (int npt,
- DDXPointPtr ppt);
-
-extern _X_EXPORT void
-fbPolySegment (DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pseg);
-
-#define fbPolyRectangle miPolyRectangle
-
-/*
- * fbpict.c
- */
-
-extern _X_EXPORT Bool
-fbPictureInit (ScreenPtr pScreen,
- PictFormatPtr formats,
- int nformats);
-
-/*
- * fbpixmap.c
- */
-
-extern _X_EXPORT PixmapPtr
-fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
- unsigned usage_hint);
-
-extern _X_EXPORT PixmapPtr
-fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth,
- unsigned usage_hint);
-
-extern _X_EXPORT Bool
-fbDestroyPixmap (PixmapPtr pPixmap);
-
-extern _X_EXPORT RegionPtr
-fbPixmapToRegion(PixmapPtr pPix);
-
-/*
- * fbpoint.c
- */
-
-extern _X_EXPORT void
-fbDots (FbBits *dstOrig,
- FbStride dstStride,
- int dstBpp,
- BoxPtr pBox,
- xPoint *pts,
- int npt,
- int xorg,
- int yorg,
- int xoff,
- int yoff,
- FbBits andOrig,
- FbBits xorOrig);
-
-extern _X_EXPORT void
-fbPolyPoint (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- xPoint *pptInit);
-
-/*
- * fbpush.c
- */
-extern _X_EXPORT void
-fbPushPattern (DrawablePtr pDrawable,
- GCPtr pGC,
-
- FbStip *src,
- FbStride srcStride,
- int srcX,
-
- int x,
- int y,
-
- int width,
- int height);
-
-extern _X_EXPORT void
-fbPushFill (DrawablePtr pDrawable,
- GCPtr pGC,
-
- FbStip *src,
- FbStride srcStride,
- int srcX,
-
- int x,
- int y,
- int width,
- int height);
-
-extern _X_EXPORT void
-fbPushImage (DrawablePtr pDrawable,
- GCPtr pGC,
-
- FbStip *src,
- FbStride srcStride,
- int srcX,
-
- int x,
- int y,
- int width,
- int height);
-
-extern _X_EXPORT void
-fbPushPixels (GCPtr pGC,
- PixmapPtr pBitmap,
- DrawablePtr pDrawable,
- int dx,
- int dy,
- int xOrg,
- int yOrg);
-
-
-/*
- * fbscreen.c
- */
-
-extern _X_EXPORT Bool
-fbCloseScreen (int indx, ScreenPtr pScreen);
-
-extern _X_EXPORT Bool
-fbRealizeFont(ScreenPtr pScreen, FontPtr pFont);
-
-extern _X_EXPORT Bool
-fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
-
-extern _X_EXPORT void
-fbQueryBestSize (int class,
- unsigned short *width, unsigned short *height,
- ScreenPtr pScreen);
-
-extern _X_EXPORT PixmapPtr
-_fbGetWindowPixmap (WindowPtr pWindow);
-
-extern _X_EXPORT void
-_fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap);
-
-extern _X_EXPORT Bool
-fbSetupScreen(ScreenPtr pScreen,
- pointer pbits, /* pointer to screen bitmap */
- int xsize, /* in pixels */
- int ysize,
- int dpix, /* dots per inch */
- int dpiy,
- int width, /* pixel width of frame buffer */
- int bpp); /* bits per pixel of frame buffer */
-
-extern _X_EXPORT Bool
-wfbFinishScreenInit(ScreenPtr pScreen,
- pointer pbits,
- int xsize,
- int ysize,
- int dpix,
- int dpiy,
- int width,
- int bpp,
- SetupWrapProcPtr setupWrap,
- FinishWrapProcPtr finishWrap);
-
-extern _X_EXPORT Bool
-wfbScreenInit(ScreenPtr pScreen,
- pointer pbits,
- int xsize,
- int ysize,
- int dpix,
- int dpiy,
- int width,
- int bpp,
- SetupWrapProcPtr setupWrap,
- FinishWrapProcPtr finishWrap);
-
-extern _X_EXPORT Bool
-fbFinishScreenInit(ScreenPtr pScreen,
- pointer pbits,
- int xsize,
- int ysize,
- int dpix,
- int dpiy,
- int width,
- int bpp);
-
-extern _X_EXPORT Bool
-fbScreenInit(ScreenPtr pScreen,
- pointer pbits,
- int xsize,
- int ysize,
- int dpix,
- int dpiy,
- int width,
- int bpp);
-
-/*
- * fbseg.c
- */
-typedef void FbBres (DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x,
- int y,
- int e,
- int e1,
- int e3,
- int len);
-
-extern _X_EXPORT FbBres fbBresSolid, fbBresDash, fbBresFill, fbBresFillDash;
-/*
- * fbsetsp.c
- */
-
-extern _X_EXPORT void
-fbSetSpans (DrawablePtr pDrawable,
- GCPtr pGC,
- char *src,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted);
-
-extern _X_EXPORT FbBres *
-fbSelectBres (DrawablePtr pDrawable,
- GCPtr pGC);
-
-extern _X_EXPORT void
-fbBres (DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x,
- int y,
- int e,
- int e1,
- int e3,
- int len);
-
-extern _X_EXPORT void
-fbSegment (DrawablePtr pDrawable,
- GCPtr pGC,
- int xa,
- int ya,
- int xb,
- int yb,
- Bool drawLast,
- int *dashOffset);
-
-
-/*
- * fbsolid.c
- */
-
-extern _X_EXPORT void
-fbSolid (FbBits *dst,
- FbStride dstStride,
- int dstX,
- int bpp,
-
- int width,
- int height,
-
- FbBits and,
- FbBits xor);
-
-#ifdef FB_24BIT
-extern _X_EXPORT void
-fbSolid24 (FbBits *dst,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- FbBits and,
- FbBits xor);
-#endif
-
-/*
- * fbstipple.c
- */
-
-extern _X_EXPORT void
-fbTransparentSpan (FbBits *dst,
- FbBits stip,
- FbBits fgxor,
- int n);
-
-extern _X_EXPORT void
-fbEvenStipple (FbBits *dst,
- FbStride dstStride,
- int dstX,
- int dstBpp,
-
- int width,
- int height,
-
- FbStip *stip,
- FbStride stipStride,
- int stipHeight,
-
- FbBits fgand,
- FbBits fgxor,
- FbBits bgand,
- FbBits bgxor,
-
- int xRot,
- int yRot);
-
-extern _X_EXPORT void
-fbOddStipple (FbBits *dst,
- FbStride dstStride,
- int dstX,
- int dstBpp,
-
- int width,
- int height,
-
- FbStip *stip,
- FbStride stipStride,
- int stipWidth,
- int stipHeight,
-
- FbBits fgand,
- FbBits fgxor,
- FbBits bgand,
- FbBits bgxor,
-
- int xRot,
- int yRot);
-
-extern _X_EXPORT void
-fbStipple (FbBits *dst,
- FbStride dstStride,
- int dstX,
- int dstBpp,
-
- int width,
- int height,
-
- FbStip *stip,
- FbStride stipStride,
- int stipWidth,
- int stipHeight,
- Bool even,
-
- FbBits fgand,
- FbBits fgxor,
- FbBits bgand,
- FbBits bgxor,
-
- int xRot,
- int yRot);
-
-/*
- * fbtile.c
- */
-
-extern _X_EXPORT void
-fbEvenTile (FbBits *dst,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- FbBits *tile,
- FbStride tileStride,
- int tileHeight,
-
- int alu,
- FbBits pm,
- int xRot,
- int yRot);
-
-extern _X_EXPORT void
-fbOddTile (FbBits *dst,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- FbBits *tile,
- FbStride tileStride,
- int tileWidth,
- int tileHeight,
-
- int alu,
- FbBits pm,
- int bpp,
-
- int xRot,
- int yRot);
-
-extern _X_EXPORT void
-fbTile (FbBits *dst,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- FbBits *tile,
- FbStride tileStride,
- int tileWidth,
- int tileHeight,
-
- int alu,
- FbBits pm,
- int bpp,
-
- int xRot,
- int yRot);
-
-/*
- * fbutil.c
- */
-extern _X_EXPORT FbBits
-fbReplicatePixel (Pixel p, int bpp);
-
-extern _X_EXPORT void
-fbReduceRasterOp (int rop, FbBits fg, FbBits pm, FbBits *andp, FbBits *xorp);
-
-#ifdef FB_ACCESS_WRAPPER
-extern _X_EXPORT ReadMemoryProcPtr wfbReadMemory;
-extern _X_EXPORT WriteMemoryProcPtr wfbWriteMemory;
-#endif
-
-/*
- * fbwindow.c
- */
-
-extern _X_EXPORT Bool
-fbCreateWindow(WindowPtr pWin);
-
-extern _X_EXPORT Bool
-fbDestroyWindow(WindowPtr pWin);
-
-extern _X_EXPORT Bool
-fbMapWindow(WindowPtr pWindow);
-
-extern _X_EXPORT Bool
-fbPositionWindow(WindowPtr pWin, int x, int y);
-
-extern _X_EXPORT Bool
-fbUnmapWindow(WindowPtr pWindow);
-
-extern _X_EXPORT void
-fbCopyWindowProc (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pbox,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown,
- Pixel bitplane,
- void *closure);
-
-extern _X_EXPORT void
-fbCopyWindow(WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc);
-
-extern _X_EXPORT Bool
-fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
-
-extern _X_EXPORT void
-fbFillRegionSolid (DrawablePtr pDrawable,
- RegionPtr pRegion,
- FbBits and,
- FbBits xor);
-
-extern _X_EXPORT pixman_image_t *
-image_from_pict (PicturePtr pict,
- Bool has_clip,
- int *xoff,
- int *yoff);
-
-extern _X_EXPORT void free_pixman_pict (PicturePtr, pixman_image_t *);
-
-#endif /* _FB_H_ */
-
+/*
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#ifndef _FB_H_
+#define _FB_H_
+
+#include <X11/X.h>
+#include <pixman.h>
+
+#include "scrnintstr.h"
+#include "pixmap.h"
+#include "pixmapstr.h"
+#include "region.h"
+#include "gcstruct.h"
+#include "colormap.h"
+#include "miscstruct.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "privates.h"
+#include "mi.h"
+#include "migc.h"
+#include "mibstore.h"
+#include "picturestr.h"
+
+#ifdef FB_ACCESS_WRAPPER
+
+#include "wfbrename.h"
+#define FBPREFIX(x) wfb##x
+#define WRITE(ptr, val) ((*wfbWriteMemory)((ptr), (val), sizeof(*(ptr))))
+#define READ(ptr) ((*wfbReadMemory)((ptr), sizeof(*(ptr))))
+
+#define MEMCPY_WRAPPED(dst, src, size) do { \
+ size_t _i; \
+ CARD8 *_dst = (CARD8*)(dst), *_src = (CARD8*)(src); \
+ for(_i = 0; _i < size; _i++) { \
+ WRITE(_dst +_i, READ(_src + _i)); \
+ } \
+} while(0)
+
+#define MEMSET_WRAPPED(dst, val, size) do { \
+ size_t _i; \
+ CARD8 *_dst = (CARD8*)(dst); \
+ for(_i = 0; _i < size; _i++) { \
+ WRITE(_dst +_i, (val)); \
+ } \
+} while(0)
+
+#else
+
+#define FBPREFIX(x) fb##x
+#define WRITE(ptr, val) (*(ptr) = (val))
+#define READ(ptr) (*(ptr))
+#define MEMCPY_WRAPPED(dst, src, size) memcpy((dst), (src), (size))
+#define MEMSET_WRAPPED(dst, val, size) memset((dst), (val), (size))
+
+#endif
+
+/*
+ * This single define controls the basic size of data manipulated
+ * by this software; it must be log2(sizeof (FbBits) * 8)
+ */
+
+#ifndef FB_SHIFT
+#define FB_SHIFT LOG2_BITMAP_PAD
+#endif
+
+#if FB_SHIFT < LOG2_BITMAP_PAD
+ error FB_SHIFT must be >= LOG2_BITMAP_PAD
+#endif
+
+#define FB_UNIT (1 << FB_SHIFT)
+#define FB_HALFUNIT (1 << (FB_SHIFT-1))
+#define FB_MASK (FB_UNIT - 1)
+#define FB_ALLONES ((FbBits) -1)
+
+#if GLYPHPADBYTES != 4
+#error "GLYPHPADBYTES must be 4"
+#endif
+
+/* for driver compat - intel UXA needs the second one at least */
+#define FB_24BIT
+#define FB_24_32BIT
+
+#define FB_STIP_SHIFT LOG2_BITMAP_PAD
+#define FB_STIP_UNIT (1 << FB_STIP_SHIFT)
+#define FB_STIP_MASK (FB_STIP_UNIT - 1)
+#define FB_STIP_ALLONES ((FbStip) -1)
+
+#define FB_STIP_ODDSTRIDE(s) (((s) & (FB_MASK >> FB_STIP_SHIFT)) != 0)
+#define FB_STIP_ODDPTR(p) ((((long) (p)) & (FB_MASK >> 3)) != 0)
+
+#define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))
+#define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))
+
+#define FbFullMask(n) ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))
+
+#if FB_SHIFT == 6
+# ifdef WIN32
+typedef unsigned __int64 FbBits;
+# else
+# if defined(__alpha__) || defined(__alpha) || \
+ defined(ia64) || defined(__ia64__) || \
+ defined(__sparc64__) || defined(_LP64) || \
+ defined(__s390x__) || \
+ defined(amd64) || defined (__amd64__) || \
+ defined (__powerpc64__)
+typedef unsigned long FbBits;
+# else
+typedef unsigned long long FbBits;
+# endif
+# endif
+#endif
+
+#if FB_SHIFT == 5
+typedef CARD32 FbBits;
+#endif
+
+#if FB_SHIFT == 4
+typedef CARD16 FbBits;
+#endif
+
+#if LOG2_BITMAP_PAD == FB_SHIFT
+typedef FbBits FbStip;
+#else
+# if LOG2_BITMAP_PAD == 5
+typedef CARD32 FbStip;
+# endif
+#endif
+
+typedef int FbStride;
+
+
+#ifdef FB_DEBUG
+extern _X_EXPORT void fbValidateDrawable(DrawablePtr d);
+extern _X_EXPORT void fbInitializeDrawable(DrawablePtr d);
+extern _X_EXPORT void fbSetBits (FbStip *bits, int stride, FbStip data);
+#define FB_HEAD_BITS (FbStip) (0xbaadf00d)
+#define FB_TAIL_BITS (FbStip) (0xbaddf0ad)
+#else
+#define fbValidateDrawable(d)
+#define fdInitializeDrawable(d)
+#endif
+
+#include "fbrop.h"
+
+#if BITMAP_BIT_ORDER == LSBFirst
+#define FbScrLeft(x,n) ((x) >> (n))
+#define FbScrRight(x,n) ((x) << (n))
+/* #define FbLeftBits(x,n) ((x) & ((((FbBits) 1) << (n)) - 1)) */
+#define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1))
+#define FbStipMoveLsb(x,s,n) (FbStipRight (x,(s)-(n)))
+#define FbPatternOffsetBits 0
+#else
+#define FbScrLeft(x,n) ((x) << (n))
+#define FbScrRight(x,n) ((x) >> (n))
+/* #define FbLeftBits(x,n) ((x) >> (FB_UNIT - (n))) */
+#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
+#define FbStipMoveLsb(x,s,n) (x)
+#define FbPatternOffsetBits (sizeof (FbBits) - 1)
+#endif
+
+#include "micoord.h"
+
+#define FbStipLeft(x,n) FbScrLeft(x,n)
+#define FbStipRight(x,n) FbScrRight(x,n)
+
+#define FbRotLeft(x,n) FbScrLeft(x,n) | (n ? FbScrRight(x,FB_UNIT-n) : 0)
+#define FbRotRight(x,n) FbScrRight(x,n) | (n ? FbScrLeft(x,FB_UNIT-n) : 0)
+
+#define FbRotStipLeft(x,n) FbStipLeft(x,n) | (n ? FbStipRight(x,FB_STIP_UNIT-n) : 0)
+#define FbRotStipRight(x,n) FbStipRight(x,n) | (n ? FbStipLeft(x,FB_STIP_UNIT-n) : 0)
+
+#define FbLeftMask(x) ( ((x) & FB_MASK) ? \
+ FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
+#define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \
+ FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
+
+#define FbLeftStipMask(x) ( ((x) & FB_STIP_MASK) ? \
+ FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0)
+#define FbRightStipMask(x) ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \
+ FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0)
+
+#define FbBitsMask(x,w) (FbScrRight(FB_ALLONES,(x) & FB_MASK) & \
+ FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK))
+
+#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \
+ FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))
+
+
+#define FbMaskBits(x,w,l,n,r) { \
+ n = (w); \
+ r = FbRightMask((x)+n); \
+ l = FbLeftMask(x); \
+ if (l) { \
+ n -= FB_UNIT - ((x) & FB_MASK); \
+ if (n < 0) { \
+ n = 0; \
+ l &= r; \
+ r = 0; \
+ } \
+ } \
+ n >>= FB_SHIFT; \
+}
+
+
+#define FbByteMaskInvalid 0x10
+
+#define FbPatternOffset(o,t) ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1)))
+
+#define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o)))
+#define FbSelectPatternPart(xor,o,t) ((xor) >> (FbPatternOffset (o,t) << 3))
+#define FbStorePart(dst,off,t,xor) (WRITE(FbPtrOffset(dst,off,t), \
+ FbSelectPart(xor,off,t)))
+#ifndef FbSelectPart
+#define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t)
+#endif
+
+#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \
+ n = (w); \
+ lb = 0; \
+ rb = 0; \
+ r = FbRightMask((x)+n); \
+ if (r) { \
+ /* compute right byte length */ \
+ if ((copy) && (((x) + n) & 7) == 0) { \
+ rb = (((x) + n) & FB_MASK) >> 3; \
+ } else { \
+ rb = FbByteMaskInvalid; \
+ } \
+ } \
+ l = FbLeftMask(x); \
+ if (l) { \
+ /* compute left byte length */ \
+ if ((copy) && ((x) & 7) == 0) { \
+ lb = ((x) & FB_MASK) >> 3; \
+ } else { \
+ lb = FbByteMaskInvalid; \
+ } \
+ /* subtract out the portion painted by leftMask */ \
+ n -= FB_UNIT - ((x) & FB_MASK); \
+ if (n < 0) { \
+ if (lb != FbByteMaskInvalid) { \
+ if (rb == FbByteMaskInvalid) { \
+ lb = FbByteMaskInvalid; \
+ } else if (rb) { \
+ lb |= (rb - lb) << (FB_SHIFT - 3); \
+ rb = 0; \
+ } \
+ } \
+ n = 0; \
+ l &= r; \
+ r = 0; \
+ }\
+ } \
+ n >>= FB_SHIFT; \
+}
+
+#if FB_SHIFT == 6
+#define FbDoLeftMaskByteRRop6Cases(dst,xor) \
+ case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 6): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 5): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break; \
+ case (sizeof (FbBits) - 4) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 4) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 4) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 4): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break;
+
+#define FbDoRightMaskByteRRop6Cases(dst,xor) \
+ case 4: \
+ FbStorePart(dst,0,CARD32,xor); \
+ break; \
+ case 5: \
+ FbStorePart(dst,0,CARD32,xor); \
+ FbStorePart(dst,4,CARD8,xor); \
+ break; \
+ case 6: \
+ FbStorePart(dst,0,CARD32,xor); \
+ FbStorePart(dst,4,CARD16,xor); \
+ break; \
+ case 7: \
+ FbStorePart(dst,0,CARD32,xor); \
+ FbStorePart(dst,4,CARD16,xor); \
+ FbStorePart(dst,6,CARD8,xor); \
+ break;
+#else
+#define FbDoLeftMaskByteRRop6Cases(dst,xor)
+#define FbDoRightMaskByteRRop6Cases(dst,xor)
+#endif
+
+#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
+ switch (lb) { \
+ FbDoLeftMaskByteRRop6Cases(dst,xor) \
+ case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 3) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 2) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case sizeof (FbBits) - 3: \
+ FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
+ case sizeof (FbBits) - 2: \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD16,xor); \
+ break; \
+ case sizeof (FbBits) - 1: \
+ FbStorePart(dst,sizeof (FbBits) - 1,CARD8,xor); \
+ break; \
+ default: \
+ WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, l)); \
+ break; \
+ } \
+}
+
+
+#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
+ switch (rb) { \
+ case 1: \
+ FbStorePart(dst,0,CARD8,xor); \
+ break; \
+ case 2: \
+ FbStorePart(dst,0,CARD16,xor); \
+ break; \
+ case 3: \
+ FbStorePart(dst,0,CARD16,xor); \
+ FbStorePart(dst,2,CARD8,xor); \
+ break; \
+ FbDoRightMaskByteRRop6Cases(dst,xor) \
+ default: \
+ WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, r)); \
+ } \
+}
+
+#define FbMaskStip(x,w,l,n,r) { \
+ n = (w); \
+ r = FbRightStipMask((x)+n); \
+ l = FbLeftStipMask(x); \
+ if (l) { \
+ n -= FB_STIP_UNIT - ((x) & FB_STIP_MASK); \
+ if (n < 0) { \
+ n = 0; \
+ l &= r; \
+ r = 0; \
+ } \
+ } \
+ n >>= FB_STIP_SHIFT; \
+}
+
+/*
+ * These macros are used to transparently stipple
+ * in copy mode; the expected usage is with 'n' constant
+ * so all of the conditional parts collapse into a minimal
+ * sequence of partial word writes
+ *
+ * 'n' is the bytemask of which bytes to store, 'a' is the address
+ * of the FbBits base unit, 'o' is the offset within that unit
+ *
+ * The term "lane" comes from the hardware term "byte-lane" which
+ */
+
+#define FbLaneCase1(n,a,o) \
+ if ((n) == 0x01) { \
+ WRITE((CARD8 *) ((a)+FbPatternOffset(o,CARD8)), fgxor); \
+ }
+
+#define FbLaneCase2(n,a,o) \
+ if ((n) == 0x03) { \
+ WRITE((CARD16 *) ((a)+FbPatternOffset(o,CARD16)), fgxor); \
+ } else { \
+ FbLaneCase1((n)&1,a,o) \
+ FbLaneCase1((n)>>1,a,(o)+1) \
+ }
+
+#define FbLaneCase4(n,a,o) \
+ if ((n) == 0x0f) { \
+ WRITE((CARD32 *) ((a)+FbPatternOffset(o,CARD32)), fgxor); \
+ } else { \
+ FbLaneCase2((n)&3,a,o) \
+ FbLaneCase2((n)>>2,a,(o)+2) \
+ }
+
+#define FbLaneCase8(n,a,o) \
+ if ((n) == 0x0ff) { \
+ *(FbBits *) ((a)+(o)) = fgxor; \
+ } else { \
+ FbLaneCase4((n)&15,a,o) \
+ FbLaneCase4((n)>>4,a,(o)+4) \
+ }
+
+#if FB_SHIFT == 6
+#define FbLaneCase(n,a) FbLaneCase8(n,(CARD8 *) (a),0)
+#endif
+
+#if FB_SHIFT == 5
+#define FbLaneCase(n,a) FbLaneCase4(n,(CARD8 *) (a),0)
+#endif
+
+/* Rotate a filled pixel value to the specified alignement */
+#define FbRot24(p,b) (FbScrRight(p,b) | FbScrLeft(p,24-(b)))
+#define FbRot24Stip(p,b) (FbStipRight(p,b) | FbStipLeft(p,24-(b)))
+
+/* step a filled pixel value to the next/previous FB_UNIT alignment */
+#define FbNext24Pix(p) (FbRot24(p,(24-FB_UNIT%24)))
+#define FbPrev24Pix(p) (FbRot24(p,FB_UNIT%24))
+#define FbNext24Stip(p) (FbRot24(p,(24-FB_STIP_UNIT%24)))
+#define FbPrev24Stip(p) (FbRot24(p,FB_STIP_UNIT%24))
+
+/* step a rotation value to the next/previous rotation value */
+#if FB_UNIT == 64
+#define FbNext24Rot(r) ((r) == 16 ? 0 : (r) + 8)
+#define FbPrev24Rot(r) ((r) == 0 ? 16 : (r) - 8)
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define FbFirst24Rot(x) (((x) + 8) % 24)
+#else
+#define FbFirst24Rot(x) ((x) % 24)
+#endif
+
+#endif
+
+#if FB_UNIT == 32
+#define FbNext24Rot(r) ((r) == 0 ? 16 : (r) - 8)
+#define FbPrev24Rot(r) ((r) == 16 ? 0 : (r) + 8)
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define FbFirst24Rot(x) (((x) + 16) % 24)
+#else
+#define FbFirst24Rot(x) ((x) % 24)
+#endif
+#endif
+
+#define FbNext24RotStip(r) ((r) == 0 ? 16 : (r) - 8)
+#define FbPrev24RotStip(r) ((r) == 16 ? 0 : (r) + 8)
+
+/* Whether 24-bit specific code is needed for this filled pixel value */
+#define FbCheck24Pix(p) ((p) == FbNext24Pix(p))
+
+/* Macros for dealing with dashing */
+
+#define FbDashDeclare \
+ unsigned char *__dash, *__firstDash, *__lastDash
+
+#define FbDashInit(pGC,pPriv,dashOffset,dashlen,even) { \
+ (even) = TRUE; \
+ __firstDash = (pGC)->dash; \
+ __lastDash = __firstDash + (pGC)->numInDashList; \
+ (dashOffset) %= (pPriv)->dashLength; \
+ \
+ __dash = __firstDash; \
+ while ((dashOffset) >= ((dashlen) = *__dash)) \
+ { \
+ (dashOffset) -= (dashlen); \
+ (even) = 1-(even); \
+ if (++__dash == __lastDash) \
+ __dash = __firstDash; \
+ } \
+ (dashlen) -= (dashOffset); \
+}
+
+#define FbDashNext(dashlen) { \
+ if (++__dash == __lastDash) \
+ __dash = __firstDash; \
+ (dashlen) = *__dash; \
+}
+
+/* as numInDashList is always even, this case can skip a test */
+
+#define FbDashNextEven(dashlen) { \
+ (dashlen) = *++__dash; \
+}
+
+#define FbDashNextOdd(dashlen) FbDashNext(dashlen)
+
+#define FbDashStep(dashlen,even) { \
+ if (!--(dashlen)) { \
+ FbDashNext(dashlen); \
+ (even) = 1-(even); \
+ } \
+}
+
+extern _X_EXPORT DevPrivateKey
+fbGetGCPrivateKey (void);
+
+extern _X_EXPORT DevPrivateKey
+fbGetWinPrivateKey (void);
+
+extern _X_EXPORT const GCOps fbGCOps;
+extern _X_EXPORT const GCFuncs fbGCFuncs;
+
+
+/* Framebuffer access wrapper */
+typedef FbBits (*ReadMemoryProcPtr)(const void *src, int size);
+typedef void (*WriteMemoryProcPtr)(void *dst, FbBits value, int size);
+typedef void (*SetupWrapProcPtr)(ReadMemoryProcPtr *pRead,
+ WriteMemoryProcPtr *pWrite,
+ DrawablePtr pDraw);
+typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw);
+
+#ifdef FB_ACCESS_WRAPPER
+
+#define fbPrepareAccess(pDraw) \
+ fbGetScreenPrivate((pDraw)->pScreen)->setupWrap( \
+ &wfbReadMemory, \
+ &wfbWriteMemory, \
+ (pDraw))
+#define fbFinishAccess(pDraw) \
+ fbGetScreenPrivate((pDraw)->pScreen)->finishWrap(pDraw)
+
+#else
+
+#define fbPrepareAccess(pPix)
+#define fbFinishAccess(pDraw)
+
+#endif
+
+
+extern _X_EXPORT DevPrivateKey
+fbGetScreenPrivateKey(void);
+
+/* private field of a screen */
+typedef struct {
+ unsigned char win32bpp; /* window bpp for 32-bpp images */
+ unsigned char pix32bpp; /* pixmap bpp for 32-bpp images */
+#ifdef FB_ACCESS_WRAPPER
+ SetupWrapProcPtr setupWrap; /* driver hook to set pixmap access wrapping */
+ FinishWrapProcPtr finishWrap; /* driver hook to clean up pixmap access wrapping */
+#endif
+} FbScreenPrivRec, *FbScreenPrivPtr;
+
+#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
+
+/* private field of GC */
+typedef struct {
+ FbBits and, xor; /* reduced rop values */
+ FbBits bgand, bgxor; /* for stipples */
+ FbBits fg, bg, pm; /* expanded and filled */
+ unsigned int dashLength; /* total of all dash elements */
+ unsigned char evenStipple; /* stipple is even */
+ unsigned char bpp; /* current drawable bpp */
+} FbGCPrivRec, *FbGCPrivPtr;
+
+#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
+ dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey()))
+
+#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
+#define fbGetExpose(pGC) ((pGC)->fExpose)
+#define fbGetFreeCompClip(pGC) ((pGC)->freeCompClip)
+#define fbGetRotatedPixmap(pGC) ((pGC)->pRotatedPixmap)
+
+#define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate)
+#define fbGetWindowPixmap(pWin) ((PixmapPtr)\
+ dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey()))
+
+#ifdef ROOTLESS
+#define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
+#define __fbPixDrawableY(pPix) ((pPix)->drawable.y)
+#else
+#define __fbPixDrawableX(pPix) 0
+#define __fbPixDrawableY(pPix) 0
+#endif
+
+#ifdef COMPOSITE
+#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x)
+#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y)
+#else
+#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix))
+#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix))
+#endif
+#define __fbPixOffXPix(pPix) (__fbPixDrawableX(pPix))
+#define __fbPixOffYPix(pPix) (__fbPixDrawableY(pPix))
+
+#define fbGetDrawablePixmap(pDrawable, pixmap, xoff, yoff) { \
+ if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
+ (pixmap) = fbGetWindowPixmap(pDrawable); \
+ (xoff) = __fbPixOffXWin(pixmap); \
+ (yoff) = __fbPixOffYWin(pixmap); \
+ } else { \
+ (pixmap) = (PixmapPtr) (pDrawable); \
+ (xoff) = __fbPixOffXPix(pixmap); \
+ (yoff) = __fbPixOffYPix(pixmap); \
+ } \
+ fbPrepareAccess(pDrawable); \
+}
+
+#define fbGetPixmapBitsData(pixmap, pointer, stride, bpp) { \
+ (pointer) = (FbBits *) (pixmap)->devPrivate.ptr; \
+ (stride) = ((int) (pixmap)->devKind) / sizeof (FbBits); (void)(stride); \
+ (bpp) = (pixmap)->drawable.bitsPerPixel; (void)(bpp); \
+}
+
+#define fbGetPixmapStipData(pixmap, pointer, stride, bpp) { \
+ (pointer) = (FbStip *) (pixmap)->devPrivate.ptr; \
+ (stride) = ((int) (pixmap)->devKind) / sizeof (FbStip); (void)(stride); \
+ (bpp) = (pixmap)->drawable.bitsPerPixel; (void)(bpp); \
+}
+
+#define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
+ PixmapPtr _pPix; \
+ fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff); \
+ fbGetPixmapBitsData(_pPix, pointer, stride, bpp); \
+}
+
+#define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
+ PixmapPtr _pPix; \
+ fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff); \
+ fbGetPixmapStipData(_pPix, pointer, stride, bpp); \
+}
+
+/*
+ * XFree86 empties the root BorderClip when the VT is inactive,
+ * here's a macro which uses that to disable GetImage and GetSpans
+ */
+
+#define fbWindowEnabled(pWin) \
+ RegionNotEmpty(&(pWin)->drawable.pScreen->root->borderClip)
+
+#define fbDrawableEnabled(pDrawable) \
+ ((pDrawable)->type == DRAWABLE_PIXMAP ? \
+ TRUE : fbWindowEnabled((WindowPtr) pDrawable))
+
+#define FbPowerOfTwo(w) (((w) & ((w) - 1)) == 0)
+/*
+ * Accelerated tiles are power of 2 width <= FB_UNIT
+ */
+#define FbEvenTile(w) ((w) <= FB_UNIT && FbPowerOfTwo(w))
+/*
+ * Accelerated stipples are power of 2 width and <= FB_UNIT/dstBpp
+ * with dstBpp a power of 2 as well
+ */
+#define FbEvenStip(w,bpp) ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp))
+
+/*
+ * fb24_32.c
+ */
+extern _X_EXPORT void
+fb24_32GetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart);
+
+extern _X_EXPORT void
+fb24_32SetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted);
+
+extern _X_EXPORT void
+fb24_32PutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ CARD8 *src,
+ FbStride srcStride);
+
+extern _X_EXPORT void
+fb24_32GetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d);
+
+extern _X_EXPORT void
+fb24_32CopyMtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT PixmapPtr
+fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel);
+
+extern _X_EXPORT Bool
+fb24_32CreateScreenResources(ScreenPtr pScreen);
+
+extern _X_EXPORT Bool
+fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
+ int width,
+ int height,
+ int depth,
+ int bitsPerPixel,
+ int devKind,
+ pointer pPixData);
+
+/*
+ * fballpriv.c
+ */
+extern _X_EXPORT Bool
+fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex);
+
+/*
+ * fbarc.c
+ */
+
+extern _X_EXPORT void
+fbPolyArc (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs);
+
+/*
+ * fbbits.c
+ */
+
+extern _X_EXPORT void
+fbBresSolid8(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbBresDash8 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbDots8 (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbArc8 (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbGlyph8 (FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+
+extern _X_EXPORT void
+fbPolyline8 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+extern _X_EXPORT void
+fbPolySegment8 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+extern _X_EXPORT void
+fbBresSolid16(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbBresDash16(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbDots16(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbArc16(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbGlyph16(FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+
+extern _X_EXPORT void
+fbPolyline16 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+extern _X_EXPORT void
+fbPolySegment16 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+
+extern _X_EXPORT void
+fbBresSolid24(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbBresDash24(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbDots24(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbArc24(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbGlyph24(FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+
+extern _X_EXPORT void
+fbPolyline24 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+extern _X_EXPORT void
+fbPolySegment24 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+
+extern _X_EXPORT void
+fbBresSolid32(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbBresDash32(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbDots32(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbArc32(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbGlyph32(FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+extern _X_EXPORT void
+fbPolyline32 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+extern _X_EXPORT void
+fbPolySegment32 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+/*
+ * fbblt.c
+ */
+extern _X_EXPORT void
+fbBlt (FbBits *src,
+ FbStride srcStride,
+ int srcX,
+
+ FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ Bool reverse,
+ Bool upsidedown);
+
+extern _X_EXPORT void
+fbBlt24 (FbBits *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ FbBits *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+
+ Bool reverse,
+ Bool upsidedown);
+
+extern _X_EXPORT void
+fbBltStip (FbStip *src,
+ FbStride srcStride, /* in FbStip units, not FbBits units */
+ int srcX,
+
+ FbStip *dst,
+ FbStride dstStride, /* in FbStip units, not FbBits units */
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp);
+
+/*
+ * fbbltone.c
+ */
+extern _X_EXPORT void
+fbBltOne (FbStip *src,
+ FbStride srcStride,
+ int srcX,
+ FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbBits fgand,
+ FbBits fbxor,
+ FbBits bgand,
+ FbBits bgxor);
+
+extern _X_EXPORT void
+fbBltOne24 (FbStip *src,
+ FbStride srcStride, /* FbStip units per scanline */
+ int srcX, /* bit position of source */
+ FbBits *dst,
+ FbStride dstStride, /* FbBits units per scanline */
+ int dstX, /* bit position of dest */
+ int dstBpp, /* bits per destination unit */
+
+ int width, /* width in bits of destination */
+ int height, /* height in scanlines */
+
+ FbBits fgand, /* rrop values */
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor);
+
+extern _X_EXPORT void
+fbBltPlane (FbBits *src,
+ FbStride srcStride,
+ int srcX,
+ int srcBpp,
+
+ FbStip *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbStip fgand,
+ FbStip fgxor,
+ FbStip bgand,
+ FbStip bgxor,
+ Pixel planeMask);
+
+/*
+ * fbcmap_mi.c
+ */
+extern _X_EXPORT int
+fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps);
+
+extern _X_EXPORT void
+fbInstallColormap(ColormapPtr pmap);
+
+extern _X_EXPORT void
+fbUninstallColormap(ColormapPtr pmap);
+
+extern _X_EXPORT void
+fbResolveColor(unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue,
+ VisualPtr pVisual);
+
+extern _X_EXPORT Bool
+fbInitializeColormap(ColormapPtr pmap);
+
+extern _X_EXPORT int
+fbExpandDirectColors (ColormapPtr pmap,
+ int ndef,
+ xColorItem *indefs,
+ xColorItem *outdefs);
+
+extern _X_EXPORT Bool
+fbCreateDefColormap(ScreenPtr pScreen);
+
+extern _X_EXPORT void
+fbClearVisualTypes(void);
+
+extern _X_EXPORT Bool
+fbHasVisualTypes (int depth);
+
+extern _X_EXPORT Bool
+fbSetVisualTypes (int depth, int visuals, int bitsPerRGB);
+
+extern _X_EXPORT Bool
+fbSetVisualTypesAndMasks (int depth, int visuals, int bitsPerRGB,
+ Pixel redMask, Pixel greenMask, Pixel blueMask);
+
+extern _X_EXPORT Bool
+fbInitVisuals (VisualPtr *visualp,
+ DepthPtr *depthp,
+ int *nvisualp,
+ int *ndepthp,
+ int *rootDepthp,
+ VisualID *defaultVisp,
+ unsigned long sizes,
+ int bitsPerRGB);
+
+/*
+ * fbcopy.c
+ */
+
+/* Compatibility definition, to be removed at next ABI change. */
+typedef void (*fbCopyProc) (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pDstBox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT void
+fbCopyNtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+/* Compatibility wrapper, to be removed at next ABI change. */
+extern _X_EXPORT void
+fbCopyRegion (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ RegionPtr pDstRegion,
+ int dx,
+ int dy,
+ fbCopyProc copyProc,
+ Pixel bitPlane,
+ void *closure);
+
+/* Compatibility wrapper, to be removed at next ABI change. */
+extern _X_EXPORT RegionPtr
+fbDoCopy (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut,
+ fbCopyProc copyProc,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT void
+fbCopy1toN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT void
+fbCopyNto1 (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT RegionPtr
+fbCopyArea (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut);
+
+extern _X_EXPORT RegionPtr
+fbCopyPlane (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut,
+ unsigned long bitplane);
+
+/*
+ * fbfill.c
+ */
+extern _X_EXPORT void
+fbFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int width,
+ int height);
+
+extern _X_EXPORT void
+fbSolidBoxClipped (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int xa,
+ int ya,
+ int xb,
+ int yb,
+ FbBits and,
+ FbBits xor);
+
+/*
+ * fbfillrect.c
+ */
+extern _X_EXPORT void
+fbPolyFillRect(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nrectInit,
+ xRectangle *prectInit);
+
+#define fbPolyFillArc miPolyFillArc
+
+#define fbFillPolygon miFillPolygon
+
+/*
+ * fbfillsp.c
+ */
+extern _X_EXPORT void
+fbFillSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nInit,
+ DDXPointPtr pptInit,
+ int *pwidthInit,
+ int fSorted);
+
+
+/*
+ * fbgc.c
+ */
+
+extern _X_EXPORT Bool
+fbCreateGC(GCPtr pGC);
+
+extern _X_EXPORT void
+fbPadPixmap (PixmapPtr pPixmap);
+
+extern _X_EXPORT void
+fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
+
+/*
+ * fbgetsp.c
+ */
+extern _X_EXPORT void
+fbGetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart);
+
+/*
+ * fbglyph.c
+ */
+
+extern _X_EXPORT Bool
+fbGlyphIn (RegionPtr pRegion,
+ int x,
+ int y,
+ int width,
+ int height);
+
+extern _X_EXPORT void
+fbPolyGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase);
+
+extern _X_EXPORT void
+fbImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase);
+
+/*
+ * fbimage.c
+ */
+
+extern _X_EXPORT void
+fbPutImage (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage);
+
+extern _X_EXPORT void
+fbPutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ FbStip *src,
+ FbStride srcStride);
+
+extern _X_EXPORT void
+fbPutXYImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ FbBits fg,
+ FbBits bg,
+ FbBits pm,
+ int alu,
+ Bool opaque,
+
+ int x,
+ int y,
+ int width,
+ int height,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX);
+
+extern _X_EXPORT void
+fbGetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d);
+/*
+ * fbline.c
+ */
+
+extern _X_EXPORT void
+fbZeroLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt);
+
+extern _X_EXPORT void
+fbZeroSegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSegs);
+
+extern _X_EXPORT void
+fbPolyLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt);
+
+extern _X_EXPORT void
+fbFixCoordModePrevious (int npt,
+ DDXPointPtr ppt);
+
+extern _X_EXPORT void
+fbPolySegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+#define fbPolyRectangle miPolyRectangle
+
+/*
+ * fbpict.c
+ */
+
+extern _X_EXPORT Bool
+fbPictureInit (ScreenPtr pScreen,
+ PictFormatPtr formats,
+ int nformats);
+
+/*
+ * fbpixmap.c
+ */
+
+extern _X_EXPORT PixmapPtr
+fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
+ unsigned usage_hint);
+
+extern _X_EXPORT PixmapPtr
+fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth,
+ unsigned usage_hint);
+
+extern _X_EXPORT Bool
+fbDestroyPixmap (PixmapPtr pPixmap);
+
+extern _X_EXPORT RegionPtr
+fbPixmapToRegion(PixmapPtr pPix);
+
+/*
+ * fbpoint.c
+ */
+
+extern _X_EXPORT void
+fbDots (FbBits *dstOrig,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits andOrig,
+ FbBits xorOrig);
+
+extern _X_EXPORT void
+fbPolyPoint (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ xPoint *pptInit);
+
+/*
+ * fbpush.c
+ */
+extern _X_EXPORT void
+fbPushPattern (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+
+ int width,
+ int height);
+
+extern _X_EXPORT void
+fbPushFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+ int width,
+ int height);
+
+extern _X_EXPORT void
+fbPushImage (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+ int width,
+ int height);
+
+extern _X_EXPORT void
+fbPushPixels (GCPtr pGC,
+ PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int dx,
+ int dy,
+ int xOrg,
+ int yOrg);
+
+
+/*
+ * fbscreen.c
+ */
+
+extern _X_EXPORT Bool
+fbCloseScreen (int indx, ScreenPtr pScreen);
+
+extern _X_EXPORT Bool
+fbRealizeFont(ScreenPtr pScreen, FontPtr pFont);
+
+extern _X_EXPORT Bool
+fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
+
+extern _X_EXPORT void
+fbQueryBestSize (int class,
+ unsigned short *width, unsigned short *height,
+ ScreenPtr pScreen);
+
+extern _X_EXPORT PixmapPtr
+_fbGetWindowPixmap (WindowPtr pWindow);
+
+extern _X_EXPORT void
+_fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap);
+
+extern _X_EXPORT Bool
+fbSetupScreen(ScreenPtr pScreen,
+ pointer pbits, /* pointer to screen bitmap */
+ int xsize, /* in pixels */
+ int ysize,
+ int dpix, /* dots per inch */
+ int dpiy,
+ int width, /* pixel width of frame buffer */
+ int bpp); /* bits per pixel of frame buffer */
+
+extern _X_EXPORT Bool
+wfbFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp,
+ SetupWrapProcPtr setupWrap,
+ FinishWrapProcPtr finishWrap);
+
+extern _X_EXPORT Bool
+wfbScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp,
+ SetupWrapProcPtr setupWrap,
+ FinishWrapProcPtr finishWrap);
+
+extern _X_EXPORT Bool
+fbFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp);
+
+extern _X_EXPORT Bool
+fbScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp);
+
+/*
+ * fbseg.c
+ */
+typedef void FbBres (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT FbBres fbBresSolid, fbBresDash, fbBresFill, fbBresFillDash;
+/*
+ * fbsetsp.c
+ */
+
+extern _X_EXPORT void
+fbSetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted);
+
+extern _X_EXPORT FbBres *
+fbSelectBres (DrawablePtr pDrawable,
+ GCPtr pGC);
+
+extern _X_EXPORT void
+fbBres (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbSegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xa,
+ int ya,
+ int xb,
+ int yb,
+ Bool drawLast,
+ int *dashOffset);
+
+
+/*
+ * fbsolid.c
+ */
+
+extern _X_EXPORT void
+fbSolid (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int bpp,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbSolid24 (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor);
+
+/*
+ * fbstipple.c
+ */
+
+extern _X_EXPORT void
+fbTransparentSpan (FbBits *dst,
+ FbBits stip,
+ FbBits fgxor,
+ int n);
+
+extern _X_EXPORT void
+fbEvenStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipHeight,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot);
+
+extern _X_EXPORT void
+fbOddStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipWidth,
+ int stipHeight,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot);
+
+extern _X_EXPORT void
+fbStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipWidth,
+ int stipHeight,
+ Bool even,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot);
+
+/*
+ * fbtile.c
+ */
+
+extern _X_EXPORT void
+fbEvenTile (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ FbStride tileStride,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int xRot,
+ int yRot);
+
+extern _X_EXPORT void
+fbOddTile (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ int xRot,
+ int yRot);
+
+extern _X_EXPORT void
+fbTile (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ int xRot,
+ int yRot);
+
+/*
+ * fbutil.c
+ */
+extern _X_EXPORT FbBits
+fbReplicatePixel (Pixel p, int bpp);
+
+extern _X_EXPORT void
+fbReduceRasterOp (int rop, FbBits fg, FbBits pm, FbBits *andp, FbBits *xorp);
+
+#ifdef FB_ACCESS_WRAPPER
+extern _X_EXPORT ReadMemoryProcPtr wfbReadMemory;
+extern _X_EXPORT WriteMemoryProcPtr wfbWriteMemory;
+#endif
+
+/*
+ * fbwindow.c
+ */
+
+extern _X_EXPORT Bool
+fbCreateWindow(WindowPtr pWin);
+
+extern _X_EXPORT Bool
+fbDestroyWindow(WindowPtr pWin);
+
+extern _X_EXPORT Bool
+fbMapWindow(WindowPtr pWindow);
+
+extern _X_EXPORT Bool
+fbPositionWindow(WindowPtr pWin, int x, int y);
+
+extern _X_EXPORT Bool
+fbUnmapWindow(WindowPtr pWindow);
+
+extern _X_EXPORT void
+fbCopyWindowProc (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT void
+fbCopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+
+extern _X_EXPORT Bool
+fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
+
+extern _X_EXPORT void
+fbFillRegionSolid (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT pixman_image_t *
+image_from_pict (PicturePtr pict,
+ Bool has_clip,
+ int *xoff,
+ int *yoff);
+
+extern _X_EXPORT void free_pixman_pict (PicturePtr, pixman_image_t *);
+
+#endif /* _FB_H_ */
+
diff --git a/xorg-server/fb/fballpriv.c b/xorg-server/fb/fballpriv.c
index b4fcb1f4a..321903628 100644
--- a/xorg-server/fb/fballpriv.c
+++ b/xorg-server/fb/fballpriv.c
@@ -1,64 +1,60 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-#ifdef FB_SCREEN_PRIVATE
-static DevPrivateKeyRec fbScreenPrivateKeyRec;
-DevPrivateKey
-fbGetScreenPrivateKey(void) { return &fbScreenPrivateKeyRec; }
-#endif
-
-static DevPrivateKeyRec fbGCPrivateKeyRec;
-DevPrivateKey
-fbGetGCPrivateKey (void) { return &fbGCPrivateKeyRec; }
-
-static DevPrivateKeyRec fbWinPrivateKeyRec;
-DevPrivateKey
-fbGetWinPrivateKey (void) { return &fbWinPrivateKeyRec; }
-
-Bool
-fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
-{
- if (pGCKey)
- *pGCKey = &fbGCPrivateKeyRec;
-
- if (!dixRegisterPrivateKey(&fbGCPrivateKeyRec, PRIVATE_GC, sizeof(FbGCPrivRec)))
- return FALSE;
-#ifdef FB_SCREEN_PRIVATE
- if (!dixRegisterPrivateKey(&fbScreenPrivateKeyRec, PRIVATE_SCREEN, sizeof (FbScreenPrivRec)))
- return FALSE;
-#endif
- if (!dixRegisterPrivateKey(&fbWinPrivateKeyRec, PRIVATE_WINDOW, 0))
- return FALSE;
-
- return TRUE;
-}
-
-#ifdef FB_ACCESS_WRAPPER
-ReadMemoryProcPtr wfbReadMemory;
-WriteMemoryProcPtr wfbWriteMemory;
-#endif
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+static DevPrivateKeyRec fbScreenPrivateKeyRec;
+DevPrivateKey
+fbGetScreenPrivateKey(void) { return &fbScreenPrivateKeyRec; }
+
+static DevPrivateKeyRec fbGCPrivateKeyRec;
+DevPrivateKey
+fbGetGCPrivateKey (void) { return &fbGCPrivateKeyRec; }
+
+static DevPrivateKeyRec fbWinPrivateKeyRec;
+DevPrivateKey
+fbGetWinPrivateKey (void) { return &fbWinPrivateKeyRec; }
+
+Bool
+fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
+{
+ if (pGCKey)
+ *pGCKey = &fbGCPrivateKeyRec;
+
+ if (!dixRegisterPrivateKey(&fbGCPrivateKeyRec, PRIVATE_GC, sizeof(FbGCPrivRec)))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&fbScreenPrivateKeyRec, PRIVATE_SCREEN, sizeof (FbScreenPrivRec)))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&fbWinPrivateKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
+ return TRUE;
+}
+
+#ifdef FB_ACCESS_WRAPPER
+ReadMemoryProcPtr wfbReadMemory;
+WriteMemoryProcPtr wfbWriteMemory;
+#endif
diff --git a/xorg-server/fb/fbarc.c b/xorg-server/fb/fbarc.c
index 1da980255..a0c5343e0 100644
--- a/xorg-server/fb/fbarc.c
+++ b/xorg-server/fb/fbarc.c
@@ -1,149 +1,145 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-#include "mizerarc.h"
-#include <limits.h>
-
-typedef void (*FbArc) (FbBits *dst,
- FbStride dstStride,
- int dstBpp,
- xArc *arc,
- int dx,
- int dy,
- FbBits and,
- FbBits xor);
-
-void
-fbPolyArc (DrawablePtr pDrawable,
- GCPtr pGC,
- int narcs,
- xArc *parcs)
-{
- FbArc arc;
-
- if (pGC->lineWidth == 0)
- {
-#ifndef FBNOPIXADDR
- arc = 0;
- if (pGC->lineStyle == LineSolid && pGC->fillStyle == FillSolid)
- {
- switch (pDrawable->bitsPerPixel)
- {
- case 8: arc = fbArc8; break;
- case 16: arc = fbArc16; break;
-#ifdef FB_24BIT
- case 24: arc = fbArc24; break;
-#endif
- case 32: arc = fbArc32; break;
- }
- }
- if (arc)
- {
- FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
- FbBits *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- BoxRec box;
- int x2, y2;
- RegionPtr cclip;
- int wrapped = 0;
-
- cclip = fbGetCompositeClip (pGC);
- fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-#ifdef FB_ACCESS_WRAPPER
- wrapped = 1;
-#else
- wrapped = 0;
-#endif
- while (narcs--)
- {
- if (miCanZeroArc (parcs))
- {
- box.x1 = parcs->x + pDrawable->x;
- box.y1 = parcs->y + pDrawable->y;
- /*
- * Because box.x2 and box.y2 get truncated to 16 bits, and the
- * RECT_IN_REGION test treats the resulting number as a signed
- * integer, the RECT_IN_REGION test alone can go the wrong way.
- * This can result in a server crash because the rendering
- * routines in this file deal directly with cpu addresses
- * of pixels to be stored, and do not clip or otherwise check
- * that all such addresses are within their respective pixmaps.
- * So we only allow the RECT_IN_REGION test to be used for
- * values that can be expressed correctly in a signed short.
- */
- x2 = box.x1 + (int)parcs->width + 1;
- box.x2 = x2;
- y2 = box.y1 + (int)parcs->height + 1;
- box.y2 = y2;
- if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) &&
- (RegionContainsRect(cclip, &box) == rgnIN) ) {
-#ifdef FB_ACCESS_WRAPPER
- if (!wrapped) {
- fbPrepareAccess (pDrawable);
- wrapped = 1;
- }
-#endif
- (*arc) (dst, dstStride, dstBpp,
- parcs, pDrawable->x + dstXoff, pDrawable->y + dstYoff,
- pPriv->and, pPriv->xor);
- } else {
-#ifdef FB_ACCESS_WRAPPER
- if (wrapped) {
- fbFinishAccess (pDrawable);
- wrapped = 0;
- }
-#endif
- miZeroPolyArc(pDrawable, pGC, 1, parcs);
- }
- }
- else {
-#ifdef FB_ACCESS_WRAPPER
- if (wrapped) {
- fbFinishAccess (pDrawable);
- wrapped = 0;
- }
-#endif
- miPolyArc(pDrawable, pGC, 1, parcs);
- }
- parcs++;
- }
-#ifdef FB_ACCESS_WRAPPER
- if (wrapped) {
- fbFinishAccess (pDrawable);
- wrapped = 0;
- }
-#endif
- }
- else
-#endif
- miZeroPolyArc (pDrawable, pGC, narcs, parcs);
- }
- else
- miPolyArc (pDrawable, pGC, narcs, parcs);
-}
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "mizerarc.h"
+#include <limits.h>
+
+typedef void (*FbArc) (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+void
+fbPolyArc (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs)
+{
+ FbArc arc;
+
+ if (pGC->lineWidth == 0)
+ {
+ arc = 0;
+ if (pGC->lineStyle == LineSolid && pGC->fillStyle == FillSolid)
+ {
+ switch (pDrawable->bitsPerPixel)
+ {
+ case 8: arc = fbArc8; break;
+ case 16: arc = fbArc16; break;
+ case 24: arc = fbArc24; break;
+ case 32: arc = fbArc32; break;
+ }
+ }
+ if (arc)
+ {
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ BoxRec box;
+ int x2, y2;
+ RegionPtr cclip;
+ int wrapped = 0;
+
+ cclip = fbGetCompositeClip (pGC);
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+#ifdef FB_ACCESS_WRAPPER
+ wrapped = 1;
+#else
+ wrapped = 0;
+#endif
+ while (narcs--)
+ {
+ if (miCanZeroArc (parcs))
+ {
+ box.x1 = parcs->x + pDrawable->x;
+ box.y1 = parcs->y + pDrawable->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int)parcs->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int)parcs->height + 1;
+ box.y2 = y2;
+ if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) &&
+ (RegionContainsRect(cclip, &box) == rgnIN) ) {
+#ifdef FB_ACCESS_WRAPPER
+ if (!wrapped) {
+ fbPrepareAccess (pDrawable);
+ wrapped = 1;
+ }
+#endif
+ (*arc) (dst, dstStride, dstBpp,
+ parcs, pDrawable->x + dstXoff, pDrawable->y + dstYoff,
+ pPriv->and, pPriv->xor);
+ } else {
+#ifdef FB_ACCESS_WRAPPER
+ if (wrapped) {
+ fbFinishAccess (pDrawable);
+ wrapped = 0;
+ }
+#endif
+ miZeroPolyArc(pDrawable, pGC, 1, parcs);
+ }
+ }
+ else {
+#ifdef FB_ACCESS_WRAPPER
+ if (wrapped) {
+ fbFinishAccess (pDrawable);
+ wrapped = 0;
+ }
+#endif
+ miPolyArc(pDrawable, pGC, 1, parcs);
+ }
+ parcs++;
+ }
+#ifdef FB_ACCESS_WRAPPER
+ if (wrapped) {
+ fbFinishAccess (pDrawable);
+ wrapped = 0;
+ }
+#endif
+ }
+ else
+ miZeroPolyArc (pDrawable, pGC, narcs, parcs);
+ }
+ else
+ miPolyArc (pDrawable, pGC, narcs, parcs);
+}
diff --git a/xorg-server/fb/fbbits.c b/xorg-server/fb/fbbits.c
index 808374309..850d1632e 100644
--- a/xorg-server/fb/fbbits.c
+++ b/xorg-server/fb/fbbits.c
@@ -89,7 +89,6 @@
#undef BITS4
#endif
-#ifdef FB_24BIT
#define BRESSOLID fbBresSolid24
#define BRESDASH fbBresDash24
#define DOTS fbDots24
@@ -147,7 +146,6 @@
#undef ARC
#undef POLYLINE
#undef POLYSEGMENT
-#endif /* FB_24BIT */
#define BRESSOLID fbBresSolid32
#define BRESDASH fbBresDash32
diff --git a/xorg-server/fb/fbblt.c b/xorg-server/fb/fbblt.c
index 38271c0c9..a0402986c 100644
--- a/xorg-server/fb/fbblt.c
+++ b/xorg-server/fb/fbblt.c
@@ -67,14 +67,12 @@ fbBlt (FbBits *srcLine,
int startbyte, endbyte;
FbDeclareMergeRop ();
-#ifdef FB_24BIT
if (bpp == 24 && !FbCheck24Pix (pm))
{
fbBlt24 (srcLine, srcStride, srcX, dstLine, dstStride, dstX,
width, height, alu, pm, reverse, upsidedown);
return;
}
-#endif
if (alu == GXcopy && pm == FB_ALLONES && !reverse &&
!(srcX & 7) && !(dstX & 7) && !(width & 7)) {
@@ -338,7 +336,6 @@ fbBlt (FbBits *srcLine,
}
}
-#ifdef FB_24BIT
#undef DEBUG_BLT24
#ifdef DEBUG_BLT24
@@ -603,7 +600,6 @@ fbBlt24 (FbBits *srcLine,
ErrorF ("\n");
#endif
}
-#endif /* FB_24BIT */
#if FB_SHIFT == FB_STIP_SHIFT + 1
@@ -784,7 +780,6 @@ fbBltOdd (FbBits *srcLine,
}
}
-#ifdef FB_24BIT
void
fbBltOdd24 (FbBits *srcLine,
FbStride srcStrideEven,
@@ -826,7 +821,6 @@ fbBltOdd24 (FbBits *srcLine,
}
}
}
-#endif
#endif
@@ -915,7 +909,6 @@ fbBltStip (FbStip *src,
&dstStrideEven, &dstStrideOdd,
&dstXEven, &dstXOdd);
-#ifdef FB_24BIT
if (bpp == 24 && !FbCheck24Pix (pm))
{
fbBltOdd24 (s, srcStrideEven, srcStrideOdd,
@@ -927,7 +920,6 @@ fbBltStip (FbStip *src,
width, height, alu, pm);
}
else
-#endif
{
fbBltOdd (s, srcStrideEven, srcStrideOdd,
srcXEven, srcXOdd,
diff --git a/xorg-server/fb/fbbltone.c b/xorg-server/fb/fbbltone.c
index 5d5d2e6bf..629b13a0e 100644
--- a/xorg-server/fb/fbbltone.c
+++ b/xorg-server/fb/fbbltone.c
@@ -57,7 +57,6 @@
bits = (src < srcEnd ? READ(src++) : 0); \
}
-#ifndef FBNOPIXADDR
#define LaneCases1(n,a) case n: FbLaneCase(n,a); break
#define LaneCases2(n,a) LaneCases1(n,a); LaneCases1(n+1,a)
@@ -128,7 +127,6 @@ CARD8 *fbLaneTable[33] = {
0, 0, 0, 0, 0, 0, 0, 0,
fb32Lane
};
-#endif
void
fbBltOne (FbStip *src,
@@ -164,12 +162,9 @@ fbBltOne (FbStip *src,
Bool transparent; /* accelerate 0 nop */
int srcinc; /* source units consumed */
Bool endNeedsLoad = FALSE; /* need load for endmask */
-#ifndef FBNOPIXADDR
CARD8 *fbLane;
-#endif
int startbyte, endbyte;
-#ifdef FB_24BIT
if (dstBpp == 24)
{
fbBltOne24 (src, srcStride, srcX,
@@ -178,7 +173,6 @@ fbBltOne (FbStip *src,
fgand, fgxor, bgand, bgxor);
return;
}
-#endif
/*
* Do not read past the end of the buffer!
@@ -238,11 +232,9 @@ fbBltOne (FbStip *src,
fbBits = 0; /* unused */
if (pixelsPerDst <= 8)
fbBits = fbStippleTable[pixelsPerDst];
-#ifndef FBNOPIXADDR
fbLane = 0;
if (transparent && fgand == 0 && dstBpp >= 8)
fbLane = fbLaneTable[dstBpp];
-#endif
/*
* Compute total number of destination words written, but
@@ -302,13 +294,11 @@ fbBltOne (FbStip *src,
else
#endif
mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
-#ifndef FBNOPIXADDR
if (fbLane)
{
fbTransparentSpan (dst, mask & startmask, fgxor, 1);
}
else
-#endif
{
if (mask || !transparent)
FbDoLeftMaskByteStippleRRop (dst, mask,
@@ -343,7 +333,6 @@ fbBltOne (FbStip *src,
}
else
{
-#ifndef FBNOPIXADDR
if (fbLane)
{
while (bits && n)
@@ -358,7 +347,6 @@ fbBltOne (FbStip *src,
dst += n;
}
else
-#endif
{
while (n--)
{
@@ -400,13 +388,11 @@ fbBltOne (FbStip *src,
else
#endif
mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
-#ifndef FBNOPIXADDR
if (fbLane)
{
fbTransparentSpan (dst, mask & endmask, fgxor, 1);
}
else
-#endif
{
if (mask || !transparent)
FbDoRightMaskByteStippleRRop (dst, mask,
@@ -419,7 +405,6 @@ fbBltOne (FbStip *src,
}
}
-#ifdef FB_24BIT
/*
* Crufty macros to initialize the mask array, most of this
@@ -747,7 +732,6 @@ fbBltOne24 (FbStip *srcLine,
}
}
}
-#endif
/*
* Not very efficient, but simple -- copy a single plane
@@ -801,7 +785,6 @@ fbBltPlane (FbBits *src,
w = width / srcBpp;
pm = fbReplicatePixel (planeMask, srcBpp);
-#ifdef FB_24BIT
if (srcBpp == 24)
{
int w = 24;
@@ -812,7 +795,6 @@ fbBltPlane (FbBits *src,
srcMaskFirst = FbRot24(pm,rot0) & FbBitsMask(srcX,w);
}
else
-#endif
{
rot0 = 0;
srcMaskFirst = pm & FbBitsMask(srcX, srcBpp);
@@ -828,10 +810,8 @@ fbBltPlane (FbBits *src,
src += srcStride;
srcMask = srcMaskFirst;
-#ifdef FB_24BIT
if (srcBpp == 24)
srcMask0 = FbRot24(pm,rot0) & FbBitsMask(0, srcBpp);
-#endif
srcBits = READ(s++);
dstMask = dstMaskFirst;
@@ -845,10 +825,8 @@ fbBltPlane (FbBits *src,
if (!srcMask)
{
srcBits = READ(s++);
-#ifdef FB_24BIT
if (srcBpp == 24)
srcMask0 = FbNext24Pix(srcMask0) & FbBitsMask(0,24);
-#endif
srcMask = srcMask0;
}
if (!dstMask)
diff --git a/xorg-server/fb/fbcopy.c b/xorg-server/fb/fbcopy.c
index 30cbf7b25..898320378 100644
--- a/xorg-server/fb/fbcopy.c
+++ b/xorg-server/fb/fbcopy.c
@@ -1,374 +1,372 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include "fb.h"
-
-/* Compatibility wrapper, to be removed at next ABI change. */
-void
-fbCopyRegion (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- RegionPtr pDstRegion,
- int dx,
- int dy,
- fbCopyProc copyProc,
- Pixel bitPlane,
- void *closure)
-{
- miCopyRegion(pSrcDrawable, pDstDrawable, pGC, pDstRegion, dx, dy, copyProc, bitPlane, closure);
-}
-
-/* Compatibility wrapper, to be removed at next ABI change. */
-RegionPtr
-fbDoCopy (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- int xIn,
- int yIn,
- int widthSrc,
- int heightSrc,
- int xOut,
- int yOut,
- fbCopyProc copyProc,
- Pixel bitPlane,
- void *closure)
-{
- return miDoCopy(pSrcDrawable, pDstDrawable, pGC, xIn, yIn, widthSrc, heightSrc, xOut, yOut, copyProc, bitPlane, closure);
-}
-
-void
-fbCopyNtoN (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pbox,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown,
- Pixel bitplane,
- void *closure)
-{
- CARD8 alu = pGC ? pGC->alu : GXcopy;
- FbBits pm = pGC ? fbGetGCPrivate(pGC)->pm : FB_ALLONES;
- FbBits *src;
- FbStride srcStride;
- int srcBpp;
- int srcXoff, srcYoff;
- FbBits *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
-
- fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
- fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-
- while (nbox--)
- {
-#ifndef FB_ACCESS_WRAPPER /* pixman_blt() doesn't support accessors yet */
- if (pm == FB_ALLONES && alu == GXcopy && !reverse &&
- !upsidedown)
- {
- if (!pixman_blt ((uint32_t *)src, (uint32_t *)dst, srcStride, dstStride, srcBpp, dstBpp,
- (pbox->x1 + dx + srcXoff),
- (pbox->y1 + dy + srcYoff),
- (pbox->x1 + dstXoff),
- (pbox->y1 + dstYoff),
- (pbox->x2 - pbox->x1),
- (pbox->y2 - pbox->y1)))
- goto fallback;
- else
- goto next;
- }
- fallback:
-#endif
- fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
- srcStride,
- (pbox->x1 + dx + srcXoff) * srcBpp,
-
- dst + (pbox->y1 + dstYoff) * dstStride,
- dstStride,
- (pbox->x1 + dstXoff) * dstBpp,
-
- (pbox->x2 - pbox->x1) * dstBpp,
- (pbox->y2 - pbox->y1),
-
- alu,
- pm,
- dstBpp,
-
- reverse,
- upsidedown);
-#ifndef FB_ACCESS_WRAPPER
- next:
-#endif
- pbox++;
- }
- fbFinishAccess (pDstDrawable);
- fbFinishAccess (pSrcDrawable);
-}
-
-void
-fbCopy1toN (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pbox,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown,
- Pixel bitplane,
- void *closure)
-{
- FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
- FbBits *src;
- FbStride srcStride;
- int srcBpp;
- int srcXoff, srcYoff;
- FbBits *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
-
- fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
- fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-
- while (nbox--)
- {
- if (dstBpp == 1)
- {
- fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
- srcStride,
- (pbox->x1 + dx + srcXoff) * srcBpp,
-
- dst + (pbox->y1 + dstYoff) * dstStride,
- dstStride,
- (pbox->x1 + dstXoff) * dstBpp,
-
- (pbox->x2 - pbox->x1) * dstBpp,
- (pbox->y2 - pbox->y1),
-
- FbOpaqueStipple1Rop(pGC->alu,
- pGC->fgPixel,pGC->bgPixel),
- pPriv->pm,
- dstBpp,
-
- reverse,
- upsidedown);
- }
- else
- {
- fbBltOne ((FbStip *) (src + (pbox->y1 + dy + srcYoff) * srcStride),
- srcStride*(FB_UNIT/FB_STIP_UNIT),
- (pbox->x1 + dx + srcXoff),
-
- dst + (pbox->y1 + dstYoff) * dstStride,
- dstStride,
- (pbox->x1 + dstXoff) * dstBpp,
- dstBpp,
-
- (pbox->x2 - pbox->x1) * dstBpp,
- (pbox->y2 - pbox->y1),
-
- pPriv->and, pPriv->xor,
- pPriv->bgand, pPriv->bgxor);
- }
- pbox++;
- }
-
- fbFinishAccess (pDstDrawable);
- fbFinishAccess (pSrcDrawable);
-}
-
-void
-fbCopyNto1 (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pbox,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown,
- Pixel bitplane,
- void *closure)
-{
- FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
-
- while (nbox--)
- {
- if (pDstDrawable->bitsPerPixel == 1)
- {
- FbBits *src;
- FbStride srcStride;
- int srcBpp;
- int srcXoff, srcYoff;
-
- FbStip *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
-
- fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
- fbGetStipDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
- fbBltPlane (src + (pbox->y1+ dy + srcYoff) * srcStride,
- srcStride,
- (pbox->x1 + dx + srcXoff) * srcBpp,
- srcBpp,
-
- dst + (pbox->y1 + dstYoff) * dstStride,
- dstStride,
- (pbox->x1 + dstXoff) * dstBpp,
-
- (pbox->x2 - pbox->x1) * srcBpp,
- (pbox->y2 - pbox->y1),
-
- (FbStip) pPriv->and, (FbStip) pPriv->xor,
- (FbStip) pPriv->bgand, (FbStip) pPriv->bgxor,
- bitplane);
- fbFinishAccess (pDstDrawable);
- fbFinishAccess (pSrcDrawable);
- }
- else
- {
- FbBits *src;
- FbStride srcStride;
- int srcBpp;
- int srcXoff, srcYoff;
-
- FbBits *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
-
- FbStip *tmp;
- FbStride tmpStride;
- int width, height;
-
- width = pbox->x2 - pbox->x1;
- height = pbox->y2 - pbox->y1;
-
- tmpStride = ((width + FB_STIP_MASK) >> FB_STIP_SHIFT);
- tmp = malloc(tmpStride * height * sizeof (FbStip));
- if (!tmp)
- return;
-
- fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
- fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-
- fbBltPlane (src + (pbox->y1+ dy + srcYoff) * srcStride,
- srcStride,
- (pbox->x1 + dx + srcXoff) * srcBpp,
- srcBpp,
-
- tmp,
- tmpStride,
- 0,
-
- width * srcBpp,
- height,
-
- fbAndStip(GXcopy,FB_ALLONES,FB_ALLONES),
- fbXorStip(GXcopy,FB_ALLONES,FB_ALLONES),
- fbAndStip(GXcopy,0,FB_ALLONES),
- fbXorStip(GXcopy,0,FB_ALLONES),
- bitplane);
- fbBltOne (tmp,
- tmpStride,
- 0,
-
- dst + (pbox->y1 + dstYoff) * dstStride,
- dstStride,
- (pbox->x1 + dstXoff) * dstBpp,
- dstBpp,
-
- width * dstBpp,
- height,
-
- pPriv->and, pPriv->xor,
- pPriv->bgand, pPriv->bgxor);
- free(tmp);
-
- fbFinishAccess (pDstDrawable);
- fbFinishAccess (pSrcDrawable);
- }
- pbox++;
- }
-}
-
-RegionPtr
-fbCopyArea (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- int xIn,
- int yIn,
- int widthSrc,
- int heightSrc,
- int xOut,
- int yOut)
-{
- miCopyProc copy;
-
-#ifdef FB_24_32BIT
- if (pSrcDrawable->bitsPerPixel != pDstDrawable->bitsPerPixel)
- copy = fb24_32CopyMtoN;
- else
-#endif
- copy = fbCopyNtoN;
- return miDoCopy (pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
- widthSrc, heightSrc, xOut, yOut, copy, 0, 0);
-}
-
-RegionPtr
-fbCopyPlane (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- int xIn,
- int yIn,
- int widthSrc,
- int heightSrc,
- int xOut,
- int yOut,
- unsigned long bitplane)
-{
- if (pSrcDrawable->bitsPerPixel > 1)
- return miDoCopy (pSrcDrawable, pDstDrawable, pGC,
- xIn, yIn, widthSrc, heightSrc,
- xOut, yOut, fbCopyNto1, (Pixel) bitplane, 0);
- else if (bitplane & 1)
- return miDoCopy (pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
- widthSrc, heightSrc, xOut, yOut, fbCopy1toN,
- (Pixel) bitplane, 0);
- else
- return miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
- xIn, yIn,
- widthSrc,
- heightSrc,
- xOut, yOut, bitplane);
-}
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "fb.h"
+
+/* Compatibility wrapper, to be removed at next ABI change. */
+void
+fbCopyRegion (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ RegionPtr pDstRegion,
+ int dx,
+ int dy,
+ fbCopyProc copyProc,
+ Pixel bitPlane,
+ void *closure)
+{
+ miCopyRegion(pSrcDrawable, pDstDrawable, pGC, pDstRegion, dx, dy, copyProc, bitPlane, closure);
+}
+
+/* Compatibility wrapper, to be removed at next ABI change. */
+RegionPtr
+fbDoCopy (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut,
+ fbCopyProc copyProc,
+ Pixel bitPlane,
+ void *closure)
+{
+ return miDoCopy(pSrcDrawable, pDstDrawable, pGC, xIn, yIn, widthSrc, heightSrc, xOut, yOut, copyProc, bitPlane, closure);
+}
+
+void
+fbCopyNtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ CARD8 alu = pGC ? pGC->alu : GXcopy;
+ FbBits pm = pGC ? fbGetGCPrivate(pGC)->pm : FB_ALLONES;
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ while (nbox--)
+ {
+#ifndef FB_ACCESS_WRAPPER /* pixman_blt() doesn't support accessors yet */
+ if (pm == FB_ALLONES && alu == GXcopy && !reverse &&
+ !upsidedown)
+ {
+ if (!pixman_blt ((uint32_t *)src, (uint32_t *)dst, srcStride, dstStride, srcBpp, dstBpp,
+ (pbox->x1 + dx + srcXoff),
+ (pbox->y1 + dy + srcYoff),
+ (pbox->x1 + dstXoff),
+ (pbox->y1 + dstYoff),
+ (pbox->x2 - pbox->x1),
+ (pbox->y2 - pbox->y1)))
+ goto fallback;
+ else
+ goto next;
+ }
+ fallback:
+#endif
+ fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+
+ (pbox->x2 - pbox->x1) * dstBpp,
+ (pbox->y2 - pbox->y1),
+
+ alu,
+ pm,
+ dstBpp,
+
+ reverse,
+ upsidedown);
+#ifndef FB_ACCESS_WRAPPER
+ next:
+#endif
+ pbox++;
+ }
+ fbFinishAccess (pDstDrawable);
+ fbFinishAccess (pSrcDrawable);
+}
+
+void
+fbCopy1toN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ while (nbox--)
+ {
+ if (dstBpp == 1)
+ {
+ fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+
+ (pbox->x2 - pbox->x1) * dstBpp,
+ (pbox->y2 - pbox->y1),
+
+ FbOpaqueStipple1Rop(pGC->alu,
+ pGC->fgPixel,pGC->bgPixel),
+ pPriv->pm,
+ dstBpp,
+
+ reverse,
+ upsidedown);
+ }
+ else
+ {
+ fbBltOne ((FbStip *) (src + (pbox->y1 + dy + srcYoff) * srcStride),
+ srcStride*(FB_UNIT/FB_STIP_UNIT),
+ (pbox->x1 + dx + srcXoff),
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+ dstBpp,
+
+ (pbox->x2 - pbox->x1) * dstBpp,
+ (pbox->y2 - pbox->y1),
+
+ pPriv->and, pPriv->xor,
+ pPriv->bgand, pPriv->bgxor);
+ }
+ pbox++;
+ }
+
+ fbFinishAccess (pDstDrawable);
+ fbFinishAccess (pSrcDrawable);
+}
+
+void
+fbCopyNto1 (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+
+ while (nbox--)
+ {
+ if (pDstDrawable->bitsPerPixel == 1)
+ {
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetStipDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ fbBltPlane (src + (pbox->y1+ dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+ srcBpp,
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+
+ (pbox->x2 - pbox->x1) * srcBpp,
+ (pbox->y2 - pbox->y1),
+
+ (FbStip) pPriv->and, (FbStip) pPriv->xor,
+ (FbStip) pPriv->bgand, (FbStip) pPriv->bgxor,
+ bitplane);
+ fbFinishAccess (pDstDrawable);
+ fbFinishAccess (pSrcDrawable);
+ }
+ else
+ {
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ FbStip *tmp;
+ FbStride tmpStride;
+ int width, height;
+
+ width = pbox->x2 - pbox->x1;
+ height = pbox->y2 - pbox->y1;
+
+ tmpStride = ((width + FB_STIP_MASK) >> FB_STIP_SHIFT);
+ tmp = malloc(tmpStride * height * sizeof (FbStip));
+ if (!tmp)
+ return;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ fbBltPlane (src + (pbox->y1+ dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+ srcBpp,
+
+ tmp,
+ tmpStride,
+ 0,
+
+ width * srcBpp,
+ height,
+
+ fbAndStip(GXcopy,FB_ALLONES,FB_ALLONES),
+ fbXorStip(GXcopy,FB_ALLONES,FB_ALLONES),
+ fbAndStip(GXcopy,0,FB_ALLONES),
+ fbXorStip(GXcopy,0,FB_ALLONES),
+ bitplane);
+ fbBltOne (tmp,
+ tmpStride,
+ 0,
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+ dstBpp,
+
+ width * dstBpp,
+ height,
+
+ pPriv->and, pPriv->xor,
+ pPriv->bgand, pPriv->bgxor);
+ free(tmp);
+
+ fbFinishAccess (pDstDrawable);
+ fbFinishAccess (pSrcDrawable);
+ }
+ pbox++;
+ }
+}
+
+RegionPtr
+fbCopyArea (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut)
+{
+ miCopyProc copy;
+
+ if (pSrcDrawable->bitsPerPixel != pDstDrawable->bitsPerPixel)
+ copy = fb24_32CopyMtoN;
+ else
+ copy = fbCopyNtoN;
+ return miDoCopy (pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
+ widthSrc, heightSrc, xOut, yOut, copy, 0, 0);
+}
+
+RegionPtr
+fbCopyPlane (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut,
+ unsigned long bitplane)
+{
+ if (pSrcDrawable->bitsPerPixel > 1)
+ return miDoCopy (pSrcDrawable, pDstDrawable, pGC,
+ xIn, yIn, widthSrc, heightSrc,
+ xOut, yOut, fbCopyNto1, (Pixel) bitplane, 0);
+ else if (bitplane & 1)
+ return miDoCopy (pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
+ widthSrc, heightSrc, xOut, yOut, fbCopy1toN,
+ (Pixel) bitplane, 0);
+ else
+ return miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ xIn, yIn,
+ widthSrc,
+ heightSrc,
+ xOut, yOut, bitplane);
+}
diff --git a/xorg-server/fb/fbgc.c b/xorg-server/fb/fbgc.c
index 75d240a33..cc504c1b8 100644
--- a/xorg-server/fb/fbgc.c
+++ b/xorg-server/fb/fbgc.c
@@ -1,309 +1,307 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include "fb.h"
-
-const GCFuncs fbGCFuncs = {
- fbValidateGC,
- miChangeGC,
- miCopyGC,
- miDestroyGC,
- miChangeClip,
- miDestroyClip,
- miCopyClip,
-};
-
-const GCOps fbGCOps = {
- fbFillSpans,
- fbSetSpans,
- fbPutImage,
- fbCopyArea,
- fbCopyPlane,
- fbPolyPoint,
- fbPolyLine,
- fbPolySegment,
- fbPolyRectangle,
- fbPolyArc,
- miFillPolygon,
- fbPolyFillRect,
- fbPolyFillArc,
- miPolyText8,
- miPolyText16,
- miImageText8,
- miImageText16,
- fbImageGlyphBlt,
- fbPolyGlyphBlt,
- fbPushPixels
-};
-
-Bool
-fbCreateGC(GCPtr pGC)
-{
- pGC->ops = (GCOps *) &fbGCOps;
- pGC->funcs = (GCFuncs *) &fbGCFuncs;
-
- /* fb wants to translate before scan conversion */
- pGC->miTranslate = 1;
- pGC->fExpose = 1;
-
- fbGetGCPrivate(pGC)->bpp = BitsPerPixel (pGC->depth);
- return TRUE;
-}
-
-/*
- * Pad pixmap to FB_UNIT bits wide
- */
-void
-fbPadPixmap (PixmapPtr pPixmap)
-{
- int width;
- FbBits *bits;
- FbBits b;
- FbBits mask;
- int height;
- int w;
- int stride;
- int bpp;
- int xOff, yOff;
-
- fbGetDrawable (&pPixmap->drawable, bits, stride, bpp, xOff, yOff);
-
- width = pPixmap->drawable.width * pPixmap->drawable.bitsPerPixel;
- height = pPixmap->drawable.height;
- mask = FbBitsMask (0, width);
- while (height--)
- {
- b = READ(bits) & mask;
- w = width;
- while (w < FB_UNIT)
- {
- b = b | FbScrRight(b, w);
- w <<= 1;
- }
- WRITE(bits, b);
- bits += stride;
- }
-
- fbFinishAccess (&pPixmap->drawable);
-}
-
-/*
- * Verify that 'bits' repeats every 'len' bits
- */
-static Bool
-fbBitsRepeat (FbBits bits, int len, int width)
-{
- FbBits mask = FbBitsMask(0, len);
- FbBits orig = bits & mask;
- int i;
-
- if (width > FB_UNIT)
- width = FB_UNIT;
- for (i = 0; i < width / len; i++)
- {
- if ((bits & mask) != orig)
- return FALSE;
- bits = FbScrLeft(bits,len);
- }
- return TRUE;
-}
-
-/*
- * Check whether an entire bitmap line is a repetition of
- * the first 'len' bits
- */
-static Bool
-fbLineRepeat (FbBits *bits, int len, int width)
-{
- FbBits first = bits[0];
-
- if (!fbBitsRepeat (first, len, width))
- return FALSE;
- width = (width + FB_UNIT-1) >> FB_SHIFT;
- bits++;
- while (--width)
- if (READ(bits) != first)
- return FALSE;
- return TRUE;
-}
-
-/*
- * The even stipple code wants the first FB_UNIT/bpp bits on
- * each scanline to represent the entire stipple
- */
-static Bool
-fbCanEvenStipple (PixmapPtr pStipple, int bpp)
-{
- int len = FB_UNIT / bpp;
- FbBits *bits;
- int stride;
- int stip_bpp;
- int stipXoff, stipYoff;
- int h;
-
- /* can't even stipple 24bpp drawables */
- if ((bpp & (bpp-1)) != 0)
- return FALSE;
- /* make sure the stipple width is a multiple of the even stipple width */
- if (pStipple->drawable.width % len != 0)
- return FALSE;
- fbGetDrawable (&pStipple->drawable, bits, stride, stip_bpp, stipXoff, stipYoff);
- h = pStipple->drawable.height;
- /* check to see that the stipple repeats horizontally */
- while (h--)
- {
- if (!fbLineRepeat (bits, len, pStipple->drawable.width)) {
- fbFinishAccess (&pStipple->drawable);
- return FALSE;
- }
- bits += stride;
- }
- fbFinishAccess (&pStipple->drawable);
- return TRUE;
-}
-
-void
-fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
-{
- FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
- FbBits mask;
-
- /*
- * if the client clip is different or moved OR the subwindowMode has
- * changed OR the window's clip has changed since the last validation
- * we need to recompute the composite clip
- */
-
- if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
- (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
- )
- {
- miComputeCompositeClip (pGC, pDrawable);
- }
-
-#ifdef FB_24_32BIT
- if (pPriv->bpp != pDrawable->bitsPerPixel)
- {
- changes |= GCStipple|GCForeground|GCBackground|GCPlaneMask;
- pPriv->bpp = pDrawable->bitsPerPixel;
- }
- if ((changes & GCTile) && fbGetRotatedPixmap(pGC))
- {
- (*pGC->pScreen->DestroyPixmap) (fbGetRotatedPixmap(pGC));
- fbGetRotatedPixmap(pGC) = 0;
- }
-
- if (pGC->fillStyle == FillTiled)
- {
- PixmapPtr pOldTile, pNewTile;
-
- pOldTile = pGC->tile.pixmap;
- if (pOldTile->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
- {
- pNewTile = fbGetRotatedPixmap(pGC);
- if (!pNewTile || pNewTile ->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
- {
- if (pNewTile)
- (*pGC->pScreen->DestroyPixmap) (pNewTile);
- pNewTile = fb24_32ReformatTile (pOldTile, pDrawable->bitsPerPixel);
- }
- if (pNewTile)
- {
- fbGetRotatedPixmap(pGC) = pOldTile;
- pGC->tile.pixmap = pNewTile;
- changes |= GCTile;
- }
- }
- }
-#endif
- if (changes & GCTile)
- {
- if (!pGC->tileIsPixel &&
- FbEvenTile (pGC->tile.pixmap->drawable.width *
- pDrawable->bitsPerPixel))
- fbPadPixmap (pGC->tile.pixmap);
- }
- if (changes & GCStipple)
- {
- pPriv->evenStipple = FALSE;
-
- if (pGC->stipple) {
-
- /* can we do an even stipple ?? */
- if (FbEvenStip (pGC->stipple->drawable.width,
- pDrawable->bitsPerPixel) &&
- (fbCanEvenStipple (pGC->stipple, pDrawable->bitsPerPixel)))
- pPriv->evenStipple = TRUE;
-
- if (pGC->stipple->drawable.width * pDrawable->bitsPerPixel < FB_UNIT)
- fbPadPixmap (pGC->stipple);
- }
- }
- /*
- * Recompute reduced rop values
- */
- if (changes & (GCForeground|GCBackground|GCPlaneMask|GCFunction))
- {
- int s;
- FbBits depthMask;
-
- mask = FbFullMask(pDrawable->bitsPerPixel);
- depthMask = FbFullMask(pDrawable->depth);
-
- pPriv->fg = pGC->fgPixel & mask;
- pPriv->bg = pGC->bgPixel & mask;
-
- if ((pGC->planemask & depthMask) == depthMask)
- pPriv->pm = mask;
- else
- pPriv->pm = pGC->planemask & mask;
-
- s = pDrawable->bitsPerPixel;
- while (s < FB_UNIT)
- {
- pPriv->fg |= pPriv->fg << s;
- pPriv->bg |= pPriv->bg << s;
- pPriv->pm |= pPriv->pm << s;
- s <<= 1;
- }
- pPriv->and = fbAnd(pGC->alu, pPriv->fg, pPriv->pm);
- pPriv->xor = fbXor(pGC->alu, pPriv->fg, pPriv->pm);
- pPriv->bgand = fbAnd(pGC->alu, pPriv->bg, pPriv->pm);
- pPriv->bgxor = fbXor(pGC->alu, pPriv->bg, pPriv->pm);
- }
- if (changes & GCDashList)
- {
- unsigned short n = pGC->numInDashList;
- unsigned char *dash = pGC->dash;
- unsigned int dashLength = 0;
-
- while (n--)
- dashLength += (unsigned int ) *dash++;
- pPriv->dashLength = dashLength;
- }
-}
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "fb.h"
+
+const GCFuncs fbGCFuncs = {
+ fbValidateGC,
+ miChangeGC,
+ miCopyGC,
+ miDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip,
+};
+
+const GCOps fbGCOps = {
+ fbFillSpans,
+ fbSetSpans,
+ fbPutImage,
+ fbCopyArea,
+ fbCopyPlane,
+ fbPolyPoint,
+ fbPolyLine,
+ fbPolySegment,
+ fbPolyRectangle,
+ fbPolyArc,
+ miFillPolygon,
+ fbPolyFillRect,
+ fbPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ fbImageGlyphBlt,
+ fbPolyGlyphBlt,
+ fbPushPixels
+};
+
+Bool
+fbCreateGC(GCPtr pGC)
+{
+ pGC->ops = (GCOps *) &fbGCOps;
+ pGC->funcs = (GCFuncs *) &fbGCFuncs;
+
+ /* fb wants to translate before scan conversion */
+ pGC->miTranslate = 1;
+ pGC->fExpose = 1;
+
+ fbGetGCPrivate(pGC)->bpp = BitsPerPixel (pGC->depth);
+ return TRUE;
+}
+
+/*
+ * Pad pixmap to FB_UNIT bits wide
+ */
+void
+fbPadPixmap (PixmapPtr pPixmap)
+{
+ int width;
+ FbBits *bits;
+ FbBits b;
+ FbBits mask;
+ int height;
+ int w;
+ int stride;
+ int bpp;
+ int xOff, yOff;
+
+ fbGetDrawable (&pPixmap->drawable, bits, stride, bpp, xOff, yOff);
+
+ width = pPixmap->drawable.width * pPixmap->drawable.bitsPerPixel;
+ height = pPixmap->drawable.height;
+ mask = FbBitsMask (0, width);
+ while (height--)
+ {
+ b = READ(bits) & mask;
+ w = width;
+ while (w < FB_UNIT)
+ {
+ b = b | FbScrRight(b, w);
+ w <<= 1;
+ }
+ WRITE(bits, b);
+ bits += stride;
+ }
+
+ fbFinishAccess (&pPixmap->drawable);
+}
+
+/*
+ * Verify that 'bits' repeats every 'len' bits
+ */
+static Bool
+fbBitsRepeat (FbBits bits, int len, int width)
+{
+ FbBits mask = FbBitsMask(0, len);
+ FbBits orig = bits & mask;
+ int i;
+
+ if (width > FB_UNIT)
+ width = FB_UNIT;
+ for (i = 0; i < width / len; i++)
+ {
+ if ((bits & mask) != orig)
+ return FALSE;
+ bits = FbScrLeft(bits,len);
+ }
+ return TRUE;
+}
+
+/*
+ * Check whether an entire bitmap line is a repetition of
+ * the first 'len' bits
+ */
+static Bool
+fbLineRepeat (FbBits *bits, int len, int width)
+{
+ FbBits first = bits[0];
+
+ if (!fbBitsRepeat (first, len, width))
+ return FALSE;
+ width = (width + FB_UNIT-1) >> FB_SHIFT;
+ bits++;
+ while (--width)
+ if (READ(bits) != first)
+ return FALSE;
+ return TRUE;
+}
+
+/*
+ * The even stipple code wants the first FB_UNIT/bpp bits on
+ * each scanline to represent the entire stipple
+ */
+static Bool
+fbCanEvenStipple (PixmapPtr pStipple, int bpp)
+{
+ int len = FB_UNIT / bpp;
+ FbBits *bits;
+ int stride;
+ int stip_bpp;
+ int stipXoff, stipYoff;
+ int h;
+
+ /* can't even stipple 24bpp drawables */
+ if ((bpp & (bpp-1)) != 0)
+ return FALSE;
+ /* make sure the stipple width is a multiple of the even stipple width */
+ if (pStipple->drawable.width % len != 0)
+ return FALSE;
+ fbGetDrawable (&pStipple->drawable, bits, stride, stip_bpp, stipXoff, stipYoff);
+ h = pStipple->drawable.height;
+ /* check to see that the stipple repeats horizontally */
+ while (h--)
+ {
+ if (!fbLineRepeat (bits, len, pStipple->drawable.width)) {
+ fbFinishAccess (&pStipple->drawable);
+ return FALSE;
+ }
+ bits += stride;
+ }
+ fbFinishAccess (&pStipple->drawable);
+ return TRUE;
+}
+
+void
+fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ FbBits mask;
+
+ /*
+ * if the client clip is different or moved OR the subwindowMode has
+ * changed OR the window's clip has changed since the last validation
+ * we need to recompute the composite clip
+ */
+
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
+ )
+ {
+ miComputeCompositeClip (pGC, pDrawable);
+ }
+
+ if (pPriv->bpp != pDrawable->bitsPerPixel)
+ {
+ changes |= GCStipple|GCForeground|GCBackground|GCPlaneMask;
+ pPriv->bpp = pDrawable->bitsPerPixel;
+ }
+ if ((changes & GCTile) && fbGetRotatedPixmap(pGC))
+ {
+ (*pGC->pScreen->DestroyPixmap) (fbGetRotatedPixmap(pGC));
+ fbGetRotatedPixmap(pGC) = 0;
+ }
+
+ if (pGC->fillStyle == FillTiled)
+ {
+ PixmapPtr pOldTile, pNewTile;
+
+ pOldTile = pGC->tile.pixmap;
+ if (pOldTile->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
+ {
+ pNewTile = fbGetRotatedPixmap(pGC);
+ if (!pNewTile || pNewTile ->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
+ {
+ if (pNewTile)
+ (*pGC->pScreen->DestroyPixmap) (pNewTile);
+ pNewTile = fb24_32ReformatTile (pOldTile, pDrawable->bitsPerPixel);
+ }
+ if (pNewTile)
+ {
+ fbGetRotatedPixmap(pGC) = pOldTile;
+ pGC->tile.pixmap = pNewTile;
+ changes |= GCTile;
+ }
+ }
+ }
+ if (changes & GCTile)
+ {
+ if (!pGC->tileIsPixel &&
+ FbEvenTile (pGC->tile.pixmap->drawable.width *
+ pDrawable->bitsPerPixel))
+ fbPadPixmap (pGC->tile.pixmap);
+ }
+ if (changes & GCStipple)
+ {
+ pPriv->evenStipple = FALSE;
+
+ if (pGC->stipple) {
+
+ /* can we do an even stipple ?? */
+ if (FbEvenStip (pGC->stipple->drawable.width,
+ pDrawable->bitsPerPixel) &&
+ (fbCanEvenStipple (pGC->stipple, pDrawable->bitsPerPixel)))
+ pPriv->evenStipple = TRUE;
+
+ if (pGC->stipple->drawable.width * pDrawable->bitsPerPixel < FB_UNIT)
+ fbPadPixmap (pGC->stipple);
+ }
+ }
+ /*
+ * Recompute reduced rop values
+ */
+ if (changes & (GCForeground|GCBackground|GCPlaneMask|GCFunction))
+ {
+ int s;
+ FbBits depthMask;
+
+ mask = FbFullMask(pDrawable->bitsPerPixel);
+ depthMask = FbFullMask(pDrawable->depth);
+
+ pPriv->fg = pGC->fgPixel & mask;
+ pPriv->bg = pGC->bgPixel & mask;
+
+ if ((pGC->planemask & depthMask) == depthMask)
+ pPriv->pm = mask;
+ else
+ pPriv->pm = pGC->planemask & mask;
+
+ s = pDrawable->bitsPerPixel;
+ while (s < FB_UNIT)
+ {
+ pPriv->fg |= pPriv->fg << s;
+ pPriv->bg |= pPriv->bg << s;
+ pPriv->pm |= pPriv->pm << s;
+ s <<= 1;
+ }
+ pPriv->and = fbAnd(pGC->alu, pPriv->fg, pPriv->pm);
+ pPriv->xor = fbXor(pGC->alu, pPriv->fg, pPriv->pm);
+ pPriv->bgand = fbAnd(pGC->alu, pPriv->bg, pPriv->pm);
+ pPriv->bgxor = fbXor(pGC->alu, pPriv->bg, pPriv->pm);
+ }
+ if (changes & GCDashList)
+ {
+ unsigned short n = pGC->numInDashList;
+ unsigned char *dash = pGC->dash;
+ unsigned int dashLength = 0;
+
+ while (n--)
+ dashLength += (unsigned int ) *dash++;
+ pPriv->dashLength = dashLength;
+ }
+}
diff --git a/xorg-server/fb/fbgetsp.c b/xorg-server/fb/fbgetsp.c
index 6402c6c38..bf9f51eb4 100644
--- a/xorg-server/fb/fbgetsp.c
+++ b/xorg-server/fb/fbgetsp.c
@@ -47,13 +47,11 @@ fbGetSpans(DrawablePtr pDrawable,
if (!fbDrawableEnabled(pDrawable))
return;
-#ifdef FB_24_32BIT
if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
{
fb24_32GetSpans (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
return;
}
-#endif
fbGetDrawable (pDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
diff --git a/xorg-server/fb/fbglyph.c b/xorg-server/fb/fbglyph.c
index 51a5ea0a4..643cf909f 100644
--- a/xorg-server/fb/fbglyph.c
+++ b/xorg-server/fb/fbglyph.c
@@ -1,479 +1,461 @@
-/*
- *
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-#include <X11/fonts/fontstruct.h>
-#include "dixfontstr.h"
-
-Bool
-fbGlyphIn (RegionPtr pRegion,
- int x,
- int y,
- int width,
- int height)
-{
- BoxRec box;
- BoxPtr pExtents = RegionExtents(pRegion);
-
- /*
- * Check extents by hand to avoid 16 bit overflows
- */
- if (x < (int) pExtents->x1)
- return FALSE;
- if ((int) pExtents->x2 < x + width)
- return FALSE;
- if (y < (int) pExtents->y1)
- return FALSE;
- if ((int) pExtents->y2 < y + height)
- return FALSE;
- box.x1 = x;
- box.x2 = x + width;
- box.y1 = y;
- box.y2 = y + height;
- return RegionContainsRect(pRegion, &box) == rgnIN;
-}
-
-#ifdef FB_24BIT
-#ifndef FBNOPIXADDR
-
-#define WRITE1(d,n,fg) WRITE((d) + (n), (CARD8) fg)
-#define WRITE2(d,n,fg) WRITE((CARD16 *) &(d[n]), (CARD16) fg)
-#define WRITE4(d,n,fg) WRITE((CARD32 *) &(d[n]), (CARD32) fg)
-#if FB_UNIT == 6 && IMAGE_BYTE_ORDER == LSBFirst
-#define WRITE8(d) WRITE((FbBits *) &(d[0]), fg)
-#else
-#define WRITE8(d) WRITE4(d,0,_ABCA), WRITE4(d,4,_BCAB)
-#endif
-
-/*
- * This is a bit tricky, but it's brief. Write 12 bytes worth
- * of dest, which is four pixels, at a time. This gives constant
- * code for each pattern as they're always aligned the same
- *
- * a b c d a b c d a b c d bytes
- * A B C A B C A B C A B C pixels
- *
- * f0 f1 f2
- * A B C A B C A B C A B C pixels LSB
- * C A B C A B C A B C A B pixels MSB
- *
- * LSB MSB
- * A f0 f1
- * B f1 f2
- * C f2 f0
- * A B f0 f2
- * B C f1 f0
- * C A f2 f1
- * A B C A f0 f1
- * B C A B f1 f2
- * C A B C f2 f0
- */
-
-#undef _A
-#undef _B
-#undef _C
-#undef _AB
-#undef _BC
-#undef _CA
-#undef _ABCA
-#undef _BCAB
-#undef _CABC
-
-#if IMAGE_BYTE_ORDER == MSBFirst
-#define _A f1
-#define _B f2
-#define _C f0
-#define _AB f2
-#define _BC f0
-#define _CA f1
-#define _ABCA f1
-#define _BCAB f2
-#define _CABC f0
-#define CASE(a,b,c,d) ((a << 3) | (b << 2) | (c << 1) | d)
-#else
-#define _A f0
-#define _B f1
-#define _C f2
-#define _AB f0
-#define _BC f1
-#define _CA f2
-#define _ABCA f0
-#define _BCAB f1
-#define _CABC f2
-#define CASE(a,b,c,d) (a | (b << 1) | (c << 2) | (d << 3))
-#endif
-
-void
-fbGlyph24 (FbBits *dstBits,
- FbStride dstStride,
- int dstBpp,
- FbStip *stipple,
- FbBits fg,
- int x,
- int height)
-{
- int lshift;
- FbStip bits;
- CARD8 *dstLine;
- CARD8 *dst;
- FbStip f0, f1, f2;
- int n;
- int shift;
-
- f0 = fg;
- f1 = FbRot24(f0,16);
- f2 = FbRot24(f0,8);
-
- dstLine = (CARD8 *) dstBits;
- dstLine += (x & ~3) * 3;
- dstStride *= (sizeof (FbBits) / sizeof (CARD8));
- shift = x & 3;
- lshift = 4 - shift;
- while (height--)
- {
- bits = READ(stipple++);
- n = lshift;
- dst = dstLine;
- while (bits)
- {
- switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) {
- case CASE(0,0,0,0):
- break;
- case CASE(1,0,0,0):
- WRITE2(dst,0,_AB);
- WRITE1(dst,2,_C);
- break;
- case CASE(0,1,0,0):
- WRITE1(dst,3,_A);
- WRITE2(dst,4,_BC);
- break;
- case CASE(1,1,0,0):
- WRITE4(dst,0,_ABCA);
- WRITE2(dst,4,_BC);
- break;
- case CASE(0,0,1,0):
- WRITE2(dst,6,_AB);
- WRITE1(dst,8,_C);
- break;
- case CASE(1,0,1,0):
- WRITE2(dst,0,_AB);
- WRITE1(dst,2,_C);
-
- WRITE2(dst,6,_AB);
- WRITE1(dst,8,_C);
- break;
- case CASE(0,1,1,0):
- WRITE1(dst,3,_A);
- WRITE4(dst,4,_BCAB);
- WRITE1(dst,8,_C);
- break;
- case CASE(1,1,1,0):
- WRITE8(dst);
- WRITE1(dst,8,_C);
- break;
- case CASE(0,0,0,1):
- WRITE1(dst,9,_A);
- WRITE2(dst,10,_BC);
- break;
- case CASE(1,0,0,1):
- WRITE2(dst,0,_AB);
- WRITE1(dst,2,_C);
-
- WRITE1(dst,9,_A);
- WRITE2(dst,10,_BC);
- break;
- case CASE(0,1,0,1):
- WRITE1(dst,3,_A);
- WRITE2(dst,4,_BC);
-
- WRITE1(dst,9,_A);
- WRITE2(dst,10,_BC);
- break;
- case CASE(1,1,0,1):
- WRITE4(dst,0,_ABCA);
- WRITE2(dst,4,_BC);
-
- WRITE1(dst,9,_A);
- WRITE2(dst,10,_BC);
- break;
- case CASE(0,0,1,1):
- WRITE2(dst,6,_AB);
- WRITE4(dst,8,_CABC);
- break;
- case CASE(1,0,1,1):
- WRITE2(dst,0,_AB);
- WRITE1(dst,2,_C);
-
- WRITE2(dst,6,_AB);
- WRITE4(dst,8,_CABC);
- break;
- case CASE(0,1,1,1):
- WRITE1(dst,3,_A);
- WRITE4(dst,4,_BCAB);
- WRITE4(dst,8,_CABC);
- break;
- case CASE(1,1,1,1):
- WRITE8(dst);
- WRITE4(dst,8,_CABC);
- break;
- }
- bits = FbStipLeft (bits, n);
- n = 4;
- dst += 12;
- }
- dstLine += dstStride;
- }
-}
-#endif
-#endif
-
-void
-fbPolyGlyphBlt (DrawablePtr pDrawable,
- GCPtr pGC,
- int x,
- int y,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase)
-{
- FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
- CharInfoPtr pci;
- unsigned char *pglyph; /* pointer bits in glyph */
- int gx, gy;
- int gWidth, gHeight; /* width and height of glyph */
- FbStride gStride; /* stride of glyph */
-#ifndef FBNOPIXADDR
- void (*glyph) (FbBits *,
- FbStride,
- int,
- FbStip *,
- FbBits,
- int,
- int);
- FbBits *dst = 0;
- FbStride dstStride = 0;
- int dstBpp = 0;
- int dstXoff = 0, dstYoff = 0;
-
- glyph = 0;
- if (pGC->fillStyle == FillSolid && pPriv->and == 0)
- {
- dstBpp = pDrawable->bitsPerPixel;
- switch (dstBpp) {
- case 8: glyph = fbGlyph8; break;
- case 16: glyph = fbGlyph16; break;
-#ifdef FB_24BIT
- case 24: glyph = fbGlyph24; break;
-#endif
- case 32: glyph = fbGlyph32; break;
- }
- }
-#endif
- x += pDrawable->x;
- y += pDrawable->y;
-
- while (nglyph--)
- {
- pci = *ppci++;
- pglyph = FONTGLYPHBITS(pglyphBase, pci);
- gWidth = GLYPHWIDTHPIXELS(pci);
- gHeight = GLYPHHEIGHTPIXELS(pci);
- if (gWidth && gHeight)
- {
- gx = x + pci->metrics.leftSideBearing;
- gy = y - pci->metrics.ascent;
-#ifndef FBNOPIXADDR
- if (glyph && gWidth <= sizeof (FbStip) * 8 &&
- fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
- {
- fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
- (*glyph) (dst + (gy + dstYoff) * dstStride,
- dstStride,
- dstBpp,
- (FbStip *) pglyph,
- pPriv->xor,
- gx + dstXoff,
- gHeight);
- fbFinishAccess (pDrawable);
- }
- else
-#endif
- {
- gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
- fbPushImage (pDrawable,
- pGC,
-
- (FbStip *) pglyph,
- gStride,
- 0,
-
- gx,
- gy,
- gWidth, gHeight);
- }
- }
- x += pci->metrics.characterWidth;
- }
-}
-
-
-void
-fbImageGlyphBlt (DrawablePtr pDrawable,
- GCPtr pGC,
- int x,
- int y,
- unsigned int nglyph,
- CharInfoPtr *ppciInit,
- pointer pglyphBase)
-{
- FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
- CharInfoPtr *ppci;
- CharInfoPtr pci;
- unsigned char *pglyph; /* pointer bits in glyph */
- int gWidth, gHeight; /* width and height of glyph */
- FbStride gStride; /* stride of glyph */
- Bool opaque;
- int n;
- int gx, gy;
-#ifndef FBNOPIXADDR
- void (*glyph) (FbBits *,
- FbStride,
- int,
- FbStip *,
- FbBits,
- int,
- int);
- FbBits *dst = 0;
- FbStride dstStride = 0;
- int dstBpp = 0;
- int dstXoff = 0, dstYoff = 0;
-
- glyph = 0;
- if (pPriv->and == 0)
- {
- dstBpp = pDrawable->bitsPerPixel;
- switch (dstBpp) {
- case 8: glyph = fbGlyph8; break;
- case 16: glyph = fbGlyph16; break;
-#ifdef FB_24BIT
- case 24: glyph = fbGlyph24; break;
-#endif
- case 32: glyph = fbGlyph32; break;
- }
- }
-#endif
-
- x += pDrawable->x;
- y += pDrawable->y;
-
- if (TERMINALFONT (pGC->font)
-#ifndef FBNOPIXADDR
- && !glyph
-#endif
- )
- {
- opaque = TRUE;
- }
- else
- {
- int xBack, widthBack;
- int yBack, heightBack;
-
- ppci = ppciInit;
- n = nglyph;
- widthBack = 0;
- while (n--)
- widthBack += (*ppci++)->metrics.characterWidth;
-
- xBack = x;
- if (widthBack < 0)
- {
- xBack += widthBack;
- widthBack = -widthBack;
- }
- yBack = y - FONTASCENT(pGC->font);
- heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
- fbSolidBoxClipped (pDrawable,
- fbGetCompositeClip(pGC),
- xBack,
- yBack,
- xBack + widthBack,
- yBack + heightBack,
- fbAnd(GXcopy,pPriv->bg,pPriv->pm),
- fbXor(GXcopy,pPriv->bg,pPriv->pm));
- opaque = FALSE;
- }
-
- 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 = y - pci->metrics.ascent;
-#ifndef FBNOPIXADDR
- if (glyph && gWidth <= sizeof (FbStip) * 8 &&
- fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
- {
- fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
- (*glyph) (dst + (gy + dstYoff) * dstStride,
- dstStride,
- dstBpp,
- (FbStip *) pglyph,
- pPriv->fg,
- gx + dstXoff,
- gHeight);
- fbFinishAccess (pDrawable);
- }
- else
-#endif
- {
- gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
- fbPutXYImage (pDrawable,
- fbGetCompositeClip(pGC),
- pPriv->fg,
- pPriv->bg,
- pPriv->pm,
- GXcopy,
- opaque,
-
- gx,
- gy,
- gWidth, gHeight,
-
- (FbStip *) pglyph,
- gStride,
- 0);
- }
- }
- x += pci->metrics.characterWidth;
- }
-}
+/*
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+
+Bool
+fbGlyphIn (RegionPtr pRegion,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ BoxRec box;
+ BoxPtr pExtents = RegionExtents(pRegion);
+
+ /*
+ * Check extents by hand to avoid 16 bit overflows
+ */
+ if (x < (int) pExtents->x1)
+ return FALSE;
+ if ((int) pExtents->x2 < x + width)
+ return FALSE;
+ if (y < (int) pExtents->y1)
+ return FALSE;
+ if ((int) pExtents->y2 < y + height)
+ return FALSE;
+ box.x1 = x;
+ box.x2 = x + width;
+ box.y1 = y;
+ box.y2 = y + height;
+ return RegionContainsRect(pRegion, &box) == rgnIN;
+}
+
+
+#define WRITE1(d,n,fg) WRITE((d) + (n), (CARD8) fg)
+#define WRITE2(d,n,fg) WRITE((CARD16 *) &(d[n]), (CARD16) fg)
+#define WRITE4(d,n,fg) WRITE((CARD32 *) &(d[n]), (CARD32) fg)
+#if FB_UNIT == 6 && IMAGE_BYTE_ORDER == LSBFirst
+#define WRITE8(d) WRITE((FbBits *) &(d[0]), fg)
+#else
+#define WRITE8(d) WRITE4(d,0,_ABCA), WRITE4(d,4,_BCAB)
+#endif
+
+/*
+ * This is a bit tricky, but it's brief. Write 12 bytes worth
+ * of dest, which is four pixels, at a time. This gives constant
+ * code for each pattern as they're always aligned the same
+ *
+ * a b c d a b c d a b c d bytes
+ * A B C A B C A B C A B C pixels
+ *
+ * f0 f1 f2
+ * A B C A B C A B C A B C pixels LSB
+ * C A B C A B C A B C A B pixels MSB
+ *
+ * LSB MSB
+ * A f0 f1
+ * B f1 f2
+ * C f2 f0
+ * A B f0 f2
+ * B C f1 f0
+ * C A f2 f1
+ * A B C A f0 f1
+ * B C A B f1 f2
+ * C A B C f2 f0
+ */
+
+#undef _A
+#undef _B
+#undef _C
+#undef _AB
+#undef _BC
+#undef _CA
+#undef _ABCA
+#undef _BCAB
+#undef _CABC
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define _A f1
+#define _B f2
+#define _C f0
+#define _AB f2
+#define _BC f0
+#define _CA f1
+#define _ABCA f1
+#define _BCAB f2
+#define _CABC f0
+#define CASE(a,b,c,d) ((a << 3) | (b << 2) | (c << 1) | d)
+#else
+#define _A f0
+#define _B f1
+#define _C f2
+#define _AB f0
+#define _BC f1
+#define _CA f2
+#define _ABCA f0
+#define _BCAB f1
+#define _CABC f2
+#define CASE(a,b,c,d) (a | (b << 1) | (c << 2) | (d << 3))
+#endif
+
+void
+fbGlyph24 (FbBits *dstBits,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int x,
+ int height)
+{
+ int lshift;
+ FbStip bits;
+ CARD8 *dstLine;
+ CARD8 *dst;
+ FbStip f0, f1, f2;
+ int n;
+ int shift;
+
+ f0 = fg;
+ f1 = FbRot24(f0,16);
+ f2 = FbRot24(f0,8);
+
+ dstLine = (CARD8 *) dstBits;
+ dstLine += (x & ~3) * 3;
+ dstStride *= (sizeof (FbBits) / sizeof (CARD8));
+ shift = x & 3;
+ lshift = 4 - shift;
+ while (height--)
+ {
+ bits = READ(stipple++);
+ n = lshift;
+ dst = dstLine;
+ while (bits)
+ {
+ switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) {
+ case CASE(0,0,0,0):
+ break;
+ case CASE(1,0,0,0):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+ break;
+ case CASE(0,1,0,0):
+ WRITE1(dst,3,_A);
+ WRITE2(dst,4,_BC);
+ break;
+ case CASE(1,1,0,0):
+ WRITE4(dst,0,_ABCA);
+ WRITE2(dst,4,_BC);
+ break;
+ case CASE(0,0,1,0):
+ WRITE2(dst,6,_AB);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(1,0,1,0):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+
+ WRITE2(dst,6,_AB);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(0,1,1,0):
+ WRITE1(dst,3,_A);
+ WRITE4(dst,4,_BCAB);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(1,1,1,0):
+ WRITE8(dst);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(0,0,0,1):
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(1,0,0,1):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(0,1,0,1):
+ WRITE1(dst,3,_A);
+ WRITE2(dst,4,_BC);
+
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(1,1,0,1):
+ WRITE4(dst,0,_ABCA);
+ WRITE2(dst,4,_BC);
+
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(0,0,1,1):
+ WRITE2(dst,6,_AB);
+ WRITE4(dst,8,_CABC);
+ break;
+ case CASE(1,0,1,1):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+
+ WRITE2(dst,6,_AB);
+ WRITE4(dst,8,_CABC);
+ break;
+ case CASE(0,1,1,1):
+ WRITE1(dst,3,_A);
+ WRITE4(dst,4,_BCAB);
+ WRITE4(dst,8,_CABC);
+ break;
+ case CASE(1,1,1,1):
+ WRITE8(dst);
+ WRITE4(dst,8,_CABC);
+ break;
+ }
+ bits = FbStipLeft (bits, n);
+ n = 4;
+ dst += 12;
+ }
+ dstLine += dstStride;
+ }
+}
+
+void
+fbPolyGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ CharInfoPtr pci;
+ unsigned char *pglyph; /* pointer bits in glyph */
+ int gx, gy;
+ int gWidth, gHeight; /* width and height of glyph */
+ FbStride gStride; /* stride of glyph */
+ void (*glyph) (FbBits *,
+ FbStride,
+ int,
+ FbStip *,
+ FbBits,
+ int,
+ int);
+ FbBits *dst = 0;
+ FbStride dstStride = 0;
+ int dstBpp = 0;
+ int dstXoff = 0, dstYoff = 0;
+
+ glyph = 0;
+ if (pGC->fillStyle == FillSolid && pPriv->and == 0)
+ {
+ dstBpp = pDrawable->bitsPerPixel;
+ switch (dstBpp) {
+ case 8: glyph = fbGlyph8; break;
+ case 16: glyph = fbGlyph16; break;
+ case 24: glyph = fbGlyph24; break;
+ case 32: glyph = fbGlyph32; break;
+ }
+ }
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ gWidth = GLYPHWIDTHPIXELS(pci);
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gWidth && gHeight)
+ {
+ gx = x + pci->metrics.leftSideBearing;
+ gy = y - pci->metrics.ascent;
+ if (glyph && gWidth <= sizeof (FbStip) * 8 &&
+ fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
+ {
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ (*glyph) (dst + (gy + dstYoff) * dstStride,
+ dstStride,
+ dstBpp,
+ (FbStip *) pglyph,
+ pPriv->xor,
+ gx + dstXoff,
+ gHeight);
+ fbFinishAccess (pDrawable);
+ }
+ else
+ {
+ gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
+ fbPushImage (pDrawable,
+ pGC,
+
+ (FbStip *) pglyph,
+ gStride,
+ 0,
+
+ gx,
+ gy,
+ gWidth, gHeight);
+ }
+ }
+ x += pci->metrics.characterWidth;
+ }
+}
+
+
+void
+fbImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppciInit,
+ pointer pglyphBase)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ CharInfoPtr *ppci;
+ CharInfoPtr pci;
+ unsigned char *pglyph; /* pointer bits in glyph */
+ int gWidth, gHeight; /* width and height of glyph */
+ FbStride gStride; /* stride of glyph */
+ Bool opaque;
+ int n;
+ int gx, gy;
+ void (*glyph) (FbBits *,
+ FbStride,
+ int,
+ FbStip *,
+ FbBits,
+ int,
+ int);
+ FbBits *dst = 0;
+ FbStride dstStride = 0;
+ int dstBpp = 0;
+ int dstXoff = 0, dstYoff = 0;
+
+ glyph = 0;
+ if (pPriv->and == 0)
+ {
+ dstBpp = pDrawable->bitsPerPixel;
+ switch (dstBpp) {
+ case 8: glyph = fbGlyph8; break;
+ case 16: glyph = fbGlyph16; break;
+ case 24: glyph = fbGlyph24; break;
+ case 32: glyph = fbGlyph32; break;
+ }
+ }
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ if (TERMINALFONT (pGC->font)
+ && !glyph
+ )
+ {
+ opaque = TRUE;
+ }
+ else
+ {
+ int xBack, widthBack;
+ int yBack, heightBack;
+
+ ppci = ppciInit;
+ n = nglyph;
+ widthBack = 0;
+ while (n--)
+ widthBack += (*ppci++)->metrics.characterWidth;
+
+ xBack = x;
+ if (widthBack < 0)
+ {
+ xBack += widthBack;
+ widthBack = -widthBack;
+ }
+ yBack = y - FONTASCENT(pGC->font);
+ heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+ fbSolidBoxClipped (pDrawable,
+ fbGetCompositeClip(pGC),
+ xBack,
+ yBack,
+ xBack + widthBack,
+ yBack + heightBack,
+ fbAnd(GXcopy,pPriv->bg,pPriv->pm),
+ fbXor(GXcopy,pPriv->bg,pPriv->pm));
+ opaque = FALSE;
+ }
+
+ 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 = y - pci->metrics.ascent;
+ if (glyph && gWidth <= sizeof (FbStip) * 8 &&
+ fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
+ {
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ (*glyph) (dst + (gy + dstYoff) * dstStride,
+ dstStride,
+ dstBpp,
+ (FbStip *) pglyph,
+ pPriv->fg,
+ gx + dstXoff,
+ gHeight);
+ fbFinishAccess (pDrawable);
+ }
+ else
+ {
+ gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pPriv->fg,
+ pPriv->bg,
+ pPriv->pm,
+ GXcopy,
+ opaque,
+
+ gx,
+ gy,
+ gWidth, gHeight,
+
+ (FbStip *) pglyph,
+ gStride,
+ 0);
+ }
+ }
+ x += pci->metrics.characterWidth;
+ }
+}
diff --git a/xorg-server/fb/fbimage.c b/xorg-server/fb/fbimage.c
index 0fcb05f7c..63978cc3b 100644
--- a/xorg-server/fb/fbimage.c
+++ b/xorg-server/fb/fbimage.c
@@ -1,368 +1,364 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <string.h>
-
-#include "fb.h"
-
-void
-fbPutImage (DrawablePtr pDrawable,
- GCPtr pGC,
- int depth,
- int x,
- int y,
- int w,
- int h,
- int leftPad,
- int format,
- char *pImage)
-{
- FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
- unsigned long i;
- FbStride srcStride;
- FbStip *src = (FbStip *) pImage;
-
- x += pDrawable->x;
- y += pDrawable->y;
-
- switch (format)
- {
- case XYBitmap:
- srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip);
- fbPutXYImage (pDrawable,
- fbGetCompositeClip(pGC),
- pPriv->fg,
- pPriv->bg,
- pPriv->pm,
- pGC->alu,
- TRUE,
- x, y, w, h,
- src,
- srcStride,
- leftPad);
- break;
- case XYPixmap:
- srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip);
- for (i = (unsigned long)1 << (pDrawable->depth - 1); i; i >>= 1)
- {
- if (i & pGC->planemask)
- {
- fbPutXYImage (pDrawable,
- fbGetCompositeClip(pGC),
- FB_ALLONES,
- 0,
- fbReplicatePixel (i, pDrawable->bitsPerPixel),
- pGC->alu,
- TRUE,
- x, y, w, h,
- src,
- srcStride,
- leftPad);
- src += srcStride * h;
- }
- }
- break;
- case ZPixmap:
-#ifdef FB_24_32BIT
- if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
- {
- srcStride = PixmapBytePad(w, pDrawable->depth);
- fb24_32PutZImage (pDrawable,
- fbGetCompositeClip(pGC),
- pGC->alu,
- (FbBits) pGC->planemask,
- x, y, w, h,
- (CARD8 *) pImage,
- srcStride);
- }
- else
-#endif
- {
- srcStride = PixmapBytePad(w, pDrawable->depth) / sizeof (FbStip);
- fbPutZImage (pDrawable,
- fbGetCompositeClip(pGC),
- pGC->alu,
- pPriv->pm,
- x, y, w, h,
- src, srcStride);
- }
- }
-}
-
-void
-fbPutZImage (DrawablePtr pDrawable,
- RegionPtr pClip,
- int alu,
- FbBits pm,
- int x,
- int y,
- int width,
- int height,
- FbStip *src,
- FbStride srcStride)
-{
- FbStip *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- int nbox;
- BoxPtr pbox;
- int x1, y1, x2, y2;
-
- fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-
- for (nbox = RegionNumRects (pClip),
- pbox = RegionRects(pClip);
- nbox--;
- pbox++)
- {
- x1 = x;
- y1 = y;
- x2 = x + width;
- y2 = y + height;
- if (x1 < pbox->x1)
- x1 = pbox->x1;
- if (y1 < pbox->y1)
- y1 = pbox->y1;
- if (x2 > pbox->x2)
- x2 = pbox->x2;
- if (y2 > pbox->y2)
- y2 = pbox->y2;
- if (x1 >= x2 || y1 >= y2)
- continue;
- fbBltStip (src + (y1 - y) * srcStride,
- srcStride,
- (x1 - x) * dstBpp,
-
- dst + (y1 + dstYoff) * dstStride,
- dstStride,
- (x1 + dstXoff) * dstBpp,
-
- (x2 - x1) * dstBpp,
- (y2 - y1),
-
- alu,
- pm,
- dstBpp);
- }
-
- fbFinishAccess (pDrawable);
-}
-
-void
-fbPutXYImage (DrawablePtr pDrawable,
- RegionPtr pClip,
- FbBits fg,
- FbBits bg,
- FbBits pm,
- int alu,
- Bool opaque,
-
- int x,
- int y,
- int width,
- int height,
-
- FbStip *src,
- FbStride srcStride,
- int srcX)
-{
- FbBits *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- int nbox;
- BoxPtr pbox;
- int x1, y1, x2, y2;
- FbBits fgand = 0, fgxor = 0, bgand = 0, bgxor = 0;
-
- fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-
- if (dstBpp == 1)
- {
- if (opaque)
- alu = FbOpaqueStipple1Rop(alu,fg,bg);
- else
- alu = FbStipple1Rop(alu,fg);
- }
- else
- {
- fgand = fbAnd(alu,fg,pm);
- fgxor = fbXor(alu,fg,pm);
- if (opaque)
- {
- bgand = fbAnd(alu,bg,pm);
- bgxor = fbXor(alu,bg,pm);
- }
- else
- {
- bgand = fbAnd(GXnoop,(FbBits)0,FB_ALLONES);
- bgxor = fbXor(GXnoop,(FbBits)0,FB_ALLONES);
- }
- }
-
- for (nbox = RegionNumRects (pClip),
- pbox = RegionRects(pClip);
- nbox--;
- pbox++)
- {
- x1 = x;
- y1 = y;
- x2 = x + width;
- y2 = y + height;
- if (x1 < pbox->x1)
- x1 = pbox->x1;
- if (y1 < pbox->y1)
- y1 = pbox->y1;
- if (x2 > pbox->x2)
- x2 = pbox->x2;
- if (y2 > pbox->y2)
- y2 = pbox->y2;
- if (x1 >= x2 || y1 >= y2)
- continue;
- if (dstBpp == 1)
- {
- fbBltStip (src + (y1 - y) * srcStride,
- srcStride,
- (x1 - x) + srcX,
-
- (FbStip *) (dst + (y1 + dstYoff) * dstStride),
- FbBitsStrideToStipStride(dstStride),
- (x1 + dstXoff) * dstBpp,
-
- (x2 - x1) * dstBpp,
- (y2 - y1),
-
- alu,
- pm,
- dstBpp);
- }
- else
- {
- fbBltOne (src + (y1 - y) * srcStride,
- srcStride,
- (x1 - x) + srcX,
-
- dst + (y1 + dstYoff) * dstStride,
- dstStride,
- (x1 + dstXoff) * dstBpp,
- dstBpp,
-
- (x2 - x1) * dstBpp,
- (y2 - y1),
-
- fgand, fgxor, bgand, bgxor);
- }
- }
-
- fbFinishAccess (pDrawable);
-}
-
-void
-fbGetImage (DrawablePtr pDrawable,
- int x,
- int y,
- int w,
- int h,
- unsigned int format,
- unsigned long planeMask,
- char *d)
-{
- FbBits *src;
- FbStride srcStride;
- int srcBpp;
- int srcXoff, srcYoff;
- FbStip *dst;
- FbStride dstStride;
-
- /*
- * XFree86 DDX empties the root borderClip when the VT is
- * switched away; this checks for that case
- */
- if (!fbDrawableEnabled(pDrawable))
- return;
-
-#ifdef FB_24_32BIT
- if (format == ZPixmap &&
- pDrawable->bitsPerPixel != BitsPerPixel (pDrawable->depth))
- {
- fb24_32GetImage (pDrawable, x, y, w, h, format, planeMask, d);
- return;
- }
-#endif
-
- fbGetDrawable (pDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
-
- x += pDrawable->x;
- y += pDrawable->y;
-
- dst = (FbStip *) d;
- if (format == ZPixmap || srcBpp == 1)
- {
- FbBits pm;
-
- pm = fbReplicatePixel (planeMask, srcBpp);
- dstStride = PixmapBytePad(w, pDrawable->depth);
- if (pm != FB_ALLONES)
- memset (d, 0, dstStride * h);
- dstStride /= sizeof (FbStip);
- fbBltStip ((FbStip *) (src + (y + srcYoff) * srcStride),
- FbBitsStrideToStipStride(srcStride),
- (x + srcXoff) * srcBpp,
-
- dst,
- dstStride,
- 0,
-
- w * srcBpp, h,
-
- GXcopy,
- pm,
- srcBpp);
- }
- else
- {
- dstStride = BitmapBytePad(w) / sizeof (FbStip);
- fbBltPlane (src + (y + srcYoff) * srcStride,
- srcStride,
- (x + srcXoff) * srcBpp,
- srcBpp,
-
- dst,
- dstStride,
- 0,
-
- w * srcBpp, h,
-
- fbAndStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES),
- fbXorStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES),
- fbAndStip(GXcopy,0,FB_STIP_ALLONES),
- fbXorStip(GXcopy,0,FB_STIP_ALLONES),
- planeMask);
- }
-
- fbFinishAccess (pDrawable);
-}
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+
+#include "fb.h"
+
+void
+fbPutImage (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ unsigned long i;
+ FbStride srcStride;
+ FbStip *src = (FbStip *) pImage;
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ switch (format)
+ {
+ case XYBitmap:
+ srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip);
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pPriv->fg,
+ pPriv->bg,
+ pPriv->pm,
+ pGC->alu,
+ TRUE,
+ x, y, w, h,
+ src,
+ srcStride,
+ leftPad);
+ break;
+ case XYPixmap:
+ srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip);
+ for (i = (unsigned long)1 << (pDrawable->depth - 1); i; i >>= 1)
+ {
+ if (i & pGC->planemask)
+ {
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ FB_ALLONES,
+ 0,
+ fbReplicatePixel (i, pDrawable->bitsPerPixel),
+ pGC->alu,
+ TRUE,
+ x, y, w, h,
+ src,
+ srcStride,
+ leftPad);
+ src += srcStride * h;
+ }
+ }
+ break;
+ case ZPixmap:
+ if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
+ {
+ srcStride = PixmapBytePad(w, pDrawable->depth);
+ fb24_32PutZImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pGC->alu,
+ (FbBits) pGC->planemask,
+ x, y, w, h,
+ (CARD8 *) pImage,
+ srcStride);
+ }
+ else
+ {
+ srcStride = PixmapBytePad(w, pDrawable->depth) / sizeof (FbStip);
+ fbPutZImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pGC->alu,
+ pPriv->pm,
+ x, y, w, h,
+ src, srcStride);
+ }
+ }
+}
+
+void
+fbPutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ FbStip *src,
+ FbStride srcStride)
+{
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int nbox;
+ BoxPtr pbox;
+ int x1, y1, x2, y2;
+
+ fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ for (nbox = RegionNumRects (pClip),
+ pbox = RegionRects(pClip);
+ nbox--;
+ pbox++)
+ {
+ x1 = x;
+ y1 = y;
+ x2 = x + width;
+ y2 = y + height;
+ if (x1 < pbox->x1)
+ x1 = pbox->x1;
+ if (y1 < pbox->y1)
+ y1 = pbox->y1;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ fbBltStip (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x) * dstBpp,
+
+ dst + (y1 + dstYoff) * dstStride,
+ dstStride,
+ (x1 + dstXoff) * dstBpp,
+
+ (x2 - x1) * dstBpp,
+ (y2 - y1),
+
+ alu,
+ pm,
+ dstBpp);
+ }
+
+ fbFinishAccess (pDrawable);
+}
+
+void
+fbPutXYImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ FbBits fg,
+ FbBits bg,
+ FbBits pm,
+ int alu,
+ Bool opaque,
+
+ int x,
+ int y,
+ int width,
+ int height,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int nbox;
+ BoxPtr pbox;
+ int x1, y1, x2, y2;
+ FbBits fgand = 0, fgxor = 0, bgand = 0, bgxor = 0;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ if (dstBpp == 1)
+ {
+ if (opaque)
+ alu = FbOpaqueStipple1Rop(alu,fg,bg);
+ else
+ alu = FbStipple1Rop(alu,fg);
+ }
+ else
+ {
+ fgand = fbAnd(alu,fg,pm);
+ fgxor = fbXor(alu,fg,pm);
+ if (opaque)
+ {
+ bgand = fbAnd(alu,bg,pm);
+ bgxor = fbXor(alu,bg,pm);
+ }
+ else
+ {
+ bgand = fbAnd(GXnoop,(FbBits)0,FB_ALLONES);
+ bgxor = fbXor(GXnoop,(FbBits)0,FB_ALLONES);
+ }
+ }
+
+ for (nbox = RegionNumRects (pClip),
+ pbox = RegionRects(pClip);
+ nbox--;
+ pbox++)
+ {
+ x1 = x;
+ y1 = y;
+ x2 = x + width;
+ y2 = y + height;
+ if (x1 < pbox->x1)
+ x1 = pbox->x1;
+ if (y1 < pbox->y1)
+ y1 = pbox->y1;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ if (dstBpp == 1)
+ {
+ fbBltStip (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x) + srcX,
+
+ (FbStip *) (dst + (y1 + dstYoff) * dstStride),
+ FbBitsStrideToStipStride(dstStride),
+ (x1 + dstXoff) * dstBpp,
+
+ (x2 - x1) * dstBpp,
+ (y2 - y1),
+
+ alu,
+ pm,
+ dstBpp);
+ }
+ else
+ {
+ fbBltOne (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x) + srcX,
+
+ dst + (y1 + dstYoff) * dstStride,
+ dstStride,
+ (x1 + dstXoff) * dstBpp,
+ dstBpp,
+
+ (x2 - x1) * dstBpp,
+ (y2 - y1),
+
+ fgand, fgxor, bgand, bgxor);
+ }
+ }
+
+ fbFinishAccess (pDrawable);
+}
+
+void
+fbGetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d)
+{
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbStip *dst;
+ FbStride dstStride;
+
+ /*
+ * XFree86 DDX empties the root borderClip when the VT is
+ * switched away; this checks for that case
+ */
+ if (!fbDrawableEnabled(pDrawable))
+ return;
+
+ if (format == ZPixmap &&
+ pDrawable->bitsPerPixel != BitsPerPixel (pDrawable->depth))
+ {
+ fb24_32GetImage (pDrawable, x, y, w, h, format, planeMask, d);
+ return;
+ }
+
+ fbGetDrawable (pDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ dst = (FbStip *) d;
+ if (format == ZPixmap || srcBpp == 1)
+ {
+ FbBits pm;
+
+ pm = fbReplicatePixel (planeMask, srcBpp);
+ dstStride = PixmapBytePad(w, pDrawable->depth);
+ if (pm != FB_ALLONES)
+ memset (d, 0, dstStride * h);
+ dstStride /= sizeof (FbStip);
+ fbBltStip ((FbStip *) (src + (y + srcYoff) * srcStride),
+ FbBitsStrideToStipStride(srcStride),
+ (x + srcXoff) * srcBpp,
+
+ dst,
+ dstStride,
+ 0,
+
+ w * srcBpp, h,
+
+ GXcopy,
+ pm,
+ srcBpp);
+ }
+ else
+ {
+ dstStride = BitmapBytePad(w) / sizeof (FbStip);
+ fbBltPlane (src + (y + srcYoff) * srcStride,
+ srcStride,
+ (x + srcXoff) * srcBpp,
+ srcBpp,
+
+ dst,
+ dstStride,
+ 0,
+
+ w * srcBpp, h,
+
+ fbAndStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES),
+ fbXorStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES),
+ fbAndStip(GXcopy,0,FB_STIP_ALLONES),
+ fbXorStip(GXcopy,0,FB_STIP_ALLONES),
+ planeMask);
+ }
+
+ fbFinishAccess (pDrawable);
+}
diff --git a/xorg-server/fb/fbline.c b/xorg-server/fb/fbline.c
index 66e6d3690..e290bf886 100644
--- a/xorg-server/fb/fbline.c
+++ b/xorg-server/fb/fbline.c
@@ -1,175 +1,167 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-void
-fbZeroLine (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr ppt)
-{
- int x1, y1, x2, y2;
- int x, y;
- int dashOffset;
-
- x = pDrawable->x;
- y = pDrawable->y;
- x1 = ppt->x;
- y1 = ppt->y;
- dashOffset = pGC->dashOffset;
- while (--npt)
- {
- ++ppt;
- x2 = ppt->x;
- y2 = ppt->y;
- if (mode == CoordModePrevious)
- {
- x2 += x1;
- y2 += y1;
- }
- fbSegment (pDrawable, pGC, x1 + x, y1 + y,
- x2 + x, y2 + y,
- npt == 1 && pGC->capStyle != CapNotLast,
- &dashOffset);
- x1 = x2;
- y1 = y2;
- }
-}
-
-void
-fbZeroSegment (DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSegs)
-{
- int dashOffset;
- int x, y;
- Bool drawLast = pGC->capStyle != CapNotLast;
-
- x = pDrawable->x;
- y = pDrawable->y;
- while (nseg--)
- {
- dashOffset = pGC->dashOffset;
- fbSegment (pDrawable, pGC,
- pSegs->x1 + x, pSegs->y1 + y,
- pSegs->x2 + x, pSegs->y2 + y,
- drawLast,
- &dashOffset);
- pSegs++;
- }
-}
-
-void
-fbFixCoordModePrevious (int npt,
- DDXPointPtr ppt)
-{
- int x, y;
-
- x = ppt->x;
- y = ppt->y;
- npt--;
- while (npt--)
- {
- ppt++;
- x = (ppt->x += x);
- y = (ppt->y += y);
- }
-}
-
-void
-fbPolyLine (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr ppt)
-{
- void (*line) (DrawablePtr, GCPtr, int mode, int npt, DDXPointPtr ppt);
-
- if (pGC->lineWidth == 0)
- {
- line = fbZeroLine;
-#ifndef FBNOPIXADDR
- if (pGC->fillStyle == FillSolid &&
- pGC->lineStyle == LineSolid &&
- RegionNumRects (fbGetCompositeClip(pGC)) == 1)
- {
- switch (pDrawable->bitsPerPixel) {
- case 8: line = fbPolyline8; break;
- case 16: line = fbPolyline16; break;
-#ifdef FB_24BIT
- case 24: line = fbPolyline24; break;
-#endif
- case 32: line = fbPolyline32; break;
- }
- }
-#endif
- }
- else
- {
- if (pGC->lineStyle != LineSolid)
- line = miWideDash;
- else
- line = miWideLine;
- }
- (*line) (pDrawable, pGC, mode, npt, ppt);
-}
-
-void
-fbPolySegment (DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pseg)
-{
- void (*seg) (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pseg);
-
- if (pGC->lineWidth == 0)
- {
- seg = fbZeroSegment;
-#ifndef FBNOPIXADDR
- if (pGC->fillStyle == FillSolid &&
- pGC->lineStyle == LineSolid &&
- RegionNumRects (fbGetCompositeClip(pGC)) == 1)
- {
- switch (pDrawable->bitsPerPixel) {
- case 8: seg = fbPolySegment8; break;
- case 16: seg = fbPolySegment16; break;
-#ifdef FB_24BIT
- case 24: seg = fbPolySegment24; break;
-#endif
- case 32: seg = fbPolySegment32; break;
- }
- }
-#endif
- }
- else
- {
- seg = miPolySegment;
- }
- (*seg) (pDrawable, pGC, nseg, pseg);
-}
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbZeroLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt)
+{
+ int x1, y1, x2, y2;
+ int x, y;
+ int dashOffset;
+
+ x = pDrawable->x;
+ y = pDrawable->y;
+ x1 = ppt->x;
+ y1 = ppt->y;
+ dashOffset = pGC->dashOffset;
+ while (--npt)
+ {
+ ++ppt;
+ x2 = ppt->x;
+ y2 = ppt->y;
+ if (mode == CoordModePrevious)
+ {
+ x2 += x1;
+ y2 += y1;
+ }
+ fbSegment (pDrawable, pGC, x1 + x, y1 + y,
+ x2 + x, y2 + y,
+ npt == 1 && pGC->capStyle != CapNotLast,
+ &dashOffset);
+ x1 = x2;
+ y1 = y2;
+ }
+}
+
+void
+fbZeroSegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSegs)
+{
+ int dashOffset;
+ int x, y;
+ Bool drawLast = pGC->capStyle != CapNotLast;
+
+ x = pDrawable->x;
+ y = pDrawable->y;
+ while (nseg--)
+ {
+ dashOffset = pGC->dashOffset;
+ fbSegment (pDrawable, pGC,
+ pSegs->x1 + x, pSegs->y1 + y,
+ pSegs->x2 + x, pSegs->y2 + y,
+ drawLast,
+ &dashOffset);
+ pSegs++;
+ }
+}
+
+void
+fbFixCoordModePrevious (int npt,
+ DDXPointPtr ppt)
+{
+ int x, y;
+
+ x = ppt->x;
+ y = ppt->y;
+ npt--;
+ while (npt--)
+ {
+ ppt++;
+ x = (ppt->x += x);
+ y = (ppt->y += y);
+ }
+}
+
+void
+fbPolyLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt)
+{
+ void (*line) (DrawablePtr, GCPtr, int mode, int npt, DDXPointPtr ppt);
+
+ if (pGC->lineWidth == 0)
+ {
+ line = fbZeroLine;
+ if (pGC->fillStyle == FillSolid &&
+ pGC->lineStyle == LineSolid &&
+ RegionNumRects (fbGetCompositeClip(pGC)) == 1)
+ {
+ switch (pDrawable->bitsPerPixel) {
+ case 8: line = fbPolyline8; break;
+ case 16: line = fbPolyline16; break;
+ case 24: line = fbPolyline24; break;
+ case 32: line = fbPolyline32; break;
+ }
+ }
+ }
+ else
+ {
+ if (pGC->lineStyle != LineSolid)
+ line = miWideDash;
+ else
+ line = miWideLine;
+ }
+ (*line) (pDrawable, pGC, mode, npt, ppt);
+}
+
+void
+fbPolySegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg)
+{
+ void (*seg) (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pseg);
+
+ if (pGC->lineWidth == 0)
+ {
+ seg = fbZeroSegment;
+ if (pGC->fillStyle == FillSolid &&
+ pGC->lineStyle == LineSolid &&
+ RegionNumRects (fbGetCompositeClip(pGC)) == 1)
+ {
+ switch (pDrawable->bitsPerPixel) {
+ case 8: seg = fbPolySegment8; break;
+ case 16: seg = fbPolySegment16; break;
+ case 24: seg = fbPolySegment24; break;
+ case 32: seg = fbPolySegment32; break;
+ }
+ }
+ }
+ else
+ {
+ seg = miPolySegment;
+ }
+ (*seg) (pDrawable, pGC, nseg, pseg);
+}
diff --git a/xorg-server/fb/fboverlay.c b/xorg-server/fb/fboverlay.c
index d6986e2a8..61eaaa3f9 100644
--- a/xorg-server/fb/fboverlay.c
+++ b/xorg-server/fb/fboverlay.c
@@ -1,433 +1,425 @@
-/*
- *
- * Copyright © 2000 SuSE, 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 SuSE not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. SuSE makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
- * 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: Keith Packard, SuSE, Inc.
- */
-
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include "fb.h"
-#include "fboverlay.h"
-#include "shmint.h"
-
-static DevPrivateKeyRec fbOverlayScreenPrivateKeyRec;
-#define fbOverlayScreenPrivateKey (&fbOverlayScreenPrivateKeyRec)
-
-DevPrivateKey fbOverlayGetScreenPrivateKey(void)
-{
- return fbOverlayScreenPrivateKey;
-}
-
-/*
- * Replace this if you want something supporting
- * multiple overlays with the same depth
- */
-Bool
-fbOverlayCreateWindow(WindowPtr pWin)
-{
- FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
- int i;
- PixmapPtr pPixmap;
-
- if (pWin->drawable.class != InputOutput)
- return TRUE;
-
-#ifdef FB_SCREEN_PRIVATE
- if (pWin->drawable.bitsPerPixel == 32)
- pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
-#endif
-
- for (i = 0; i < pScrPriv->nlayers; i++)
- {
- pPixmap = pScrPriv->layer[i].u.run.pixmap;
- if (pWin->drawable.depth == pPixmap->drawable.depth)
- {
- dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pPixmap);
- /*
- * Make sure layer keys are written correctly by
- * having non-root layers set to full while the
- * root layer is set to empty. This will cause
- * all of the layers to get painted when the root
- * is mapped
- */
- if (!pWin->parent)
- {
- RegionEmpty(&pScrPriv->layer[i].u.run.region);
- }
- return TRUE;
- }
- }
- return FALSE;
-}
-
-Bool
-fbOverlayCloseScreen (int iScreen, ScreenPtr pScreen)
-{
- FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
- int i;
-
- for (i = 0; i < pScrPriv->nlayers; i++)
- {
- (*pScreen->DestroyPixmap)(pScrPriv->layer[i].u.run.pixmap);
- RegionUninit(&pScrPriv->layer[i].u.run.region);
- }
- return TRUE;
-}
-
-/*
- * Return layer containing this window
- */
-int
-fbOverlayWindowLayer(WindowPtr pWin)
-{
- FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
- int i;
-
- for (i = 0; i < pScrPriv->nlayers; i++)
- if (dixLookupPrivate(&pWin->devPrivates, fbGetWinPrivateKey()) ==
- (pointer) pScrPriv->layer[i].u.run.pixmap)
- return i;
- return 0;
-}
-
-Bool
-fbOverlayCreateScreenResources(ScreenPtr pScreen)
-{
- int i;
- FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
- PixmapPtr pPixmap;
- pointer pbits;
- int width;
- int depth;
- BoxRec box;
-
- if (!miCreateScreenResources(pScreen))
- return FALSE;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pScreen->width;
- box.y2 = pScreen->height;
- for (i = 0; i < pScrPriv->nlayers; i++)
- {
- pbits = pScrPriv->layer[i].u.init.pbits;
- width = pScrPriv->layer[i].u.init.width;
- depth = pScrPriv->layer[i].u.init.depth;
- pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth, 0);
- if (!pPixmap)
- return FALSE;
- if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width,
- pScreen->height, depth,
- BitsPerPixel(depth),
- PixmapBytePad(width, depth),
- pbits))
- return FALSE;
- pScrPriv->layer[i].u.run.pixmap = pPixmap;
- RegionInit(&pScrPriv->layer[i].u.run.region, &box, 0);
- }
- pScreen->devPrivate = pScrPriv->layer[0].u.run.pixmap;
- return TRUE;
-}
-
-void
-fbOverlayPaintKey (DrawablePtr pDrawable,
- RegionPtr pRegion,
- CARD32 pixel,
- int layer)
-{
- fbFillRegionSolid (pDrawable, pRegion, 0,
- fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
-}
-
-/*
- * Track visible region for each layer
- */
-void
-fbOverlayUpdateLayerRegion (ScreenPtr pScreen,
- int layer,
- RegionPtr prgn)
-{
- FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
- int i;
- RegionRec rgnNew;
-
- if (!prgn || !RegionNotEmpty(prgn))
- return;
- for (i = 0; i < pScrPriv->nlayers; i++)
- {
- if (i == layer)
- {
- /* add new piece to this fb */
- RegionUnion(&pScrPriv->layer[i].u.run.region,
- &pScrPriv->layer[i].u.run.region,
- prgn);
- }
- else if (RegionNotEmpty(&pScrPriv->layer[i].u.run.region))
- {
- /* paint new piece with chroma key */
- RegionNull(&rgnNew);
- RegionIntersect(&rgnNew, prgn,
- &pScrPriv->layer[i].u.run.region);
- (*pScrPriv->PaintKey) (&pScrPriv->layer[i].u.run.pixmap->drawable,
- &rgnNew,
- pScrPriv->layer[i].key,
- i);
- RegionUninit(&rgnNew);
- /* remove piece from other fbs */
- RegionSubtract(&pScrPriv->layer[i].u.run.region,
- &pScrPriv->layer[i].u.run.region,
- prgn);
- }
- }
-}
-
-/*
- * Copy only areas in each layer containing real bits
- */
-void
-fbOverlayCopyWindow(WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
- RegionRec rgnDst;
- int dx, dy;
- int i;
- RegionRec layerRgn[FB_OVERLAY_MAX];
- PixmapPtr pPixmap;
-
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
-
- /*
- * Clip to existing bits
- */
- RegionTranslate(prgnSrc, -dx, -dy);
- RegionNull(&rgnDst);
- RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
- RegionTranslate(&rgnDst, dx, dy);
- /*
- * Compute the portion of each fb affected by this copy
- */
- for (i = 0; i < pScrPriv->nlayers; i++)
- {
- RegionNull(&layerRgn[i]);
- RegionIntersect(&layerRgn[i], &rgnDst,
- &pScrPriv->layer[i].u.run.region);
- if (RegionNotEmpty(&layerRgn[i]))
- {
- RegionTranslate(&layerRgn[i], -dx, -dy);
- pPixmap = pScrPriv->layer[i].u.run.pixmap;
- miCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
- 0,
- &layerRgn[i], dx, dy, pScrPriv->CopyWindow, 0,
- (void *)(long) i);
- }
- }
- /*
- * Update regions
- */
- for (i = 0; i < pScrPriv->nlayers; i++)
- {
- if (RegionNotEmpty(&layerRgn[i]))
- fbOverlayUpdateLayerRegion (pScreen, i, &layerRgn[i]);
-
- RegionUninit(&layerRgn[i]);
- }
- RegionUninit(&rgnDst);
-}
-
-void
-fbOverlayWindowExposures (WindowPtr pWin,
- RegionPtr prgn,
- RegionPtr other_exposed)
-{
- fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
- fbOverlayWindowLayer (pWin),
- prgn);
- miWindowExposures(pWin, prgn, other_exposed);
-}
-
-Bool
-fbOverlaySetupScreen(ScreenPtr pScreen,
- pointer pbits1,
- pointer pbits2,
- int xsize,
- int ysize,
- int dpix,
- int dpiy,
- int width1,
- int width2,
- int bpp1,
- int bpp2)
-{
- return fbSetupScreen (pScreen,
- pbits1,
- xsize,
- ysize,
- dpix,
- dpiy,
- width1,
- bpp1);
-}
-
-static Bool
-fb24_32OverlayCreateScreenResources(ScreenPtr pScreen)
-{
- FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
- int pitch;
- Bool retval;
- int i;
-
- if((retval = fbOverlayCreateScreenResources(pScreen))) {
- for (i = 0; i < pScrPriv->nlayers; i++)
- {
- /* fix the screen pixmap */
- PixmapPtr pPix = (PixmapPtr) pScrPriv->layer[i].u.run.pixmap;
- if (pPix->drawable.bitsPerPixel == 32) {
- pPix->drawable.bitsPerPixel = 24;
- pitch = BitmapBytePad(pPix->drawable.width * 24);
- pPix->devKind = pitch;
- }
- }
- }
-
- return retval;
-}
-
-Bool
-fbOverlayFinishScreenInit(ScreenPtr pScreen,
- pointer pbits1,
- pointer pbits2,
- int xsize,
- int ysize,
- int dpix,
- int dpiy,
- int width1,
- int width2,
- int bpp1,
- int bpp2,
- int depth1,
- int depth2)
-{
- VisualPtr visuals;
- DepthPtr depths;
- int nvisuals;
- int ndepths;
- int bpp = 0, imagebpp = 32;
- VisualID defaultVisual;
- FbOverlayScrPrivPtr pScrPriv;
-
- if (!dixRegisterPrivateKey(&fbOverlayScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- pScrPriv = malloc(sizeof (FbOverlayScrPrivRec));
- if (!pScrPriv)
- return FALSE;
-
-#ifdef FB_24_32BIT
- if (bpp1 == 32 || bpp2 == 32)
- bpp = 32;
- else if (bpp1 == 24 || bpp2 == 24)
- bpp = 24;
-
- if (bpp == 24)
- {
- int f;
-
- imagebpp = 32;
- /*
- * Check to see if we're advertising a 24bpp image format,
- * in which case windows will use it in preference to a 32 bit
- * format.
- */
- for (f = 0; f < screenInfo.numPixmapFormats; f++)
- {
- if (screenInfo.formats[f].bitsPerPixel == 24)
- {
- imagebpp = 24;
- break;
- }
- }
- }
-#endif
-#ifdef FB_SCREEN_PRIVATE
- if (imagebpp == 32)
- {
- fbGetScreenPrivate(pScreen)->win32bpp = bpp;
- fbGetScreenPrivate(pScreen)->pix32bpp = bpp;
- }
- else
- {
- fbGetScreenPrivate(pScreen)->win32bpp = 32;
- fbGetScreenPrivate(pScreen)->pix32bpp = 32;
- }
-#endif
-
- if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &depth1,
- &defaultVisual, ((unsigned long)1<<(bpp1-1)) |
- ((unsigned long)1<<(bpp2-1)), 8))
- return FALSE;
- if (! miScreenInit(pScreen, 0, xsize, ysize, dpix, dpiy, 0,
- depth1, ndepths, depths,
- defaultVisual, nvisuals, visuals))
- return FALSE;
- /* MI thinks there's no frame buffer */
-#ifdef MITSHM
- ShmRegisterFbFuncs(pScreen);
-#endif
- pScreen->minInstalledCmaps = 1;
- pScreen->maxInstalledCmaps = 2;
-
- pScrPriv->nlayers = 2;
- pScrPriv->PaintKey = fbOverlayPaintKey;
- pScrPriv->CopyWindow = fbCopyWindowProc;
- pScrPriv->layer[0].u.init.pbits = pbits1;
- pScrPriv->layer[0].u.init.width = width1;
- pScrPriv->layer[0].u.init.depth = depth1;
-
- pScrPriv->layer[1].u.init.pbits = pbits2;
- pScrPriv->layer[1].u.init.width = width2;
- pScrPriv->layer[1].u.init.depth = depth2;
- dixSetPrivate(&pScreen->devPrivates, fbOverlayScreenPrivateKey, pScrPriv);
-
- /* overwrite miCloseScreen with our own */
- pScreen->CloseScreen = fbOverlayCloseScreen;
- pScreen->CreateScreenResources = fbOverlayCreateScreenResources;
- pScreen->CreateWindow = fbOverlayCreateWindow;
- pScreen->WindowExposures = fbOverlayWindowExposures;
- pScreen->CopyWindow = fbOverlayCopyWindow;
-#ifdef FB_24_32BIT
- if (bpp == 24 && imagebpp == 32)
- {
- pScreen->ModifyPixmapHeader = fb24_32ModifyPixmapHeader;
- pScreen->CreateScreenResources = fb24_32OverlayCreateScreenResources;
- }
-#endif
-
- return TRUE;
-}
+/*
+ *
+ * Copyright © 2000 SuSE, 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 SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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: Keith Packard, SuSE, Inc.
+ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "fb.h"
+#include "fboverlay.h"
+#include "shmint.h"
+
+static DevPrivateKeyRec fbOverlayScreenPrivateKeyRec;
+#define fbOverlayScreenPrivateKey (&fbOverlayScreenPrivateKeyRec)
+
+DevPrivateKey fbOverlayGetScreenPrivateKey(void)
+{
+ return fbOverlayScreenPrivateKey;
+}
+
+/*
+ * Replace this if you want something supporting
+ * multiple overlays with the same depth
+ */
+Bool
+fbOverlayCreateWindow(WindowPtr pWin)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
+ int i;
+ PixmapPtr pPixmap;
+
+ if (pWin->drawable.class != InputOutput)
+ return TRUE;
+
+ if (pWin->drawable.bitsPerPixel == 32)
+ pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
+
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ pPixmap = pScrPriv->layer[i].u.run.pixmap;
+ if (pWin->drawable.depth == pPixmap->drawable.depth)
+ {
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pPixmap);
+ /*
+ * Make sure layer keys are written correctly by
+ * having non-root layers set to full while the
+ * root layer is set to empty. This will cause
+ * all of the layers to get painted when the root
+ * is mapped
+ */
+ if (!pWin->parent)
+ {
+ RegionEmpty(&pScrPriv->layer[i].u.run.region);
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+Bool
+fbOverlayCloseScreen (int iScreen, ScreenPtr pScreen)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ int i;
+
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ (*pScreen->DestroyPixmap)(pScrPriv->layer[i].u.run.pixmap);
+ RegionUninit(&pScrPriv->layer[i].u.run.region);
+ }
+ return TRUE;
+}
+
+/*
+ * Return layer containing this window
+ */
+int
+fbOverlayWindowLayer(WindowPtr pWin)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
+ int i;
+
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ if (dixLookupPrivate(&pWin->devPrivates, fbGetWinPrivateKey()) ==
+ (pointer) pScrPriv->layer[i].u.run.pixmap)
+ return i;
+ return 0;
+}
+
+Bool
+fbOverlayCreateScreenResources(ScreenPtr pScreen)
+{
+ int i;
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ PixmapPtr pPixmap;
+ pointer pbits;
+ int width;
+ int depth;
+ BoxRec box;
+
+ if (!miCreateScreenResources(pScreen))
+ return FALSE;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ pbits = pScrPriv->layer[i].u.init.pbits;
+ width = pScrPriv->layer[i].u.init.width;
+ depth = pScrPriv->layer[i].u.init.depth;
+ pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth, 0);
+ if (!pPixmap)
+ return FALSE;
+ if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width,
+ pScreen->height, depth,
+ BitsPerPixel(depth),
+ PixmapBytePad(width, depth),
+ pbits))
+ return FALSE;
+ pScrPriv->layer[i].u.run.pixmap = pPixmap;
+ RegionInit(&pScrPriv->layer[i].u.run.region, &box, 0);
+ }
+ pScreen->devPrivate = pScrPriv->layer[0].u.run.pixmap;
+ return TRUE;
+}
+
+void
+fbOverlayPaintKey (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ CARD32 pixel,
+ int layer)
+{
+ fbFillRegionSolid (pDrawable, pRegion, 0,
+ fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
+}
+
+/*
+ * Track visible region for each layer
+ */
+void
+fbOverlayUpdateLayerRegion (ScreenPtr pScreen,
+ int layer,
+ RegionPtr prgn)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ int i;
+ RegionRec rgnNew;
+
+ if (!prgn || !RegionNotEmpty(prgn))
+ return;
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ if (i == layer)
+ {
+ /* add new piece to this fb */
+ RegionUnion(&pScrPriv->layer[i].u.run.region,
+ &pScrPriv->layer[i].u.run.region,
+ prgn);
+ }
+ else if (RegionNotEmpty(&pScrPriv->layer[i].u.run.region))
+ {
+ /* paint new piece with chroma key */
+ RegionNull(&rgnNew);
+ RegionIntersect(&rgnNew, prgn,
+ &pScrPriv->layer[i].u.run.region);
+ (*pScrPriv->PaintKey) (&pScrPriv->layer[i].u.run.pixmap->drawable,
+ &rgnNew,
+ pScrPriv->layer[i].key,
+ i);
+ RegionUninit(&rgnNew);
+ /* remove piece from other fbs */
+ RegionSubtract(&pScrPriv->layer[i].u.run.region,
+ &pScrPriv->layer[i].u.run.region,
+ prgn);
+ }
+ }
+}
+
+/*
+ * Copy only areas in each layer containing real bits
+ */
+void
+fbOverlayCopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ RegionRec rgnDst;
+ int dx, dy;
+ int i;
+ RegionRec layerRgn[FB_OVERLAY_MAX];
+ PixmapPtr pPixmap;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+
+ /*
+ * Clip to existing bits
+ */
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionNull(&rgnDst);
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
+ RegionTranslate(&rgnDst, dx, dy);
+ /*
+ * Compute the portion of each fb affected by this copy
+ */
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ RegionNull(&layerRgn[i]);
+ RegionIntersect(&layerRgn[i], &rgnDst,
+ &pScrPriv->layer[i].u.run.region);
+ if (RegionNotEmpty(&layerRgn[i]))
+ {
+ RegionTranslate(&layerRgn[i], -dx, -dy);
+ pPixmap = pScrPriv->layer[i].u.run.pixmap;
+ miCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
+ 0,
+ &layerRgn[i], dx, dy, pScrPriv->CopyWindow, 0,
+ (void *)(long) i);
+ }
+ }
+ /*
+ * Update regions
+ */
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ if (RegionNotEmpty(&layerRgn[i]))
+ fbOverlayUpdateLayerRegion (pScreen, i, &layerRgn[i]);
+
+ RegionUninit(&layerRgn[i]);
+ }
+ RegionUninit(&rgnDst);
+}
+
+void
+fbOverlayWindowExposures (WindowPtr pWin,
+ RegionPtr prgn,
+ RegionPtr other_exposed)
+{
+ fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
+ fbOverlayWindowLayer (pWin),
+ prgn);
+ miWindowExposures(pWin, prgn, other_exposed);
+}
+
+Bool
+fbOverlaySetupScreen(ScreenPtr pScreen,
+ pointer pbits1,
+ pointer pbits2,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width1,
+ int width2,
+ int bpp1,
+ int bpp2)
+{
+ return fbSetupScreen (pScreen,
+ pbits1,
+ xsize,
+ ysize,
+ dpix,
+ dpiy,
+ width1,
+ bpp1);
+}
+
+static Bool
+fb24_32OverlayCreateScreenResources(ScreenPtr pScreen)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ int pitch;
+ Bool retval;
+ int i;
+
+ if((retval = fbOverlayCreateScreenResources(pScreen))) {
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ /* fix the screen pixmap */
+ PixmapPtr pPix = (PixmapPtr) pScrPriv->layer[i].u.run.pixmap;
+ if (pPix->drawable.bitsPerPixel == 32) {
+ pPix->drawable.bitsPerPixel = 24;
+ pitch = BitmapBytePad(pPix->drawable.width * 24);
+ pPix->devKind = pitch;
+ }
+ }
+ }
+
+ return retval;
+}
+
+Bool
+fbOverlayFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits1,
+ pointer pbits2,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width1,
+ int width2,
+ int bpp1,
+ int bpp2,
+ int depth1,
+ int depth2)
+{
+ VisualPtr visuals;
+ DepthPtr depths;
+ int nvisuals;
+ int ndepths;
+ int bpp = 0, imagebpp = 32;
+ VisualID defaultVisual;
+ FbOverlayScrPrivPtr pScrPriv;
+
+ if (!dixRegisterPrivateKey(&fbOverlayScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ pScrPriv = malloc(sizeof (FbOverlayScrPrivRec));
+ if (!pScrPriv)
+ return FALSE;
+
+ if (bpp1 == 32 || bpp2 == 32)
+ bpp = 32;
+ else if (bpp1 == 24 || bpp2 == 24)
+ bpp = 24;
+
+ if (bpp == 24)
+ {
+ int f;
+
+ imagebpp = 32;
+ /*
+ * Check to see if we're advertising a 24bpp image format,
+ * in which case windows will use it in preference to a 32 bit
+ * format.
+ */
+ for (f = 0; f < screenInfo.numPixmapFormats; f++)
+ {
+ if (screenInfo.formats[f].bitsPerPixel == 24)
+ {
+ imagebpp = 24;
+ break;
+ }
+ }
+ }
+ if (imagebpp == 32)
+ {
+ fbGetScreenPrivate(pScreen)->win32bpp = bpp;
+ fbGetScreenPrivate(pScreen)->pix32bpp = bpp;
+ }
+ else
+ {
+ fbGetScreenPrivate(pScreen)->win32bpp = 32;
+ fbGetScreenPrivate(pScreen)->pix32bpp = 32;
+ }
+
+ if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &depth1,
+ &defaultVisual, ((unsigned long)1<<(bpp1-1)) |
+ ((unsigned long)1<<(bpp2-1)), 8))
+ return FALSE;
+ if (! miScreenInit(pScreen, 0, xsize, ysize, dpix, dpiy, 0,
+ depth1, ndepths, depths,
+ defaultVisual, nvisuals, visuals))
+ return FALSE;
+ /* MI thinks there's no frame buffer */
+#ifdef MITSHM
+ ShmRegisterFbFuncs(pScreen);
+#endif
+ pScreen->minInstalledCmaps = 1;
+ pScreen->maxInstalledCmaps = 2;
+
+ pScrPriv->nlayers = 2;
+ pScrPriv->PaintKey = fbOverlayPaintKey;
+ pScrPriv->CopyWindow = fbCopyWindowProc;
+ pScrPriv->layer[0].u.init.pbits = pbits1;
+ pScrPriv->layer[0].u.init.width = width1;
+ pScrPriv->layer[0].u.init.depth = depth1;
+
+ pScrPriv->layer[1].u.init.pbits = pbits2;
+ pScrPriv->layer[1].u.init.width = width2;
+ pScrPriv->layer[1].u.init.depth = depth2;
+ dixSetPrivate(&pScreen->devPrivates, fbOverlayScreenPrivateKey, pScrPriv);
+
+ /* overwrite miCloseScreen with our own */
+ pScreen->CloseScreen = fbOverlayCloseScreen;
+ pScreen->CreateScreenResources = fbOverlayCreateScreenResources;
+ pScreen->CreateWindow = fbOverlayCreateWindow;
+ pScreen->WindowExposures = fbOverlayWindowExposures;
+ pScreen->CopyWindow = fbOverlayCopyWindow;
+ if (bpp == 24 && imagebpp == 32)
+ {
+ pScreen->ModifyPixmapHeader = fb24_32ModifyPixmapHeader;
+ pScreen->CreateScreenResources = fb24_32OverlayCreateScreenResources;
+ }
+
+ return TRUE;
+}
diff --git a/xorg-server/fb/fbpixmap.c b/xorg-server/fb/fbpixmap.c
index 155f1e134..a356c67b6 100644
--- a/xorg-server/fb/fbpixmap.c
+++ b/xorg-server/fb/fbpixmap.c
@@ -1,392 +1,390 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include "fb.h"
-
-PixmapPtr
-fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
- unsigned usage_hint)
-{
- PixmapPtr pPixmap;
- size_t datasize;
- size_t paddedWidth;
- int adjust;
- int base;
-
- paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
- if (paddedWidth / 4 > 32767 || height > 32767)
- return NullPixmap;
- datasize = height * paddedWidth;
- base = pScreen->totalPixmapSize;
- adjust = 0;
- if (base & 7)
- adjust = 8 - (base & 7);
- datasize += adjust;
-#ifdef FB_DEBUG
- datasize += 2 * paddedWidth;
-#endif
- pPixmap = AllocatePixmap(pScreen, datasize);
- if (!pPixmap)
- return NullPixmap;
- pPixmap->drawable.type = DRAWABLE_PIXMAP;
- pPixmap->drawable.class = 0;
- pPixmap->drawable.pScreen = pScreen;
- pPixmap->drawable.depth = depth;
- pPixmap->drawable.bitsPerPixel = bpp;
- 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;
- pPixmap->devKind = paddedWidth;
- pPixmap->refcnt = 1;
- pPixmap->devPrivate.ptr = (pointer) ((char *)pPixmap + base + adjust);
-
-#ifdef FB_DEBUG
- pPixmap->devPrivate.ptr = (void *) ((char *) pPixmap->devPrivate.ptr + paddedWidth);
- fbInitializeDrawable (&pPixmap->drawable);
-#endif
-
-#ifdef COMPOSITE
- pPixmap->screen_x = 0;
- pPixmap->screen_y = 0;
-#endif
-
- pPixmap->usage_hint = usage_hint;
-
- return pPixmap;
-}
-
-PixmapPtr
-fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth,
- unsigned usage_hint)
-{
- int bpp;
- bpp = BitsPerPixel (depth);
-#ifdef FB_SCREEN_PRIVATE
- if (bpp == 32 && depth <= 24)
- bpp = fbGetScreenPrivate(pScreen)->pix32bpp;
-#endif
- return fbCreatePixmapBpp (pScreen, width, height, depth, bpp, usage_hint);
-}
-
-Bool
-fbDestroyPixmap (PixmapPtr pPixmap)
-{
- if(--pPixmap->refcnt)
- return TRUE;
- FreePixmap(pPixmap);
- return TRUE;
-}
-
-#define ADDRECT(reg,r,fr,rx1,ry1,rx2,ry2) \
-if (((rx1) < (rx2)) && ((ry1) < (ry2)) && \
- (!((reg)->data->numRects && \
- ((r-1)->y1 == (ry1)) && \
- ((r-1)->y2 == (ry2)) && \
- ((r-1)->x1 <= (rx1)) && \
- ((r-1)->x2 >= (rx2))))) \
-{ \
- if ((reg)->data->numRects == (reg)->data->size) \
- { \
- RegionRectAlloc(reg, 1); \
- fr = RegionBoxptr(reg); \
- r = fr + (reg)->data->numRects; \
- } \
- r->x1 = (rx1); \
- r->y1 = (ry1); \
- r->x2 = (rx2); \
- r->y2 = (ry2); \
- (reg)->data->numRects++; \
- if(r->x1 < (reg)->extents.x1) \
- (reg)->extents.x1 = r->x1; \
- if(r->x2 > (reg)->extents.x2) \
- (reg)->extents.x2 = r->x2; \
- r++; \
-}
-
-/* Convert bitmap clip mask into clipping region.
- * First, goes through each line and makes boxes by noting the transitions
- * from 0 to 1 and 1 to 0.
- * Then it coalesces the current line with the previous if they have boxes
- * at the same X coordinates.
- */
-RegionPtr
-fbPixmapToRegion(PixmapPtr pPix)
-{
- register RegionPtr pReg;
- FbBits *pw, w;
- register int ib;
- int width, h, base, rx1 = 0, crects;
- FbBits *pwLineEnd;
- int irectPrevStart, irectLineStart;
- register BoxPtr prectO, prectN;
- BoxPtr FirstRect, rects, prectLineStart;
- Bool fInBox, fSame;
- register FbBits mask0 = FB_ALLONES & ~FbScrRight(FB_ALLONES, 1);
- FbBits *pwLine;
- int nWidth;
-
- pReg = RegionCreate(NULL, 1);
- if(!pReg)
- return NullRegion;
- FirstRect = RegionBoxptr(pReg);
- rects = FirstRect;
-
- fbPrepareAccess(&pPix->drawable);
-
- pwLine = (FbBits *) pPix->devPrivate.ptr;
- nWidth = pPix->devKind >> (FB_SHIFT-3);
-
- width = pPix->drawable.width;
- pReg->extents.x1 = width - 1;
- pReg->extents.x2 = 0;
- irectPrevStart = -1;
- for(h = 0; h < pPix->drawable.height; h++)
- {
- pw = pwLine;
- pwLine += nWidth;
- irectLineStart = rects - FirstRect;
- /* If the Screen left most bit of the word is set, we're starting in
- * a box */
- if(READ(pw) & mask0)
- {
- fInBox = TRUE;
- rx1 = 0;
- }
- else
- fInBox = FALSE;
- /* Process all words which are fully in the pixmap */
- pwLineEnd = pw + (width >> FB_SHIFT);
- for (base = 0; pw < pwLineEnd; base += FB_UNIT)
- {
- w = READ(pw++);
- if (fInBox)
- {
- if (!~w)
- continue;
- }
- else
- {
- if (!w)
- continue;
- }
- for(ib = 0; ib < FB_UNIT; ib++)
- {
- /* If the Screen left most bit of the word is set, we're
- * starting a box */
- if(w & mask0)
- {
- if(!fInBox)
- {
- rx1 = base + ib;
- /* start new box */
- fInBox = TRUE;
- }
- }
- else
- {
- if(fInBox)
- {
- /* end box */
- ADDRECT(pReg, rects, FirstRect,
- rx1, h, base + ib, h + 1);
- fInBox = FALSE;
- }
- }
- /* Shift the word VISUALLY left one. */
- w = FbScrLeft(w, 1);
- }
- }
- if(width & FB_MASK)
- {
- /* Process final partial word on line */
- w = READ(pw++);
- for(ib = 0; ib < (width & FB_MASK); ib++)
- {
- /* If the Screen left most bit of the word is set, we're
- * starting a box */
- if(w & mask0)
- {
- if(!fInBox)
- {
- rx1 = base + ib;
- /* start new box */
- fInBox = TRUE;
- }
- }
- else
- {
- if(fInBox)
- {
- /* end box */
- ADDRECT(pReg, rects, FirstRect,
- rx1, h, base + ib, h + 1);
- fInBox = FALSE;
- }
- }
- /* Shift the word VISUALLY left one. */
- w = FbScrLeft(w, 1);
- }
- }
- /* If scanline ended with last bit set, end the box */
- if(fInBox)
- {
- ADDRECT(pReg, rects, FirstRect,
- rx1, h, base + (width & FB_MASK), h + 1);
- }
- /* if all rectangles on this line have the same x-coords as
- * those on the previous line, then add 1 to all the previous y2s and
- * throw away all the rectangles from this line
- */
- fSame = FALSE;
- if(irectPrevStart != -1)
- {
- crects = irectLineStart - irectPrevStart;
- if(crects == ((rects - FirstRect) - irectLineStart))
- {
- prectO = FirstRect + irectPrevStart;
- prectN = prectLineStart = FirstRect + irectLineStart;
- fSame = TRUE;
- while(prectO < prectLineStart)
- {
- if((prectO->x1 != prectN->x1) || (prectO->x2 != prectN->x2))
- {
- fSame = FALSE;
- break;
- }
- prectO++;
- prectN++;
- }
- if (fSame)
- {
- prectO = FirstRect + irectPrevStart;
- while(prectO < prectLineStart)
- {
- prectO->y2 += 1;
- prectO++;
- }
- rects -= crects;
- pReg->data->numRects -= crects;
- }
- }
- }
- if(!fSame)
- irectPrevStart = irectLineStart;
- }
- if (!pReg->data->numRects)
- pReg->extents.x1 = pReg->extents.x2 = 0;
- else
- {
- pReg->extents.y1 = RegionBoxptr(pReg)->y1;
- pReg->extents.y2 = RegionEnd(pReg)->y2;
- if (pReg->data->numRects == 1)
- {
- free(pReg->data);
- pReg->data = (RegDataPtr)NULL;
- }
- }
-
- fbFinishAccess(&pPix->drawable);
-#ifdef DEBUG
- if (!RegionIsValid(pReg))
- FatalError("Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__);
-#endif
- return pReg;
-}
-
-#ifdef FB_DEBUG
-
-#ifndef WIN32
-#include <stdio.h>
-#else
-#include <dbg.h>
-#endif
-
-static Bool
-fbValidateBits (FbStip *bits, int stride, FbStip data)
-{
- while (stride--)
- {
- if (*bits != data)
- {
-#ifdef WIN32
- NCD_DEBUG ((DEBUG_FAILURE, "fdValidateBits failed at 0x%x (is 0x%x want 0x%x)",
- bits, *bits, data));
-#else
- fprintf (stderr, "fbValidateBits failed\n");
-#endif
- return FALSE;
- }
- bits++;
- }
-}
-
-void
-fbValidateDrawable (DrawablePtr pDrawable)
-{
- FbStip *bits, *first, *last;
- int stride, bpp;
- int xoff, yoff;
- int height;
- Bool failed;
-
- if (pDrawable->type != DRAWABLE_PIXMAP)
- pDrawable = (DrawablePtr) fbGetWindowPixmap(pDrawable);
- fbGetStipDrawable(pDrawable, bits, stride, bpp, xoff, yoff);
- first = bits - stride;
- last = bits + stride * pDrawable->height;
- if (!fbValidateBits (first, stride, FB_HEAD_BITS) ||
- !fbValidateBits (last, stride, FB_TAIL_BITS))
- fbInitializeDrawable(pDrawable);
- fbFinishAccess (pDrawable);
-}
-
-void
-fbSetBits (FbStip *bits, int stride, FbStip data)
-{
- while (stride--)
- *bits++ = data;
-}
-
-void
-fbInitializeDrawable (DrawablePtr pDrawable)
-{
- FbStip *bits, *first, *last;
- int stride, bpp;
- int xoff, yoff;
-
- fbGetStipDrawable(pDrawable, bits, stride, bpp, xoff, yoff);
- first = bits - stride;
- last = bits + stride * pDrawable->height;
- fbSetBits (first, stride, FB_HEAD_BITS);
- fbSetBits (last, stride, FB_TAIL_BITS);
- fbFinishAccess (pDrawable);
-}
-#endif /* FB_DEBUG */
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "fb.h"
+
+PixmapPtr
+fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
+ unsigned usage_hint)
+{
+ PixmapPtr pPixmap;
+ size_t datasize;
+ size_t paddedWidth;
+ int adjust;
+ int base;
+
+ paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
+ if (paddedWidth / 4 > 32767 || height > 32767)
+ return NullPixmap;
+ datasize = height * paddedWidth;
+ base = pScreen->totalPixmapSize;
+ adjust = 0;
+ if (base & 7)
+ adjust = 8 - (base & 7);
+ datasize += adjust;
+#ifdef FB_DEBUG
+ datasize += 2 * paddedWidth;
+#endif
+ pPixmap = AllocatePixmap(pScreen, datasize);
+ if (!pPixmap)
+ return NullPixmap;
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = bpp;
+ 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;
+ pPixmap->devKind = paddedWidth;
+ pPixmap->refcnt = 1;
+ pPixmap->devPrivate.ptr = (pointer) ((char *)pPixmap + base + adjust);
+
+#ifdef FB_DEBUG
+ pPixmap->devPrivate.ptr = (void *) ((char *) pPixmap->devPrivate.ptr + paddedWidth);
+ fbInitializeDrawable (&pPixmap->drawable);
+#endif
+
+#ifdef COMPOSITE
+ pPixmap->screen_x = 0;
+ pPixmap->screen_y = 0;
+#endif
+
+ pPixmap->usage_hint = usage_hint;
+
+ return pPixmap;
+}
+
+PixmapPtr
+fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth,
+ unsigned usage_hint)
+{
+ int bpp;
+ bpp = BitsPerPixel (depth);
+ if (bpp == 32 && depth <= 24)
+ bpp = fbGetScreenPrivate(pScreen)->pix32bpp;
+ return fbCreatePixmapBpp (pScreen, width, height, depth, bpp, usage_hint);
+}
+
+Bool
+fbDestroyPixmap (PixmapPtr pPixmap)
+{
+ if(--pPixmap->refcnt)
+ return TRUE;
+ FreePixmap(pPixmap);
+ return TRUE;
+}
+
+#define ADDRECT(reg,r,fr,rx1,ry1,rx2,ry2) \
+if (((rx1) < (rx2)) && ((ry1) < (ry2)) && \
+ (!((reg)->data->numRects && \
+ ((r-1)->y1 == (ry1)) && \
+ ((r-1)->y2 == (ry2)) && \
+ ((r-1)->x1 <= (rx1)) && \
+ ((r-1)->x2 >= (rx2))))) \
+{ \
+ if ((reg)->data->numRects == (reg)->data->size) \
+ { \
+ RegionRectAlloc(reg, 1); \
+ fr = RegionBoxptr(reg); \
+ r = fr + (reg)->data->numRects; \
+ } \
+ r->x1 = (rx1); \
+ r->y1 = (ry1); \
+ r->x2 = (rx2); \
+ r->y2 = (ry2); \
+ (reg)->data->numRects++; \
+ if(r->x1 < (reg)->extents.x1) \
+ (reg)->extents.x1 = r->x1; \
+ if(r->x2 > (reg)->extents.x2) \
+ (reg)->extents.x2 = r->x2; \
+ r++; \
+}
+
+/* Convert bitmap clip mask into clipping region.
+ * First, goes through each line and makes boxes by noting the transitions
+ * from 0 to 1 and 1 to 0.
+ * Then it coalesces the current line with the previous if they have boxes
+ * at the same X coordinates.
+ */
+RegionPtr
+fbPixmapToRegion(PixmapPtr pPix)
+{
+ register RegionPtr pReg;
+ FbBits *pw, w;
+ register int ib;
+ int width, h, base, rx1 = 0, crects;
+ FbBits *pwLineEnd;
+ int irectPrevStart, irectLineStart;
+ register BoxPtr prectO, prectN;
+ BoxPtr FirstRect, rects, prectLineStart;
+ Bool fInBox, fSame;
+ register FbBits mask0 = FB_ALLONES & ~FbScrRight(FB_ALLONES, 1);
+ FbBits *pwLine;
+ int nWidth;
+
+ pReg = RegionCreate(NULL, 1);
+ if(!pReg)
+ return NullRegion;
+ FirstRect = RegionBoxptr(pReg);
+ rects = FirstRect;
+
+ fbPrepareAccess(&pPix->drawable);
+
+ pwLine = (FbBits *) pPix->devPrivate.ptr;
+ nWidth = pPix->devKind >> (FB_SHIFT-3);
+
+ width = pPix->drawable.width;
+ pReg->extents.x1 = width - 1;
+ pReg->extents.x2 = 0;
+ irectPrevStart = -1;
+ for(h = 0; h < pPix->drawable.height; h++)
+ {
+ pw = pwLine;
+ pwLine += nWidth;
+ irectLineStart = rects - FirstRect;
+ /* If the Screen left most bit of the word is set, we're starting in
+ * a box */
+ if(READ(pw) & mask0)
+ {
+ fInBox = TRUE;
+ rx1 = 0;
+ }
+ else
+ fInBox = FALSE;
+ /* Process all words which are fully in the pixmap */
+ pwLineEnd = pw + (width >> FB_SHIFT);
+ for (base = 0; pw < pwLineEnd; base += FB_UNIT)
+ {
+ w = READ(pw++);
+ if (fInBox)
+ {
+ if (!~w)
+ continue;
+ }
+ else
+ {
+ if (!w)
+ continue;
+ }
+ for(ib = 0; ib < FB_UNIT; ib++)
+ {
+ /* If the Screen left most bit of the word is set, we're
+ * starting a box */
+ if(w & mask0)
+ {
+ if(!fInBox)
+ {
+ rx1 = base + ib;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ /* end box */
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + ib, h + 1);
+ fInBox = FALSE;
+ }
+ }
+ /* Shift the word VISUALLY left one. */
+ w = FbScrLeft(w, 1);
+ }
+ }
+ if(width & FB_MASK)
+ {
+ /* Process final partial word on line */
+ w = READ(pw++);
+ for(ib = 0; ib < (width & FB_MASK); ib++)
+ {
+ /* If the Screen left most bit of the word is set, we're
+ * starting a box */
+ if(w & mask0)
+ {
+ if(!fInBox)
+ {
+ rx1 = base + ib;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ /* end box */
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + ib, h + 1);
+ fInBox = FALSE;
+ }
+ }
+ /* Shift the word VISUALLY left one. */
+ w = FbScrLeft(w, 1);
+ }
+ }
+ /* If scanline ended with last bit set, end the box */
+ if(fInBox)
+ {
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + (width & FB_MASK), h + 1);
+ }
+ /* if all rectangles on this line have the same x-coords as
+ * those on the previous line, then add 1 to all the previous y2s and
+ * throw away all the rectangles from this line
+ */
+ fSame = FALSE;
+ if(irectPrevStart != -1)
+ {
+ crects = irectLineStart - irectPrevStart;
+ if(crects == ((rects - FirstRect) - irectLineStart))
+ {
+ prectO = FirstRect + irectPrevStart;
+ prectN = prectLineStart = FirstRect + irectLineStart;
+ fSame = TRUE;
+ while(prectO < prectLineStart)
+ {
+ if((prectO->x1 != prectN->x1) || (prectO->x2 != prectN->x2))
+ {
+ fSame = FALSE;
+ break;
+ }
+ prectO++;
+ prectN++;
+ }
+ if (fSame)
+ {
+ prectO = FirstRect + irectPrevStart;
+ while(prectO < prectLineStart)
+ {
+ prectO->y2 += 1;
+ prectO++;
+ }
+ rects -= crects;
+ pReg->data->numRects -= crects;
+ }
+ }
+ }
+ if(!fSame)
+ irectPrevStart = irectLineStart;
+ }
+ if (!pReg->data->numRects)
+ pReg->extents.x1 = pReg->extents.x2 = 0;
+ else
+ {
+ pReg->extents.y1 = RegionBoxptr(pReg)->y1;
+ pReg->extents.y2 = RegionEnd(pReg)->y2;
+ if (pReg->data->numRects == 1)
+ {
+ free(pReg->data);
+ pReg->data = (RegDataPtr)NULL;
+ }
+ }
+
+ fbFinishAccess(&pPix->drawable);
+#ifdef DEBUG
+ if (!RegionIsValid(pReg))
+ FatalError("Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__);
+#endif
+ return pReg;
+}
+
+#ifdef FB_DEBUG
+
+#ifndef WIN32
+#include <stdio.h>
+#else
+#include <dbg.h>
+#endif
+
+static Bool
+fbValidateBits (FbStip *bits, int stride, FbStip data)
+{
+ while (stride--)
+ {
+ if (*bits != data)
+ {
+#ifdef WIN32
+ NCD_DEBUG ((DEBUG_FAILURE, "fdValidateBits failed at 0x%x (is 0x%x want 0x%x)",
+ bits, *bits, data));
+#else
+ fprintf (stderr, "fbValidateBits failed\n");
+#endif
+ return FALSE;
+ }
+ bits++;
+ }
+}
+
+void
+fbValidateDrawable (DrawablePtr pDrawable)
+{
+ FbStip *bits, *first, *last;
+ int stride, bpp;
+ int xoff, yoff;
+ int height;
+ Bool failed;
+
+ if (pDrawable->type != DRAWABLE_PIXMAP)
+ pDrawable = (DrawablePtr) fbGetWindowPixmap(pDrawable);
+ fbGetStipDrawable(pDrawable, bits, stride, bpp, xoff, yoff);
+ first = bits - stride;
+ last = bits + stride * pDrawable->height;
+ if (!fbValidateBits (first, stride, FB_HEAD_BITS) ||
+ !fbValidateBits (last, stride, FB_TAIL_BITS))
+ fbInitializeDrawable(pDrawable);
+ fbFinishAccess (pDrawable);
+}
+
+void
+fbSetBits (FbStip *bits, int stride, FbStip data)
+{
+ while (stride--)
+ *bits++ = data;
+}
+
+void
+fbInitializeDrawable (DrawablePtr pDrawable)
+{
+ FbStip *bits, *first, *last;
+ int stride, bpp;
+ int xoff, yoff;
+
+ fbGetStipDrawable(pDrawable, bits, stride, bpp, xoff, yoff);
+ first = bits - stride;
+ last = bits + stride * pDrawable->height;
+ fbSetBits (first, stride, FB_HEAD_BITS);
+ fbSetBits (last, stride, FB_TAIL_BITS);
+ fbFinishAccess (pDrawable);
+}
+#endif /* FB_DEBUG */
diff --git a/xorg-server/fb/fbpoint.c b/xorg-server/fb/fbpoint.c
index d675dbaff..bf617708b 100644
--- a/xorg-server/fb/fbpoint.c
+++ b/xorg-server/fb/fbpoint.c
@@ -1,162 +1,156 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-typedef void (*FbDots) (FbBits *dst,
- FbStride dstStride,
- int dstBpp,
- BoxPtr pBox,
- xPoint *pts,
- int npt,
- int xorg,
- int yorg,
- int xoff,
- int yoff,
- FbBits and,
- FbBits xor);
-
-void
-fbDots (FbBits *dstOrig,
- FbStride dstStride,
- int dstBpp,
- BoxPtr pBox,
- xPoint *pts,
- int npt,
- int xorg,
- int yorg,
- int xoff,
- int yoff,
- FbBits andOrig,
- FbBits xorOrig)
-{
- FbStip *dst = (FbStip *) dstOrig;
- int x1, y1, x2, y2;
- int x, y;
- FbStip *d;
- FbStip and = andOrig;
- FbStip xor = xorOrig;
-
- dstStride = FbBitsStrideToStipStride (dstStride);
- x1 = pBox->x1;
- y1 = pBox->y1;
- x2 = pBox->x2;
- y2 = pBox->y2;
- while (npt--)
- {
- x = pts->x + xorg;
- y = pts->y + yorg;
- pts++;
- if (x1 <= x && x < x2 && y1 <= y && y < y2)
- {
- x = (x + xoff) * dstBpp;
- d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT);
- x &= FB_STIP_MASK;
-#ifdef FB_24BIT
- if (dstBpp == 24)
- {
- FbStip leftMask, rightMask;
- int n, rot;
- FbStip andT, xorT;
-
- rot = FbFirst24Rot (x);
- andT = FbRot24Stip(and,rot);
- xorT = FbRot24Stip(xor,rot);
- FbMaskStip (x, 24, leftMask, n, rightMask);
- if (leftMask)
- {
- WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask));
- andT = FbNext24Stip(andT);
- xorT = FbNext24Stip(xorT);
- d++;
- }
- if (rightMask)
- WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, rightMask));
- }
- else
-#endif
- {
- FbStip mask;
- mask = FbStipMask(x, dstBpp);
- WRITE(d, FbDoMaskRRop (READ(d), and, xor, mask));
- }
- }
- }
-}
-
-void
-fbPolyPoint (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int nptInit,
- xPoint *pptInit)
-{
- FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
- RegionPtr pClip = fbGetCompositeClip(pGC);
- FbBits *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- FbDots dots;
- FbBits and, xor;
- xPoint *ppt;
- int npt;
- BoxPtr pBox;
- int nBox;
-
- /* make pointlist origin relative */
- ppt = pptInit;
- npt = nptInit;
- if (mode == CoordModePrevious)
- {
- npt--;
- while(npt--)
- {
- ppt++;
- ppt->x += (ppt-1)->x;
- ppt->y += (ppt-1)->y;
- }
- }
- fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
- and = pPriv->and;
- xor = pPriv->xor;
- dots = fbDots;
-#ifndef FBNOPIXADDR
- switch (dstBpp) {
- case 8: dots = fbDots8; break;
- case 16: dots = fbDots16; break;
-#ifdef FB_24BIT
- case 24: dots = fbDots24; break;
-#endif
- case 32: dots = fbDots32; break;
- }
-#endif
- for (nBox = RegionNumRects (pClip), pBox = RegionRects (pClip);
- nBox--; pBox++)
- (*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit,
- pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor);
- fbFinishAccess (pDrawable);
-}
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+typedef void (*FbDots) (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+void
+fbDots (FbBits *dstOrig,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits andOrig,
+ FbBits xorOrig)
+{
+ FbStip *dst = (FbStip *) dstOrig;
+ int x1, y1, x2, y2;
+ int x, y;
+ FbStip *d;
+ FbStip and = andOrig;
+ FbStip xor = xorOrig;
+
+ dstStride = FbBitsStrideToStipStride (dstStride);
+ x1 = pBox->x1;
+ y1 = pBox->y1;
+ x2 = pBox->x2;
+ y2 = pBox->y2;
+ while (npt--)
+ {
+ x = pts->x + xorg;
+ y = pts->y + yorg;
+ pts++;
+ if (x1 <= x && x < x2 && y1 <= y && y < y2)
+ {
+ x = (x + xoff) * dstBpp;
+ d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT);
+ x &= FB_STIP_MASK;
+ if (dstBpp == 24)
+ {
+ FbStip leftMask, rightMask;
+ int n, rot;
+ FbStip andT, xorT;
+
+ rot = FbFirst24Rot (x);
+ andT = FbRot24Stip(and,rot);
+ xorT = FbRot24Stip(xor,rot);
+ FbMaskStip (x, 24, leftMask, n, rightMask);
+ if (leftMask)
+ {
+ WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask));
+ andT = FbNext24Stip(andT);
+ xorT = FbNext24Stip(xorT);
+ d++;
+ }
+ if (rightMask)
+ WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, rightMask));
+ }
+ else
+ {
+ FbStip mask;
+ mask = FbStipMask(x, dstBpp);
+ WRITE(d, FbDoMaskRRop (READ(d), and, xor, mask));
+ }
+ }
+ }
+}
+
+void
+fbPolyPoint (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nptInit,
+ xPoint *pptInit)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbDots dots;
+ FbBits and, xor;
+ xPoint *ppt;
+ int npt;
+ BoxPtr pBox;
+ int nBox;
+
+ /* make pointlist origin relative */
+ ppt = pptInit;
+ npt = nptInit;
+ if (mode == CoordModePrevious)
+ {
+ npt--;
+ while(npt--)
+ {
+ ppt++;
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+ }
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ and = pPriv->and;
+ xor = pPriv->xor;
+ dots = fbDots;
+ switch (dstBpp) {
+ case 8: dots = fbDots8; break;
+ case 16: dots = fbDots16; break;
+ case 24: dots = fbDots24; break;
+ case 32: dots = fbDots32; break;
+ }
+ for (nBox = RegionNumRects (pClip), pBox = RegionRects (pClip);
+ nBox--; pBox++)
+ (*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit,
+ pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor);
+ fbFinishAccess (pDrawable);
+}
diff --git a/xorg-server/fb/fbscreen.c b/xorg-server/fb/fbscreen.c
index f6eda6d64..fa518f64a 100644
--- a/xorg-server/fb/fbscreen.c
+++ b/xorg-server/fb/fbscreen.c
@@ -1,288 +1,282 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-Bool
-fbCloseScreen (int index, ScreenPtr pScreen)
-{
- int d;
- DepthPtr depths = pScreen->allowedDepths;
-
- for (d = 0; d < pScreen->numDepths; d++)
- free(depths[d].vids);
- free(depths);
- free(pScreen->visuals);
- free(pScreen->devPrivate);
- return TRUE;
-}
-
-Bool
-fbRealizeFont(ScreenPtr pScreen, FontPtr pFont)
-{
- return TRUE;
-}
-
-Bool
-fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
-{
- return TRUE;
-}
-
-void
-fbQueryBestSize (int class,
- unsigned short *width, unsigned short *height,
- ScreenPtr pScreen)
-{
- unsigned short w;
-
- switch (class) {
- case CursorShape:
- if (*width > pScreen->width)
- *width = pScreen->width;
- if (*height > pScreen->height)
- *height = pScreen->height;
- break;
- case TileShape:
- case StippleShape:
- w = *width;
- if ((w & (w - 1)) && w < FB_UNIT)
- {
- for (w = 1; w < *width; w <<= 1)
- ;
- *width = w;
- }
- }
-}
-
-PixmapPtr
-_fbGetWindowPixmap (WindowPtr pWindow)
-{
- return fbGetWindowPixmap (pWindow);
-}
-
-void
-_fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
-{
- dixSetPrivate(&pWindow->devPrivates, fbGetWinPrivateKey(), pPixmap);
-}
-
-Bool
-fbSetupScreen(ScreenPtr pScreen,
- pointer pbits, /* pointer to screen bitmap */
- int xsize, /* in pixels */
- int ysize,
- int dpix, /* dots per inch */
- int dpiy,
- int width, /* pixel width of frame buffer */
- int bpp) /* bits per pixel for screen */
-{
- if (!fbAllocatePrivates(pScreen, NULL))
- return FALSE;
- pScreen->defColormap = FakeClientID(0);
- /* let CreateDefColormap do whatever it wants for pixels */
- pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
- pScreen->QueryBestSize = fbQueryBestSize;
- /* SaveScreen */
- pScreen->GetImage = fbGetImage;
- pScreen->GetSpans = fbGetSpans;
- pScreen->CreateWindow = fbCreateWindow;
- pScreen->DestroyWindow = fbDestroyWindow;
- pScreen->PositionWindow = fbPositionWindow;
- pScreen->ChangeWindowAttributes = fbChangeWindowAttributes;
- pScreen->RealizeWindow = fbMapWindow;
- pScreen->UnrealizeWindow = fbUnmapWindow;
- pScreen->CopyWindow = fbCopyWindow;
- pScreen->CreatePixmap = fbCreatePixmap;
- pScreen->DestroyPixmap = fbDestroyPixmap;
- pScreen->RealizeFont = fbRealizeFont;
- pScreen->UnrealizeFont = fbUnrealizeFont;
- pScreen->CreateGC = fbCreateGC;
- pScreen->CreateColormap = fbInitializeColormap;
- pScreen->DestroyColormap = (void (*)(ColormapPtr))NoopDDA;
- pScreen->InstallColormap = fbInstallColormap;
- pScreen->UninstallColormap = fbUninstallColormap;
- pScreen->ListInstalledColormaps = fbListInstalledColormaps;
- pScreen->StoreColors = (void (*)(ColormapPtr, int, xColorItem *))NoopDDA;
- pScreen->ResolveColor = fbResolveColor;
- pScreen->BitmapToRegion = fbPixmapToRegion;
-
- pScreen->GetWindowPixmap = _fbGetWindowPixmap;
- pScreen->SetWindowPixmap = _fbSetWindowPixmap;
-
- return TRUE;
-}
-
-#ifdef FB_ACCESS_WRAPPER
-Bool
-wfbFinishScreenInit(ScreenPtr pScreen,
- pointer pbits,
- int xsize,
- int ysize,
- int dpix,
- int dpiy,
- int width,
- int bpp,
- SetupWrapProcPtr setupWrap,
- FinishWrapProcPtr finishWrap)
-#else
-Bool
-fbFinishScreenInit(ScreenPtr pScreen,
- pointer pbits,
- int xsize,
- int ysize,
- int dpix,
- int dpiy,
- int width,
- int bpp)
-#endif
-{
- VisualPtr visuals;
- DepthPtr depths;
- int nvisuals;
- int ndepths;
- int rootdepth;
- VisualID defaultVisual;
- int imagebpp = bpp;
-
-#ifdef FB_DEBUG
- int stride;
-
- ysize -= 2;
- stride = (width * bpp) / 8;
- fbSetBits ((FbStip *) pbits,
- stride / sizeof (FbStip), FB_HEAD_BITS);
- pbits = (void *) ((char *) pbits + stride);
- fbSetBits ((FbStip *) ((char *) pbits + stride * ysize),
- stride / sizeof (FbStip), FB_TAIL_BITS);
-#endif
- /*
- * By default, a 24bpp screen will use 32bpp images, this avoids
- * problems with many applications which just can't handle packed
- * pixels. If you want real 24bit images, include a 24bpp
- * format in the pixmap formats
- */
-#ifdef FB_24_32BIT
- if (bpp == 24)
- {
- int f;
-
- imagebpp = 32;
- /*
- * Check to see if we're advertising a 24bpp image format,
- * in which case windows will use it in preference to a 32 bit
- * format.
- */
- for (f = 0; f < screenInfo.numPixmapFormats; f++)
- {
- if (screenInfo.formats[f].bitsPerPixel == 24)
- {
- imagebpp = 24;
- break;
- }
- }
- }
-#endif
-#ifdef FB_SCREEN_PRIVATE
- if (imagebpp == 32)
- {
- fbGetScreenPrivate(pScreen)->win32bpp = bpp;
- fbGetScreenPrivate(pScreen)->pix32bpp = bpp;
- }
- else
- {
- fbGetScreenPrivate(pScreen)->win32bpp = 32;
- fbGetScreenPrivate(pScreen)->pix32bpp = 32;
- }
-#ifdef FB_ACCESS_WRAPPER
- fbGetScreenPrivate(pScreen)->setupWrap = setupWrap;
- fbGetScreenPrivate(pScreen)->finishWrap = finishWrap;
-#endif
-#endif
- rootdepth = 0;
- if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
- &defaultVisual,((unsigned long)1<<(imagebpp-1)), 8))
- {
- free(visuals);
- free(depths);
- return FALSE;
- }
- if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
- rootdepth, ndepths, depths,
- defaultVisual, nvisuals, visuals))
- return FALSE;
- /* overwrite miCloseScreen with our own */
- pScreen->CloseScreen = fbCloseScreen;
-#ifdef FB_24_32BIT
- if (bpp == 24 && imagebpp == 32)
- {
- pScreen->ModifyPixmapHeader = fb24_32ModifyPixmapHeader;
- pScreen->CreateScreenResources = fb24_32CreateScreenResources;
- }
-#endif
- return TRUE;
-}
-
-/* dts * (inch/dot) * (25.4 mm / inch) = mm */
-#ifdef FB_ACCESS_WRAPPER
-Bool
-wfbScreenInit(ScreenPtr pScreen,
- pointer pbits,
- int xsize,
- int ysize,
- int dpix,
- int dpiy,
- int width,
- int bpp,
- SetupWrapProcPtr setupWrap,
- FinishWrapProcPtr finishWrap)
-{
- if (!fbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp))
- return FALSE;
- if (!wfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy,
- width, bpp, setupWrap, finishWrap))
- return FALSE;
- return TRUE;
-}
-#else
-Bool
-fbScreenInit(ScreenPtr pScreen,
- pointer pbits,
- int xsize,
- int ysize,
- int dpix,
- int dpiy,
- int width,
- int bpp)
-{
- if (!fbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp))
- return FALSE;
- if (!fbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy,
- width, bpp))
- return FALSE;
- return TRUE;
-}
-#endif
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+Bool
+fbCloseScreen (int index, ScreenPtr pScreen)
+{
+ int d;
+ DepthPtr depths = pScreen->allowedDepths;
+
+ for (d = 0; d < pScreen->numDepths; d++)
+ free(depths[d].vids);
+ free(depths);
+ free(pScreen->visuals);
+ free(pScreen->devPrivate);
+ return TRUE;
+}
+
+Bool
+fbRealizeFont(ScreenPtr pScreen, FontPtr pFont)
+{
+ return TRUE;
+}
+
+Bool
+fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
+{
+ return TRUE;
+}
+
+void
+fbQueryBestSize (int class,
+ unsigned short *width, unsigned short *height,
+ ScreenPtr pScreen)
+{
+ unsigned short w;
+
+ switch (class) {
+ case CursorShape:
+ if (*width > pScreen->width)
+ *width = pScreen->width;
+ if (*height > pScreen->height)
+ *height = pScreen->height;
+ break;
+ case TileShape:
+ case StippleShape:
+ w = *width;
+ if ((w & (w - 1)) && w < FB_UNIT)
+ {
+ for (w = 1; w < *width; w <<= 1)
+ ;
+ *width = w;
+ }
+ }
+}
+
+PixmapPtr
+_fbGetWindowPixmap (WindowPtr pWindow)
+{
+ return fbGetWindowPixmap (pWindow);
+}
+
+void
+_fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
+{
+ dixSetPrivate(&pWindow->devPrivates, fbGetWinPrivateKey(), pPixmap);
+}
+
+Bool
+fbSetupScreen(ScreenPtr pScreen,
+ pointer pbits, /* pointer to screen bitmap */
+ int xsize, /* in pixels */
+ int ysize,
+ int dpix, /* dots per inch */
+ int dpiy,
+ int width, /* pixel width of frame buffer */
+ int bpp) /* bits per pixel for screen */
+{
+ if (!fbAllocatePrivates(pScreen, NULL))
+ return FALSE;
+ pScreen->defColormap = FakeClientID(0);
+ /* let CreateDefColormap do whatever it wants for pixels */
+ pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+ pScreen->QueryBestSize = fbQueryBestSize;
+ /* SaveScreen */
+ pScreen->GetImage = fbGetImage;
+ pScreen->GetSpans = fbGetSpans;
+ pScreen->CreateWindow = fbCreateWindow;
+ pScreen->DestroyWindow = fbDestroyWindow;
+ pScreen->PositionWindow = fbPositionWindow;
+ pScreen->ChangeWindowAttributes = fbChangeWindowAttributes;
+ pScreen->RealizeWindow = fbMapWindow;
+ pScreen->UnrealizeWindow = fbUnmapWindow;
+ pScreen->CopyWindow = fbCopyWindow;
+ pScreen->CreatePixmap = fbCreatePixmap;
+ pScreen->DestroyPixmap = fbDestroyPixmap;
+ pScreen->RealizeFont = fbRealizeFont;
+ pScreen->UnrealizeFont = fbUnrealizeFont;
+ pScreen->CreateGC = fbCreateGC;
+ pScreen->CreateColormap = fbInitializeColormap;
+ pScreen->DestroyColormap = (void (*)(ColormapPtr))NoopDDA;
+ pScreen->InstallColormap = fbInstallColormap;
+ pScreen->UninstallColormap = fbUninstallColormap;
+ pScreen->ListInstalledColormaps = fbListInstalledColormaps;
+ pScreen->StoreColors = (void (*)(ColormapPtr, int, xColorItem *))NoopDDA;
+ pScreen->ResolveColor = fbResolveColor;
+ pScreen->BitmapToRegion = fbPixmapToRegion;
+
+ pScreen->GetWindowPixmap = _fbGetWindowPixmap;
+ pScreen->SetWindowPixmap = _fbSetWindowPixmap;
+
+ return TRUE;
+}
+
+#ifdef FB_ACCESS_WRAPPER
+Bool
+wfbFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp,
+ SetupWrapProcPtr setupWrap,
+ FinishWrapProcPtr finishWrap)
+#else
+Bool
+fbFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp)
+#endif
+{
+ VisualPtr visuals;
+ DepthPtr depths;
+ int nvisuals;
+ int ndepths;
+ int rootdepth;
+ VisualID defaultVisual;
+ int imagebpp = bpp;
+
+#ifdef FB_DEBUG
+ int stride;
+
+ ysize -= 2;
+ stride = (width * bpp) / 8;
+ fbSetBits ((FbStip *) pbits,
+ stride / sizeof (FbStip), FB_HEAD_BITS);
+ pbits = (void *) ((char *) pbits + stride);
+ fbSetBits ((FbStip *) ((char *) pbits + stride * ysize),
+ stride / sizeof (FbStip), FB_TAIL_BITS);
+#endif
+ /*
+ * By default, a 24bpp screen will use 32bpp images, this avoids
+ * problems with many applications which just can't handle packed
+ * pixels. If you want real 24bit images, include a 24bpp
+ * format in the pixmap formats
+ */
+ if (bpp == 24)
+ {
+ int f;
+
+ imagebpp = 32;
+ /*
+ * Check to see if we're advertising a 24bpp image format,
+ * in which case windows will use it in preference to a 32 bit
+ * format.
+ */
+ for (f = 0; f < screenInfo.numPixmapFormats; f++)
+ {
+ if (screenInfo.formats[f].bitsPerPixel == 24)
+ {
+ imagebpp = 24;
+ break;
+ }
+ }
+ }
+ if (imagebpp == 32)
+ {
+ fbGetScreenPrivate(pScreen)->win32bpp = bpp;
+ fbGetScreenPrivate(pScreen)->pix32bpp = bpp;
+ }
+ else
+ {
+ fbGetScreenPrivate(pScreen)->win32bpp = 32;
+ fbGetScreenPrivate(pScreen)->pix32bpp = 32;
+ }
+#ifdef FB_ACCESS_WRAPPER
+ fbGetScreenPrivate(pScreen)->setupWrap = setupWrap;
+ fbGetScreenPrivate(pScreen)->finishWrap = finishWrap;
+#endif
+ rootdepth = 0;
+ if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
+ &defaultVisual,((unsigned long)1<<(imagebpp-1)), 8))
+ {
+ free(visuals);
+ free(depths);
+ return FALSE;
+ }
+ if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+ rootdepth, ndepths, depths,
+ defaultVisual, nvisuals, visuals))
+ return FALSE;
+ /* overwrite miCloseScreen with our own */
+ pScreen->CloseScreen = fbCloseScreen;
+ if (bpp == 24 && imagebpp == 32)
+ {
+ pScreen->ModifyPixmapHeader = fb24_32ModifyPixmapHeader;
+ pScreen->CreateScreenResources = fb24_32CreateScreenResources;
+ }
+ return TRUE;
+}
+
+/* dts * (inch/dot) * (25.4 mm / inch) = mm */
+#ifdef FB_ACCESS_WRAPPER
+Bool
+wfbScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp,
+ SetupWrapProcPtr setupWrap,
+ FinishWrapProcPtr finishWrap)
+{
+ if (!fbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp))
+ return FALSE;
+ if (!wfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width, bpp, setupWrap, finishWrap))
+ return FALSE;
+ return TRUE;
+}
+#else
+Bool
+fbScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp)
+{
+ if (!fbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp))
+ return FALSE;
+ if (!fbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width, bpp))
+ return FALSE;
+ return TRUE;
+}
+#endif
diff --git a/xorg-server/fb/fbseg.c b/xorg-server/fb/fbseg.c
index 8a68857f7..5a458fe51 100644
--- a/xorg-server/fb/fbseg.c
+++ b/xorg-server/fb/fbseg.c
@@ -1,736 +1,722 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include "fb.h"
-#include "miline.h"
-
-#define fbBresShiftMask(mask,dir,bpp) ((bpp == FB_STIP_UNIT) ? 0 : \
- ((dir < 0) ? FbStipLeft(mask,bpp) : \
- FbStipRight(mask,bpp)))
-
-void
-fbBresSolid (DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x1,
- int y1,
- int e,
- int e1,
- int e3,
- int len)
-{
- FbStip *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
- FbStip and = (FbStip) pPriv->and;
- FbStip xor = (FbStip) pPriv->xor;
- FbStip mask, mask0;
- FbStip bits;
-
- fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
- dst += ((y1 + dstYoff) * dstStride);
- x1 = (x1 + dstXoff) * dstBpp;
- dst += x1 >> FB_STIP_SHIFT;
- x1 &= FB_STIP_MASK;
- mask0 = FbStipMask(0, dstBpp);
- mask = FbStipRight (mask0, x1);
- if (signdx < 0)
- mask0 = FbStipRight (mask0, FB_STIP_UNIT - dstBpp);
- if (signdy < 0)
- dstStride = -dstStride;
- if (axis == X_AXIS)
- {
- bits = 0;
- while (len--)
- {
- bits |= mask;
- mask = fbBresShiftMask(mask,signdx,dstBpp);
- if (!mask)
- {
- WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
- bits = 0;
- dst += signdx;
- mask = mask0;
- }
- e += e1;
- if (e >= 0)
- {
- WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
- bits = 0;
- dst += dstStride;
- e += e3;
- }
- }
- if (bits)
- WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
- }
- else
- {
- while (len--)
- {
- WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, mask));
- dst += dstStride;
- e += e1;
- if (e >= 0)
- {
- e += e3;
- mask = fbBresShiftMask(mask,signdx,dstBpp);
- if (!mask)
- {
- dst += signdx;
- mask = mask0;
- }
- }
- }
- }
-
- fbFinishAccess (pDrawable);
-}
-
-void
-fbBresDash (DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x1,
- int y1,
- int e,
- int e1,
- int e3,
- int len)
-{
- FbStip *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
- FbStip and = (FbStip) pPriv->and;
- FbStip xor = (FbStip) pPriv->xor;
- FbStip bgand = (FbStip) pPriv->bgand;
- FbStip bgxor = (FbStip) pPriv->bgxor;
- FbStip mask, mask0;
- FbDashDeclare;
- int dashlen;
- Bool even;
- Bool doOdd;
-
- fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
- doOdd = pGC->lineStyle == LineDoubleDash;
-
- FbDashInit (pGC, pPriv, dashOffset, dashlen, even);
-
- dst += ((y1 + dstYoff) * dstStride);
- x1 = (x1 + dstXoff) * dstBpp;
- dst += x1 >> FB_STIP_SHIFT;
- x1 &= FB_STIP_MASK;
- mask0 = FbStipMask(0, dstBpp);
- mask = FbStipRight (mask0, x1);
- if (signdx < 0)
- mask0 = FbStipRight (mask0, FB_STIP_UNIT - dstBpp);
- if (signdy < 0)
- dstStride = -dstStride;
- while (len--)
- {
- if (even)
- WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, mask));
- else if (doOdd)
- WRITE(dst, FbDoMaskRRop (READ(dst), bgand, bgxor, mask));
- if (axis == X_AXIS)
- {
- mask = fbBresShiftMask(mask,signdx,dstBpp);
- if (!mask)
- {
- dst += signdx;
- mask = mask0;
- }
- e += e1;
- if (e >= 0)
- {
- dst += dstStride;
- e += e3;
- }
- }
- else
- {
- dst += dstStride;
- e += e1;
- if (e >= 0)
- {
- e += e3;
- mask = fbBresShiftMask(mask,signdx,dstBpp);
- if (!mask)
- {
- dst += signdx;
- mask = mask0;
- }
- }
- }
- FbDashStep (dashlen, even);
- }
-
- fbFinishAccess (pDrawable);
-}
-
-void
-fbBresFill (DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x1,
- int y1,
- int e,
- int e1,
- int e3,
- int len)
-{
- while (len--)
- {
- fbFill (pDrawable, pGC, x1, y1, 1, 1);
- if (axis == X_AXIS)
- {
- x1 += signdx;
- e += e1;
- if (e >= 0)
- {
- e += e3;
- y1 += signdy;
- }
- }
- else
- {
- y1 += signdy;
- e += e1;
- if (e >= 0)
- {
- e += e3;
- x1 += signdx;
- }
- }
- }
-}
-
-static void
-fbSetFg (DrawablePtr pDrawable,
- GCPtr pGC,
- Pixel fg)
-{
- if (fg != pGC->fgPixel)
- {
- ChangeGCVal val;
- val.val = fg;
- ChangeGC (NullClient, pGC, GCForeground, &val);
- ValidateGC (pDrawable, pGC);
- }
-}
-
-void
-fbBresFillDash (DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x1,
- int y1,
- int e,
- int e1,
- int e3,
- int len)
-{
- FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
- FbDashDeclare;
- int dashlen;
- Bool even;
- Bool doOdd;
- Bool doBg;
- Pixel fg, bg;
-
- fg = pGC->fgPixel;
- bg = pGC->bgPixel;
-
- /* whether to fill the odd dashes */
- doOdd = pGC->lineStyle == LineDoubleDash;
- /* whether to switch fg to bg when filling odd dashes */
- doBg = doOdd && (pGC->fillStyle == FillSolid ||
- pGC->fillStyle == FillStippled);
-
- /* compute current dash position */
- FbDashInit (pGC, pPriv, dashOffset, dashlen, even);
-
- while (len--)
- {
- if (even || doOdd)
- {
- if (doBg)
- {
- if (even)
- fbSetFg (pDrawable, pGC, fg);
- else
- fbSetFg (pDrawable, pGC, bg);
- }
- fbFill (pDrawable, pGC, x1, y1, 1, 1);
- }
- if (axis == X_AXIS)
- {
- x1 += signdx;
- e += e1;
- if (e >= 0)
- {
- e += e3;
- y1 += signdy;
- }
- }
- else
- {
- y1 += signdy;
- e += e1;
- if (e >= 0)
- {
- e += e3;
- x1 += signdx;
- }
- }
- FbDashStep (dashlen, even);
- }
- if (doBg)
- fbSetFg (pDrawable, pGC, fg);
-}
-
-#ifdef FB_24BIT
-static void
-fbBresSolid24RRop (DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x1,
- int y1,
- int e,
- int e1,
- int e3,
- int len)
-{
- FbStip *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
- FbStip and = pPriv->and;
- FbStip xor = pPriv->xor;
- FbStip leftMask, rightMask;
- int nl;
- FbStip *d;
- int x;
- int rot;
- FbStip andT, xorT;
-
- fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
- dst += ((y1 + dstYoff) * dstStride);
- x1 = (x1 + dstXoff) * 24;
- if (signdy < 0)
- dstStride = -dstStride;
- signdx *= 24;
- while (len--)
- {
- d = dst + (x1 >> FB_STIP_SHIFT);
- x = x1 & FB_STIP_MASK;
- rot = FbFirst24Rot (x);
- andT = FbRot24Stip(and,rot);
- xorT = FbRot24Stip(xor,rot);
- FbMaskStip (x, 24, leftMask, nl, rightMask);
- if (leftMask)
- {
- WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask));
- d++;
- andT = FbNext24Stip (andT);
- xorT = FbNext24Stip (xorT);
- }
- if (rightMask)
- WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, rightMask));
- if (axis == X_AXIS)
- {
- x1 += signdx;
- e += e1;
- if (e >= 0)
- {
- e += e3;
- dst += dstStride;
- }
- }
- else
- {
- dst += dstStride;
- e += e1;
- if (e >= 0)
- {
- e += e3;
- x1 += signdx;
- }
- }
- }
-
- fbFinishAccess (pDrawable);
-}
-
-static void
-fbBresDash24RRop (DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x1,
- int y1,
- int e,
- int e1,
- int e3,
- int len)
-{
- FbStip *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
- FbStip andT, xorT;
- FbStip fgand = pPriv->and;
- FbStip fgxor = pPriv->xor;
- FbStip bgand = pPriv->bgand;
- FbStip bgxor = pPriv->bgxor;
- FbStip leftMask, rightMask;
- int nl;
- FbStip *d;
- int x;
- int rot;
- FbDashDeclare;
- int dashlen;
- Bool even;
- Bool doOdd;
-
- fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
- doOdd = pGC->lineStyle == LineDoubleDash;
-
- /* compute current dash position */
- FbDashInit(pGC, pPriv, dashOffset, dashlen, even);
-
- dst += ((y1 + dstYoff) * dstStride);
- x1 = (x1 + dstXoff) * 24;
- if (signdy < 0)
- dstStride = -dstStride;
- signdx *= 24;
- while (len--)
- {
- if (even || doOdd)
- {
- if (even)
- {
- andT = fgand;
- xorT = fgxor;
- }
- else
- {
- andT = bgand;
- xorT = bgxor;
- }
- d = dst + (x1 >> FB_STIP_SHIFT);
- x = x1 & FB_STIP_MASK;
- rot = FbFirst24Rot (x);
- andT = FbRot24Stip (andT, rot);
- xorT = FbRot24Stip (xorT, rot);
- FbMaskStip (x, 24, leftMask, nl, rightMask);
- if (leftMask)
- {
- WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask));
- d++;
- andT = FbNext24Stip (andT);
- xorT = FbNext24Stip (xorT);
- }
- if (rightMask)
- WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, rightMask));
- }
- if (axis == X_AXIS)
- {
- x1 += signdx;
- e += e1;
- if (e >= 0)
- {
- e += e3;
- dst += dstStride;
- }
- }
- else
- {
- dst += dstStride;
- e += e1;
- if (e >= 0)
- {
- e += e3;
- x1 += signdx;
- }
- }
- FbDashStep (dashlen, even);
- }
-
- fbFinishAccess (pDrawable);
-}
-#endif
-
-/*
- * For drivers that want to bail drawing some lines, this
- * function takes care of selecting the appropriate rasterizer
- * based on the contents of the specified GC.
- */
-
-FbBres *
-fbSelectBres (DrawablePtr pDrawable,
- GCPtr pGC)
-{
- FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
- int dstBpp = pDrawable->bitsPerPixel;
- FbBres * bres;
-
- if (pGC->lineStyle == LineSolid)
- {
- bres = fbBresFill;
- if (pGC->fillStyle == FillSolid)
- {
- bres = fbBresSolid;
-#ifdef FB_24BIT
- if (dstBpp == 24)
- bres = fbBresSolid24RRop;
-#endif
-#ifndef FBNOPIXADDR
- if (pPriv->and == 0)
- {
- switch (dstBpp) {
- case 8: bres = fbBresSolid8; break;
- case 16: bres = fbBresSolid16; break;
-#ifdef FB_24BIT
- case 24: bres = fbBresSolid24; break;
-#endif
- case 32: bres = fbBresSolid32; break;
- }
- }
-#endif
- }
- }
- else
- {
- bres = fbBresFillDash;
- if (pGC->fillStyle == FillSolid)
- {
- bres = fbBresDash;
-#ifdef FB_24BIT
- if (dstBpp == 24)
- bres = fbBresDash24RRop;
-#endif
-#ifndef FBNOPIXADDR
- if (pPriv->and == 0 &&
- (pGC->lineStyle == LineOnOffDash || pPriv->bgand == 0))
- {
- switch (dstBpp) {
- case 8: bres = fbBresDash8; break;
- case 16: bres = fbBresDash16; break;
-#ifdef FB_24BIT
- case 24: bres = fbBresDash24; break;
-#endif
- case 32: bres = fbBresDash32; break;
- }
- }
-#endif
- }
- }
- return bres;
-}
-
-void
-fbBres (DrawablePtr pDrawable,
- GCPtr pGC,
- int dashOffset,
- int signdx,
- int signdy,
- int axis,
- int x1,
- int y1,
- int e,
- int e1,
- int e3,
- int len)
-{
- (*fbSelectBres (pDrawable, pGC)) (pDrawable, pGC, dashOffset,
- signdx, signdy, axis, x1, y1,
- e, e1, e3, len);
-}
-
-void
-fbSegment (DrawablePtr pDrawable,
- GCPtr pGC,
- int x1,
- int y1,
- int x2,
- int y2,
- Bool drawLast,
- int *dashOffset)
-{
- FbBres * bres;
- RegionPtr pClip = fbGetCompositeClip(pGC);
- BoxPtr pBox;
- int nBox;
- int adx; /* abs values of dx and dy */
- int ady;
- int signdx; /* sign of dx and dy */
- int signdy;
- int e, e1, e2, e3; /* bresenham error and increments */
- int len; /* length of segment */
- int axis; /* major axis */
- int octant;
- int dashoff;
- int doff;
- unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
- unsigned int oc1; /* outcode of point 1 */
- unsigned int oc2; /* outcode of point 2 */
-
- nBox = RegionNumRects (pClip);
- pBox = RegionRects (pClip);
-
- bres = fbSelectBres (pDrawable, pGC);
-
- CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy,
- 1, 1, octant);
-
- if (adx > ady)
- {
- axis = X_AXIS;
- e1 = ady << 1;
- e2 = e1 - (adx << 1);
- e = e1 - adx;
- len = adx;
- }
- else
- {
- axis = Y_AXIS;
- e1 = adx << 1;
- e2 = e1 - (ady << 1);
- e = e1 - ady;
- SetYMajorOctant(octant);
- len = ady;
- }
-
- FIXUP_ERROR (e, octant, bias);
-
- /*
- * Adjust error terms to compare against zero
- */
- e3 = e2 - e1;
- e = e - e1;
-
- /* we have bresenham parameters and two points.
- all we have to do now is clip and draw.
- */
-
- if (drawLast)
- len++;
- dashoff = *dashOffset;
- *dashOffset = dashoff + len;
- while(nBox--)
- {
- oc1 = 0;
- oc2 = 0;
- OUTCODES(oc1, x1, y1, pBox);
- OUTCODES(oc2, x2, y2, pBox);
- if ((oc1 | oc2) == 0)
- {
- (*bres) (pDrawable, pGC, dashoff,
- signdx, signdy, axis, x1, y1,
- e, e1, e3, len);
- break;
- }
- else if (oc1 & oc2)
- {
- pBox++;
- }
- else
- {
- int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
- int clip1 = 0, clip2 = 0;
- int clipdx, clipdy;
- int err;
-
- if (miZeroClipLine(pBox->x1, pBox->y1, pBox->x2-1,
- pBox->y2-1,
- &new_x1, &new_y1, &new_x2, &new_y2,
- adx, ady, &clip1, &clip2,
- octant, bias, oc1, oc2) == -1)
- {
- pBox++;
- continue;
- }
-
- if (axis == X_AXIS)
- len = abs(new_x2 - new_x1);
- else
- len = abs(new_y2 - new_y1);
- if (clip2 != 0 || drawLast)
- len++;
- if (len)
- {
- /* unwind bresenham error term to first point */
- doff = dashoff;
- err = e;
- if (clip1)
- {
- clipdx = abs(new_x1 - x1);
- clipdy = abs(new_y1 - y1);
- if (axis == X_AXIS)
- {
- doff += clipdx;
- err += e3 * clipdy + e1 * clipdx;
- }
- else
- {
- doff += clipdy;
- err += e3 * clipdx + e1 * clipdy;
- }
- }
- (*bres) (pDrawable, pGC, doff,
- signdx, signdy, axis, new_x1, new_y1,
- err, e1, e3, len);
- }
- pBox++;
- }
- } /* while (nBox--) */
-}
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "fb.h"
+#include "miline.h"
+
+#define fbBresShiftMask(mask,dir,bpp) ((bpp == FB_STIP_UNIT) ? 0 : \
+ ((dir < 0) ? FbStipLeft(mask,bpp) : \
+ FbStipRight(mask,bpp)))
+
+void
+fbBresSolid (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbStip and = (FbStip) pPriv->and;
+ FbStip xor = (FbStip) pPriv->xor;
+ FbStip mask, mask0;
+ FbStip bits;
+
+ fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ dst += ((y1 + dstYoff) * dstStride);
+ x1 = (x1 + dstXoff) * dstBpp;
+ dst += x1 >> FB_STIP_SHIFT;
+ x1 &= FB_STIP_MASK;
+ mask0 = FbStipMask(0, dstBpp);
+ mask = FbStipRight (mask0, x1);
+ if (signdx < 0)
+ mask0 = FbStipRight (mask0, FB_STIP_UNIT - dstBpp);
+ if (signdy < 0)
+ dstStride = -dstStride;
+ if (axis == X_AXIS)
+ {
+ bits = 0;
+ while (len--)
+ {
+ bits |= mask;
+ mask = fbBresShiftMask(mask,signdx,dstBpp);
+ if (!mask)
+ {
+ WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
+ bits = 0;
+ dst += signdx;
+ mask = mask0;
+ }
+ e += e1;
+ if (e >= 0)
+ {
+ WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
+ bits = 0;
+ dst += dstStride;
+ e += e3;
+ }
+ }
+ if (bits)
+ WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
+ }
+ else
+ {
+ while (len--)
+ {
+ WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, mask));
+ dst += dstStride;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ mask = fbBresShiftMask(mask,signdx,dstBpp);
+ if (!mask)
+ {
+ dst += signdx;
+ mask = mask0;
+ }
+ }
+ }
+ }
+
+ fbFinishAccess (pDrawable);
+}
+
+void
+fbBresDash (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbStip and = (FbStip) pPriv->and;
+ FbStip xor = (FbStip) pPriv->xor;
+ FbStip bgand = (FbStip) pPriv->bgand;
+ FbStip bgxor = (FbStip) pPriv->bgxor;
+ FbStip mask, mask0;
+ FbDashDeclare;
+ int dashlen;
+ Bool even;
+ Bool doOdd;
+
+ fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ doOdd = pGC->lineStyle == LineDoubleDash;
+
+ FbDashInit (pGC, pPriv, dashOffset, dashlen, even);
+
+ dst += ((y1 + dstYoff) * dstStride);
+ x1 = (x1 + dstXoff) * dstBpp;
+ dst += x1 >> FB_STIP_SHIFT;
+ x1 &= FB_STIP_MASK;
+ mask0 = FbStipMask(0, dstBpp);
+ mask = FbStipRight (mask0, x1);
+ if (signdx < 0)
+ mask0 = FbStipRight (mask0, FB_STIP_UNIT - dstBpp);
+ if (signdy < 0)
+ dstStride = -dstStride;
+ while (len--)
+ {
+ if (even)
+ WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, mask));
+ else if (doOdd)
+ WRITE(dst, FbDoMaskRRop (READ(dst), bgand, bgxor, mask));
+ if (axis == X_AXIS)
+ {
+ mask = fbBresShiftMask(mask,signdx,dstBpp);
+ if (!mask)
+ {
+ dst += signdx;
+ mask = mask0;
+ }
+ e += e1;
+ if (e >= 0)
+ {
+ dst += dstStride;
+ e += e3;
+ }
+ }
+ else
+ {
+ dst += dstStride;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ mask = fbBresShiftMask(mask,signdx,dstBpp);
+ if (!mask)
+ {
+ dst += signdx;
+ mask = mask0;
+ }
+ }
+ }
+ FbDashStep (dashlen, even);
+ }
+
+ fbFinishAccess (pDrawable);
+}
+
+void
+fbBresFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ while (len--)
+ {
+ fbFill (pDrawable, pGC, x1, y1, 1, 1);
+ if (axis == X_AXIS)
+ {
+ x1 += signdx;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ y1 += signdy;
+ }
+ }
+ else
+ {
+ y1 += signdy;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ x1 += signdx;
+ }
+ }
+ }
+}
+
+static void
+fbSetFg (DrawablePtr pDrawable,
+ GCPtr pGC,
+ Pixel fg)
+{
+ if (fg != pGC->fgPixel)
+ {
+ ChangeGCVal val;
+ val.val = fg;
+ ChangeGC (NullClient, pGC, GCForeground, &val);
+ ValidateGC (pDrawable, pGC);
+ }
+}
+
+void
+fbBresFillDash (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbDashDeclare;
+ int dashlen;
+ Bool even;
+ Bool doOdd;
+ Bool doBg;
+ Pixel fg, bg;
+
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+
+ /* whether to fill the odd dashes */
+ doOdd = pGC->lineStyle == LineDoubleDash;
+ /* whether to switch fg to bg when filling odd dashes */
+ doBg = doOdd && (pGC->fillStyle == FillSolid ||
+ pGC->fillStyle == FillStippled);
+
+ /* compute current dash position */
+ FbDashInit (pGC, pPriv, dashOffset, dashlen, even);
+
+ while (len--)
+ {
+ if (even || doOdd)
+ {
+ if (doBg)
+ {
+ if (even)
+ fbSetFg (pDrawable, pGC, fg);
+ else
+ fbSetFg (pDrawable, pGC, bg);
+ }
+ fbFill (pDrawable, pGC, x1, y1, 1, 1);
+ }
+ if (axis == X_AXIS)
+ {
+ x1 += signdx;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ y1 += signdy;
+ }
+ }
+ else
+ {
+ y1 += signdy;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ x1 += signdx;
+ }
+ }
+ FbDashStep (dashlen, even);
+ }
+ if (doBg)
+ fbSetFg (pDrawable, pGC, fg);
+}
+
+static void
+fbBresSolid24RRop (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbStip and = pPriv->and;
+ FbStip xor = pPriv->xor;
+ FbStip leftMask, rightMask;
+ int nl;
+ FbStip *d;
+ int x;
+ int rot;
+ FbStip andT, xorT;
+
+ fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ dst += ((y1 + dstYoff) * dstStride);
+ x1 = (x1 + dstXoff) * 24;
+ if (signdy < 0)
+ dstStride = -dstStride;
+ signdx *= 24;
+ while (len--)
+ {
+ d = dst + (x1 >> FB_STIP_SHIFT);
+ x = x1 & FB_STIP_MASK;
+ rot = FbFirst24Rot (x);
+ andT = FbRot24Stip(and,rot);
+ xorT = FbRot24Stip(xor,rot);
+ FbMaskStip (x, 24, leftMask, nl, rightMask);
+ if (leftMask)
+ {
+ WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask));
+ d++;
+ andT = FbNext24Stip (andT);
+ xorT = FbNext24Stip (xorT);
+ }
+ if (rightMask)
+ WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, rightMask));
+ if (axis == X_AXIS)
+ {
+ x1 += signdx;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ dst += dstStride;
+ }
+ }
+ else
+ {
+ dst += dstStride;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ x1 += signdx;
+ }
+ }
+ }
+
+ fbFinishAccess (pDrawable);
+}
+
+static void
+fbBresDash24RRop (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbStip andT, xorT;
+ FbStip fgand = pPriv->and;
+ FbStip fgxor = pPriv->xor;
+ FbStip bgand = pPriv->bgand;
+ FbStip bgxor = pPriv->bgxor;
+ FbStip leftMask, rightMask;
+ int nl;
+ FbStip *d;
+ int x;
+ int rot;
+ FbDashDeclare;
+ int dashlen;
+ Bool even;
+ Bool doOdd;
+
+ fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ doOdd = pGC->lineStyle == LineDoubleDash;
+
+ /* compute current dash position */
+ FbDashInit(pGC, pPriv, dashOffset, dashlen, even);
+
+ dst += ((y1 + dstYoff) * dstStride);
+ x1 = (x1 + dstXoff) * 24;
+ if (signdy < 0)
+ dstStride = -dstStride;
+ signdx *= 24;
+ while (len--)
+ {
+ if (even || doOdd)
+ {
+ if (even)
+ {
+ andT = fgand;
+ xorT = fgxor;
+ }
+ else
+ {
+ andT = bgand;
+ xorT = bgxor;
+ }
+ d = dst + (x1 >> FB_STIP_SHIFT);
+ x = x1 & FB_STIP_MASK;
+ rot = FbFirst24Rot (x);
+ andT = FbRot24Stip (andT, rot);
+ xorT = FbRot24Stip (xorT, rot);
+ FbMaskStip (x, 24, leftMask, nl, rightMask);
+ if (leftMask)
+ {
+ WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask));
+ d++;
+ andT = FbNext24Stip (andT);
+ xorT = FbNext24Stip (xorT);
+ }
+ if (rightMask)
+ WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, rightMask));
+ }
+ if (axis == X_AXIS)
+ {
+ x1 += signdx;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ dst += dstStride;
+ }
+ }
+ else
+ {
+ dst += dstStride;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ x1 += signdx;
+ }
+ }
+ FbDashStep (dashlen, even);
+ }
+
+ fbFinishAccess (pDrawable);
+}
+
+/*
+ * For drivers that want to bail drawing some lines, this
+ * function takes care of selecting the appropriate rasterizer
+ * based on the contents of the specified GC.
+ */
+
+FbBres *
+fbSelectBres (DrawablePtr pDrawable,
+ GCPtr pGC)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ int dstBpp = pDrawable->bitsPerPixel;
+ FbBres * bres;
+
+ if (pGC->lineStyle == LineSolid)
+ {
+ bres = fbBresFill;
+ if (pGC->fillStyle == FillSolid)
+ {
+ bres = fbBresSolid;
+ if (dstBpp == 24)
+ bres = fbBresSolid24RRop;
+ if (pPriv->and == 0)
+ {
+ switch (dstBpp) {
+ case 8: bres = fbBresSolid8; break;
+ case 16: bres = fbBresSolid16; break;
+ case 24: bres = fbBresSolid24; break;
+ case 32: bres = fbBresSolid32; break;
+ }
+ }
+ }
+ }
+ else
+ {
+ bres = fbBresFillDash;
+ if (pGC->fillStyle == FillSolid)
+ {
+ bres = fbBresDash;
+ if (dstBpp == 24)
+ bres = fbBresDash24RRop;
+ if (pPriv->and == 0 &&
+ (pGC->lineStyle == LineOnOffDash || pPriv->bgand == 0))
+ {
+ switch (dstBpp) {
+ case 8: bres = fbBresDash8; break;
+ case 16: bres = fbBresDash16; break;
+ case 24: bres = fbBresDash24; break;
+ case 32: bres = fbBresDash32; break;
+ }
+ }
+ }
+ }
+ return bres;
+}
+
+void
+fbBres (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ (*fbSelectBres (pDrawable, pGC)) (pDrawable, pGC, dashOffset,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e3, len);
+}
+
+void
+fbSegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ Bool drawLast,
+ int *dashOffset)
+{
+ FbBres * bres;
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ BoxPtr pBox;
+ int nBox;
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2, e3; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ int dashoff;
+ int doff;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ unsigned int oc1; /* outcode of point 1 */
+ unsigned int oc2; /* outcode of point 2 */
+
+ nBox = RegionNumRects (pClip);
+ pBox = RegionRects (pClip);
+
+ bres = fbSelectBres (pDrawable, pGC);
+
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy,
+ 1, 1, octant);
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ len = adx;
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ SetYMajorOctant(octant);
+ len = ady;
+ }
+
+ FIXUP_ERROR (e, octant, bias);
+
+ /*
+ * Adjust error terms to compare against zero
+ */
+ e3 = e2 - e1;
+ e = e - e1;
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ if (drawLast)
+ len++;
+ dashoff = *dashOffset;
+ *dashOffset = dashoff + len;
+ while(nBox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pBox);
+ OUTCODES(oc2, x2, y2, pBox);
+ if ((oc1 | oc2) == 0)
+ {
+ (*bres) (pDrawable, pGC, dashoff,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e3, len);
+ break;
+ }
+ else if (oc1 & oc2)
+ {
+ pBox++;
+ }
+ else
+ {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+
+ if (miZeroClipLine(pBox->x1, pBox->y1, pBox->x2-1,
+ pBox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pBox++;
+ continue;
+ }
+
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+ if (clip2 != 0 || drawLast)
+ len++;
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ doff = dashoff;
+ err = e;
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ {
+ doff += clipdx;
+ err += e3 * clipdy + e1 * clipdx;
+ }
+ else
+ {
+ doff += clipdy;
+ err += e3 * clipdx + e1 * clipdy;
+ }
+ }
+ (*bres) (pDrawable, pGC, doff,
+ signdx, signdy, axis, new_x1, new_y1,
+ err, e1, e3, len);
+ }
+ pBox++;
+ }
+ } /* while (nBox--) */
+}
diff --git a/xorg-server/fb/fbsetsp.c b/xorg-server/fb/fbsetsp.c
index ce016453f..65ec8b874 100644
--- a/xorg-server/fb/fbsetsp.c
+++ b/xorg-server/fb/fbsetsp.c
@@ -1,102 +1,100 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-void
-fbSetSpans (DrawablePtr pDrawable,
- GCPtr pGC,
- char *src,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted)
-{
- FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
- RegionPtr pClip = fbGetCompositeClip(pGC);
- FbBits *dst, *d, *s;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- BoxPtr pbox;
- int n;
- int xoff;
- int x1, x2;
-
-#ifdef FB_24_32BIT
- if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
- {
- fb24_32SetSpans (pDrawable, pGC, src, ppt, pwidth, nspans, fSorted);
- return;
- }
-#endif
- fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
- while (nspans--)
- {
- d = dst + (ppt->y + dstYoff) * dstStride;
- xoff = (int) (((long) src) & (FB_MASK >> 3));
- s = (FbBits *) (src - xoff);
- xoff <<= 3;
- n = RegionNumRects(pClip);
- pbox = RegionRects (pClip);
- while (n--)
- {
- if (pbox->y1 > ppt->y)
- break;
- if (pbox->y2 > ppt->y)
- {
- x1 = ppt->x;
- x2 = x1 + *pwidth;
- if (pbox->x1 > x1)
- x1 = pbox->x1;
- if (pbox->x2 < x2)
- x2 = pbox->x2;
- if (x1 < x2)
- fbBlt ((FbBits *) s,
- 0,
- (x1 - ppt->x) * dstBpp + xoff,
- d,
- dstStride,
- (x1 + dstXoff) * dstBpp,
-
- (x2 - x1) * dstBpp,
- 1,
- pGC->alu,
- pPriv->pm,
- dstBpp,
-
- FALSE,
- FALSE);
- }
- }
- src += PixmapBytePad (*pwidth, pDrawable->depth);
- ppt++;
- pwidth++;
- }
- fbValidateDrawable (pDrawable);
- fbFinishAccess (pDrawable);
-}
-
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbSetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ FbBits *dst, *d, *s;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ BoxPtr pbox;
+ int n;
+ int xoff;
+ int x1, x2;
+
+ if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
+ {
+ fb24_32SetSpans (pDrawable, pGC, src, ppt, pwidth, nspans, fSorted);
+ return;
+ }
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ while (nspans--)
+ {
+ d = dst + (ppt->y + dstYoff) * dstStride;
+ xoff = (int) (((long) src) & (FB_MASK >> 3));
+ s = (FbBits *) (src - xoff);
+ xoff <<= 3;
+ n = RegionNumRects(pClip);
+ pbox = RegionRects (pClip);
+ while (n--)
+ {
+ if (pbox->y1 > ppt->y)
+ break;
+ if (pbox->y2 > ppt->y)
+ {
+ x1 = ppt->x;
+ x2 = x1 + *pwidth;
+ if (pbox->x1 > x1)
+ x1 = pbox->x1;
+ if (pbox->x2 < x2)
+ x2 = pbox->x2;
+ if (x1 < x2)
+ fbBlt ((FbBits *) s,
+ 0,
+ (x1 - ppt->x) * dstBpp + xoff,
+ d,
+ dstStride,
+ (x1 + dstXoff) * dstBpp,
+
+ (x2 - x1) * dstBpp,
+ 1,
+ pGC->alu,
+ pPriv->pm,
+ dstBpp,
+
+ FALSE,
+ FALSE);
+ }
+ }
+ src += PixmapBytePad (*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+ fbValidateDrawable (pDrawable);
+ fbFinishAccess (pDrawable);
+}
+
diff --git a/xorg-server/fb/fbsolid.c b/xorg-server/fb/fbsolid.c
index 53fcae071..414378531 100644
--- a/xorg-server/fb/fbsolid.c
+++ b/xorg-server/fb/fbsolid.c
@@ -44,13 +44,11 @@ fbSolid (FbBits *dst,
int n, nmiddle;
int startbyte, endbyte;
-#ifdef FB_24BIT
if (bpp == 24 && (!FbCheck24Pix(and) || !FbCheck24Pix(xor)))
{
fbSolid24 (dst, dstStride, dstX, width, height, and, xor);
return;
}
-#endif
dst += dstX >> FB_SHIFT;
dstX &= FB_MASK;
FbMaskBitsBytes(dstX, width, and == 0, startmask, startbyte,
@@ -81,7 +79,6 @@ fbSolid (FbBits *dst,
}
}
-#ifdef FB_24BIT
void
fbSolid24 (FbBits *dst,
FbStride dstStride,
@@ -210,4 +207,3 @@ fbSolid24 (FbBits *dst,
dst += dstStride;
}
}
-#endif
diff --git a/xorg-server/fb/fbstipple.c b/xorg-server/fb/fbstipple.c
index bc25e462f..dc1fd468f 100644
--- a/xorg-server/fb/fbstipple.c
+++ b/xorg-server/fb/fbstipple.c
@@ -26,7 +26,6 @@
#include "fb.h"
-#ifndef FBNOPIXADDR
/*
* This is a slight abuse of the preprocessor to generate repetitive
* code, the idea is to generate code for each case of a copy-mode
@@ -78,7 +77,6 @@ fbTransparentSpan (FbBits *dst,
LaneCases(dst);
}
}
-#endif
void
fbEvenStipple (FbBits *dst,
@@ -170,7 +168,6 @@ fbEvenStipple (FbBits *dst,
and = (fgand & mask) | (bgand & ~mask);
xor = (fgxor & mask) | (bgxor & ~mask);
-#ifndef FBNOPIXADDR
if (transparent)
{
if (startmask)
@@ -184,7 +181,6 @@ fbEvenStipple (FbBits *dst,
fbTransparentSpan(dst, mask&endmask, fgxor, 1);
}
else
-#endif
{
/*
* Fill scanline
diff --git a/xorg-server/fb/fbwindow.c b/xorg-server/fb/fbwindow.c
index 92b23acdb..7906f8dd2 100644
--- a/xorg-server/fb/fbwindow.c
+++ b/xorg-server/fb/fbwindow.c
@@ -1,250 +1,229 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include "fb.h"
-
-Bool
-fbCreateWindow(WindowPtr pWin)
-{
- dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(),
- fbGetScreenPixmap(pWin->drawable.pScreen));
-#ifdef FB_SCREEN_PRIVATE
- if (pWin->drawable.bitsPerPixel == 32)
- pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
-#endif
- return TRUE;
-}
-
-Bool
-fbDestroyWindow(WindowPtr pWin)
-{
- return TRUE;
-}
-
-Bool
-fbMapWindow(WindowPtr pWindow)
-{
- return TRUE;
-}
-
-Bool
-fbPositionWindow(WindowPtr pWin, int x, int y)
-{
- return TRUE;
-}
-
-Bool
-fbUnmapWindow(WindowPtr pWindow)
-{
- return TRUE;
-}
-
-void
-fbCopyWindowProc (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pbox,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown,
- Pixel bitplane,
- void *closure)
-{
- FbBits *src;
- FbStride srcStride;
- int srcBpp;
- int srcXoff, srcYoff;
- FbBits *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
-
- fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
- fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-
- while (nbox--)
- {
- fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
- srcStride,
- (pbox->x1 + dx + srcXoff) * srcBpp,
-
- dst + (pbox->y1 + dstYoff) * dstStride,
- dstStride,
- (pbox->x1 + dstXoff) * dstBpp,
-
- (pbox->x2 - pbox->x1) * dstBpp,
- (pbox->y2 - pbox->y1),
-
- GXcopy,
- FB_ALLONES,
- dstBpp,
-
- reverse,
- upsidedown);
- pbox++;
- }
-
- fbFinishAccess (pDstDrawable);
- fbFinishAccess (pSrcDrawable);
-}
-
-void
-fbCopyWindow(WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc)
-{
- RegionRec rgnDst;
- int dx, dy;
-
- PixmapPtr pPixmap = fbGetWindowPixmap (pWin);
- DrawablePtr pDrawable = &pPixmap->drawable;
-
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
- RegionTranslate(prgnSrc, -dx, -dy);
-
- RegionNull(&rgnDst);
-
- RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
-
-#ifdef COMPOSITE
- if (pPixmap->screen_x || pPixmap->screen_y)
- RegionTranslate(&rgnDst,
- -pPixmap->screen_x, -pPixmap->screen_y);
-#endif
-
- miCopyRegion (pDrawable, pDrawable,
- 0,
- &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
-
- RegionUninit(&rgnDst);
- fbValidateDrawable (&pWin->drawable);
-}
-
-Bool
-fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
-{
- PixmapPtr pPixmap;
-
- if (mask & CWBackPixmap)
- {
- if (pWin->backgroundState == BackgroundPixmap)
- {
- pPixmap = pWin->background.pixmap;
-#ifdef FB_24_32BIT
- if (pPixmap->drawable.bitsPerPixel != pWin->drawable.bitsPerPixel)
- {
- pPixmap = fb24_32ReformatTile (pPixmap,
- pWin->drawable.bitsPerPixel);
- if (pPixmap)
- {
- (*pWin->drawable.pScreen->DestroyPixmap) (pWin->background.pixmap);
- pWin->background.pixmap = pPixmap;
- }
- }
-#endif
- if (FbEvenTile (pPixmap->drawable.width *
- pPixmap->drawable.bitsPerPixel))
- fbPadPixmap (pPixmap);
- }
- }
- if (mask & CWBorderPixmap)
- {
- if (pWin->borderIsPixel == FALSE)
- {
- pPixmap = pWin->border.pixmap;
-#ifdef FB_24_32BIT
- if (pPixmap->drawable.bitsPerPixel !=
- pWin->drawable.bitsPerPixel)
- {
- pPixmap = fb24_32ReformatTile (pPixmap,
- pWin->drawable.bitsPerPixel);
- if (pPixmap)
- {
- (*pWin->drawable.pScreen->DestroyPixmap) (pWin->border.pixmap);
- pWin->border.pixmap = pPixmap;
- }
- }
-#endif
- if (FbEvenTile (pPixmap->drawable.width *
- pPixmap->drawable.bitsPerPixel))
- fbPadPixmap (pPixmap);
- }
- }
- return TRUE;
-}
-
-void
-fbFillRegionSolid (DrawablePtr pDrawable,
- RegionPtr pRegion,
- FbBits and,
- FbBits xor)
-{
- FbBits *dst;
- FbStride dstStride;
- int dstBpp;
- int dstXoff, dstYoff;
- int n = RegionNumRects(pRegion);
- BoxPtr pbox = RegionRects(pRegion);
-
-#ifndef FB_ACCESS_WRAPPER
- int try_mmx = 0;
- if (!and)
- try_mmx = 1;
-#endif
-
- fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-
- while (n--)
- {
-#ifndef FB_ACCESS_WRAPPER
- if (!try_mmx || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp,
- pbox->x1 + dstXoff, pbox->y1 + dstYoff,
- (pbox->x2 - pbox->x1),
- (pbox->y2 - pbox->y1),
- xor))
- {
-#endif
- fbSolid (dst + (pbox->y1 + dstYoff) * dstStride,
- dstStride,
- (pbox->x1 + dstXoff) * dstBpp,
- dstBpp,
- (pbox->x2 - pbox->x1) * dstBpp,
- pbox->y2 - pbox->y1,
- and, xor);
-#ifndef FB_ACCESS_WRAPPER
- }
-#endif
- fbValidateDrawable (pDrawable);
- pbox++;
- }
-
- fbFinishAccess (pDrawable);
-}
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "fb.h"
+
+Bool
+fbCreateWindow(WindowPtr pWin)
+{
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(),
+ fbGetScreenPixmap(pWin->drawable.pScreen));
+ if (pWin->drawable.bitsPerPixel == 32)
+ pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
+ return TRUE;
+}
+
+Bool
+fbDestroyWindow(WindowPtr pWin)
+{
+ return TRUE;
+}
+
+Bool
+fbMapWindow(WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+Bool
+fbPositionWindow(WindowPtr pWin, int x, int y)
+{
+ return TRUE;
+}
+
+Bool
+fbUnmapWindow(WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+void
+fbCopyWindowProc (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ while (nbox--)
+ {
+ fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+
+ (pbox->x2 - pbox->x1) * dstBpp,
+ (pbox->y2 - pbox->y1),
+
+ GXcopy,
+ FB_ALLONES,
+ dstBpp,
+
+ reverse,
+ upsidedown);
+ pbox++;
+ }
+
+ fbFinishAccess (pDstDrawable);
+ fbFinishAccess (pSrcDrawable);
+}
+
+void
+fbCopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ RegionRec rgnDst;
+ int dx, dy;
+
+ PixmapPtr pPixmap = fbGetWindowPixmap (pWin);
+ DrawablePtr pDrawable = &pPixmap->drawable;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ RegionTranslate(prgnSrc, -dx, -dy);
+
+ RegionNull(&rgnDst);
+
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
+
+#ifdef COMPOSITE
+ if (pPixmap->screen_x || pPixmap->screen_y)
+ RegionTranslate(&rgnDst,
+ -pPixmap->screen_x, -pPixmap->screen_y);
+#endif
+
+ miCopyRegion (pDrawable, pDrawable,
+ 0,
+ &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
+
+ RegionUninit(&rgnDst);
+ fbValidateDrawable (&pWin->drawable);
+}
+
+static void
+fbFixupWindowPixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
+{
+ PixmapPtr pPixmap = *ppPixmap;
+
+ if (pPixmap->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
+ {
+ pPixmap = fb24_32ReformatTile (pPixmap, pDrawable->bitsPerPixel);
+ if (!pPixmap)
+ return;
+ (*pDrawable->pScreen->DestroyPixmap) (*ppPixmap);
+ *ppPixmap = pPixmap;
+ }
+ if (FbEvenTile (pPixmap->drawable.width *
+ pPixmap->drawable.bitsPerPixel))
+ fbPadPixmap (pPixmap);
+}
+
+Bool
+fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
+{
+ if (mask & CWBackPixmap)
+ {
+ if (pWin->backgroundState == BackgroundPixmap)
+ fbFixupWindowPixmap(&pWin->drawable, &pWin->background.pixmap);
+ }
+ if (mask & CWBorderPixmap)
+ {
+ if (pWin->borderIsPixel == FALSE)
+ fbFixupWindowPixmap(&pWin->drawable, &pWin->border.pixmap);
+ }
+ return TRUE;
+}
+
+void
+fbFillRegionSolid (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ FbBits and,
+ FbBits xor)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int n = RegionNumRects(pRegion);
+ BoxPtr pbox = RegionRects(pRegion);
+
+#ifndef FB_ACCESS_WRAPPER
+ int try_mmx = 0;
+ if (!and)
+ try_mmx = 1;
+#endif
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ while (n--)
+ {
+#ifndef FB_ACCESS_WRAPPER
+ if (!try_mmx || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp,
+ pbox->x1 + dstXoff, pbox->y1 + dstYoff,
+ (pbox->x2 - pbox->x1),
+ (pbox->y2 - pbox->y1),
+ xor))
+ {
+#endif
+ fbSolid (dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+ dstBpp,
+ (pbox->x2 - pbox->x1) * dstBpp,
+ pbox->y2 - pbox->y1,
+ and, xor);
+#ifndef FB_ACCESS_WRAPPER
+ }
+#endif
+ fbValidateDrawable (pDrawable);
+ pbox++;
+ }
+
+ fbFinishAccess (pDrawable);
+}