diff options
author | marha <marha@users.sourceforge.net> | 2011-02-28 06:37:03 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-02-28 06:37:03 +0000 |
commit | feee2b5ceb37101bd1c4162e49805e6ad63e28ae (patch) | |
tree | dacb7faae8047c9dbc714a377440d9f69eb1f480 | |
parent | 8268836508edd4ba2a3045c9ba937397df7bf2c5 (diff) | |
download | vcxsrv-feee2b5ceb37101bd1c4162e49805e6ad63e28ae.tar.gz vcxsrv-feee2b5ceb37101bd1c4162e49805e6ad63e28ae.tar.bz2 vcxsrv-feee2b5ceb37101bd1c4162e49805e6ad63e28ae.zip |
xserver libX11 Xextproto mesa Git update 28 Feb 2011
37 files changed, 18328 insertions, 17634 deletions
diff --git a/X11/extensions/Makefile.in b/X11/extensions/Makefile.in deleted file mode 100644 index 81eaffd2a..000000000 --- a/X11/extensions/Makefile.in +++ /dev/null @@ -1,856 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = . -DIST_COMMON = README $(am__configure_deps) $(compat_HEADERS) \ - $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/xextproto.pc.in $(top_srcdir)/configure \ - $(xext_HEADERS) COPYING ChangeLog INSTALL config.guess \ - config.sub install-sh missing -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno config.status.lineno -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = xextproto.pc -CONFIG_CLEAN_VPATH_FILES = -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-dvi-recursive install-exec-recursive \ - install-html-recursive install-info-recursive \ - install-pdf-recursive install-ps-recursive install-recursive \ - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__installdirs = "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(compatdir)" \ - "$(DESTDIR)$(xextdir)" -DATA = $(pkgconfig_DATA) -HEADERS = $(compat_HEADERS) $(xext_HEADERS) -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ - $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ - distdir dist dist-all distcheck -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - { test ! -d "$(distdir)" \ - || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr "$(distdir)"; }; } -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2 -GZIP_ENV = --best -distuninstallcheck_listfiles = find . -type f -print -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ -ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -APP_MAN_DIR = @APP_MAN_DIR@ -APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CHANGELOG_CMD = @CHANGELOG_CMD@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CWARNFLAGS = @CWARNFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ -DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FILE_MAN_DIR = @FILE_MAN_DIR@ -FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ -FOP = @FOP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_CMD = @INSTALL_CMD@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIB_MAN_DIR = @LIB_MAN_DIR@ -LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MAN_SUBSTS = @MAN_SUBSTS@ -MISC_MAN_DIR = @MISC_MAN_DIR@ -MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -STYLESHEET_SRCDIR = @STYLESHEET_SRCDIR@ -VERSION = @VERSION@ -XMLTO = @XMLTO@ -XORG_MAN_PAGE = @XORG_MAN_PAGE@ -XORG_SGML_PATH = @XORG_SGML_PATH@ -XSL_STYLESHEET = @XSL_STYLESHEET@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -SUBDIRS = specs -xextdir = $(includedir)/X11/extensions -xext_HEADERS = \ - dpmsconst.h \ - dpmsproto.h \ - ge.h \ - geproto.h \ - lbx.h \ - lbxproto.h \ - mitmiscconst.h \ - mitmiscproto.h \ - multibufconst.h \ - multibufproto.h \ - secur.h \ - securproto.h \ - shapeconst.h \ - shapeproto.h \ - shm.h \ - shmproto.h \ - syncconst.h \ - syncproto.h \ - ag.h \ - agproto.h \ - cup.h \ - cupproto.h \ - dbe.h \ - dbeproto.h \ - EVI.h \ - EVIproto.h \ - xtestext1proto.h \ - xtestext1const.h \ - xtestconst.h \ - xtestproto.h - - -# -# These headers allow old servers to be built with -# new headers -# -compatdir = $(xextdir) -compat_HEADERS = \ - shapestr.h \ - shmstr.h \ - syncstr.h - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = xextproto.pc -MAINTAINERCLEANFILES = ChangeLog INSTALL -all: all-recursive - -.SUFFIXES: -am--refresh: - @: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ - $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - echo ' $(SHELL) ./config.status'; \ - $(SHELL) ./config.status;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - $(am__cd) $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -$(am__aclocal_m4_deps): -xextproto.pc: $(top_builddir)/config.status $(srcdir)/xextproto.pc.in - cd $(top_builddir) && $(SHELL) ./config.status $@ -install-pkgconfigDATA: $(pkgconfig_DATA) - @$(NORMAL_INSTALL) - test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ - done - -uninstall-pkgconfigDATA: - @$(NORMAL_UNINSTALL) - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files -install-compatHEADERS: $(compat_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(compatdir)" || $(MKDIR_P) "$(DESTDIR)$(compatdir)" - @list='$(compat_HEADERS)'; test -n "$(compatdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(compatdir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(compatdir)" || exit $$?; \ - done - -uninstall-compatHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(compat_HEADERS)'; test -n "$(compatdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(compatdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(compatdir)" && rm -f $$files -install-xextHEADERS: $(xext_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(xextdir)" || $(MKDIR_P) "$(DESTDIR)$(xextdir)" - @list='$(xext_HEADERS)'; test -n "$(xextdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(xextdir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(xextdir)" || exit $$?; \ - done - -uninstall-xextHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(xext_HEADERS)'; test -n "$(xextdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(xextdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(xextdir)" && rm -f $$files - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -$(RECURSIVE_CLEAN_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - $(am__remove_distdir) - test -d "$(distdir)" || mkdir "$(distdir)" - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$(top_distdir)" distdir="$(distdir)" \ - dist-hook - -test -n "$(am__skip_mode_fix)" \ - || find "$(distdir)" -type d ! -perm -755 \ - -exec chmod u+rwx,go+rx {} \; -o \ - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r "$(distdir)" -dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -dist-lzma: distdir - tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma - $(am__remove_distdir) - -dist-xz: distdir - tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz - $(am__remove_distdir) - -dist-tarZ: distdir - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) - -dist-shar: distdir - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) - -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ - *.tar.bz2*) \ - bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.lzma*) \ - lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ - *.tar.xz*) \ - xz -dc $(distdir).tar.xz | $(am__untar) ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst - chmod a-w $(distdir) - test -d $(distdir)/_build || exit 0; \ - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ - && cd "$$am__cwd" \ - || exit 1 - $(am__remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' -distuninstallcheck: - @$(am__cd) '$(distuninstallcheck_dir)' \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am -check: check-recursive -all-am: Makefile $(DATA) $(HEADERS) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(compatdir)" "$(DESTDIR)$(xextdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) -clean: clean-recursive - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: install-compatHEADERS install-pkgconfigDATA \ - install-xextHEADERS - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-compatHEADERS uninstall-pkgconfigDATA \ - uninstall-xextHEADERS - -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ - install-am install-strip tags-recursive - -.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ - all all-am am--refresh check check-am clean clean-generic \ - ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ - dist-hook dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ - distcheck distclean distclean-generic distclean-tags \ - distcleancheck distdir distuninstallcheck dvi dvi-am html \ - html-am info info-am install install-am install-compatHEADERS \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ - install-strip install-xextHEADERS installcheck installcheck-am \ - installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ - pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ - uninstall-compatHEADERS uninstall-pkgconfigDATA \ - uninstall-xextHEADERS - - -.PHONY: ChangeLog INSTALL - -INSTALL: - $(INSTALL_CMD) - -ChangeLog: - $(CHANGELOG_CMD) - -dist-hook: ChangeLog INSTALL - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/X11/extensions/configure.ac b/X11/extensions/configure.ac index 92d49d9d7..dd30292e3 100644 --- a/X11/extensions/configure.ac +++ b/X11/extensions/configure.ac @@ -1,18 +1,18 @@ -AC_PREREQ([2.60])
-AC_INIT([XExtProto], [7.1.99.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg])
-AM_INIT_AUTOMAKE([foreign dist-bzip2])
-AM_MAINTAINER_MODE
-
-# Require xorg-macros minimum of 1.10 for DocBook XML documentation
-m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.10)
-XORG_DEFAULT_OPTIONS
-XORG_ENABLE_SPECS
-XORG_WITH_XMLTO(0.0.20)
-XORG_WITH_FOP
-XORG_CHECK_SGML_DOCTOOLS(1.5)
-
-AC_OUTPUT([Makefile
- specs/Makefile
- xextproto.pc])
+AC_PREREQ([2.60]) +AC_INIT([XExtProto], [7.2.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg]) +AM_INIT_AUTOMAKE([foreign dist-bzip2]) +AM_MAINTAINER_MODE + +# Require xorg-macros minimum of 1.10 for DocBook XML documentation +m4_ifndef([XORG_MACROS_VERSION], + [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])]) +XORG_MACROS_VERSION(1.10) +XORG_DEFAULT_OPTIONS +XORG_ENABLE_SPECS +XORG_WITH_XMLTO(0.0.20) +XORG_WITH_FOP +XORG_CHECK_SGML_DOCTOOLS(1.5) + +AC_OUTPUT([Makefile + specs/Makefile + xextproto.pc]) diff --git a/libX11/specs/i18n/localedb/localedb.xml b/libX11/specs/i18n/localedb/localedb.xml index e5b96ab84..c4f6d1377 100644 --- a/libX11/specs/i18n/localedb/localedb.xml +++ b/libX11/specs/i18n/localedb/localedb.xml @@ -1,777 +1,777 @@ -<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
- "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
-
-<book id="localedbspec">
-
-<bookinfo>
- <title>X Locale Database Specification</title>
- <authorgroup>
- <author>
- <firstname>Yoshio</firstname><surname>Horiuchi</surname>
- <affiliation><orgname>IBM Japan</orgname></affiliation>
- </author>
- </authorgroup>
- <copyright><year>1994</year><holder>IBM Corporation</holder></copyright>
- <copyright><year>1994</year><holder>X Consortium</holder></copyright>
-
-
-<legalnotice>
-
-<para>
-License to use, copy, modify, and distribute this software and its documentation for
-any purpose and without fee is hereby granted, provided that the above copyright notice
-appear in all copies and that both that copyright notice and this permission notice
-appear in supporting documentation, and that the name of IBM not be used in advertising
-or publicity pertaining to distribution of the software without specific, written
-prior permission.
-</para>
-<para>
-IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
-WARRANTIES OF MERCHANTABILITY, FITNESS, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS,
-IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
-OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
-AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
-WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-</para>
-
-<para>
-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:
-</para>
-
-<para>
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-</para>
-
-<para>
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-</para>
-
-<para>
-Except as contained in this notice, the name of The Open Group shall not
-be used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from X Consortium.
-</para>
-
-<para>X Window System is a trademark of The Open Group.</para>
-
-</legalnotice>
-</bookinfo>
-
-<chapter id="localedb">
-<title>LocaleDB</title>
-
-<sect1 id="General">
-<title>General</title>
-<para>
-An X Locale Database contains the subset of a user's environment that
-depends on language, in X Window System. It is made up from one or more
-categories. Each category consists of some classes and sub-classes.
-</para>
-
-<para>
-It is provided as a plain ASCII text file, so a user can change its
-contents easily. It allows a user to customize the behavior of
-internationalized portion of Xlib without changing Xlib itself.
-</para>
-
-<para>
-This document describes;
-</para>
-
-<itemizedlist>
- <listitem>
- <para>
-Database Format Definition
- </para>
- </listitem>
- <listitem>
- <para>
-Contents of Database in sample implementation
-<!-- .RE -->
- </para>
- </listitem>
-</itemizedlist>
-
-<para>
-Since it is hard to define the set of required information for all
-platforms, only the flexible database format is defined.
-The available entries in database are implementation dependent.
-</para>
-
-</sect1>
-<sect1 id="Database_Format_Definition">
-<title>Database Format Definition</title>
-<para>
-The X Locale Database contains one or more category definitions.
-This section describes the format of each category definition.
-</para>
-
-<para>
-The category definition consists of one or more class definitions.
-Each class definition has a pair of class name and class value, or
-has several subclasses which are enclosed by the left brace ({) and
-the right brace (}).
-</para>
-
-<para>
-Comments can be placed by using the number sign character (#).
-Putting the number sign character on the top of the line indicates
-that the entire line is comment. Also, putting any whitespace character
-followed by the number sign character indicates that a part of the line
-(from the number sign to the end of the line) is comment.
-A line can be continued by placing backslash (\) character as the
-last character on the line; this continuation character will be
-discarded from the input. Comment lines cannot be continued on
-a subsequent line using an escaped new line character.
-</para>
-
-<para>
-X Locale Database only accepts XPCS, the X Portable Character Set.
-The reserved symbols are; the quotation mark("), the number sign (#),
-the semicolon(;), the backslash(\), the left brace({) and
-the right brace(}).
-</para>
-
-<para>
-The format of category definition is;
-</para>
-
-<informaltable frame="none">
- <tgroup cols='3' align='left'>
- <colspec colname='c1' colwidth="3*" colsep="0"/>
- <colspec colname='c2' colwidth="1*" colsep="0"/>
- <colspec colname='c3' colwidth="6*" colsep="0"/>
- <tbody>
- <row rowsep="0">
- <entry>CategoryDefinition</entry>
- <entry>::=</entry>
- <entry>CategoryHeader CategorySpec CategoryTrailer</entry>
- </row>
- <row rowsep="0">
- <entry>CategoryHeader</entry>
- <entry>::=</entry>
- <entry>CategoryName NL</entry>
- </row>
- <row rowsep="0">
- <entry>CategorySpec</entry>
- <entry>::=</entry>
- <entry>{ ClassSpec }</entry>
- </row>
- <row rowsep="0">
- <entry>CategoryTrailer</entry>
- <entry>::=</entry>
- <entry>"END" Delimiter CategoryName NL</entry>
- </row>
- <row rowsep="0">
- <entry>CategoryName</entry>
- <entry>::=</entry>
- <entry>String</entry>
- </row>
- <row rowsep="0">
- <entry>ClassSpec</entry>
- <entry>::=</entry>
- <entry>ClassName Delimiter ClassValue NL</entry>
- </row>
- <row rowsep="0">
- <entry>ClassName</entry>
- <entry>::=</entry>
- <entry>String</entry>
- </row>
- <row rowsep="0">
- <entry>ClassValue</entry>
- <entry>::=</entry>
- <entry>ValueList | "{" NL { ClassSpec } "}"</entry>
- </row>
- <row rowsep="0">
- <entry>ValueList</entry>
- <entry>::=</entry>
- <entry>Value | Value ";" ValueList</entry>
- </row>
- <row rowsep="0">
- <entry>Value</entry>
- <entry>::=</entry>
- <entry>ValuePiece | ValuePiece Value</entry>
- </row>
- <row rowsep="0">
- <entry>ValuePiece</entry>
- <entry>::=</entry>
- <entry>String | QuotedString | NumericString</entry>
- </row>
- <row rowsep="0">
- <entry>String</entry>
- <entry>::=</entry>
- <entry>Char { Char }</entry>
- </row>
- <row rowsep="0">
- <entry>QuotedString</entry>
- <entry>::=</entry>
- <entry>""" QuotedChar { QuotedChar } """</entry>
- </row>
- <row rowsep="0">
- <entry>NumericString</entry>
- <entry>::=</entry>
- <entry>"\\o" OctDigit { OctDigit }</entry>
- </row>
- <row rowsep="0">
- <entry></entry>
- <entry>|</entry>
- <entry>"\\d" DecDigit { DecDigit }</entry>
- </row>
- <row rowsep="0">
- <entry></entry>
- <entry>|</entry>
- <entry>"\\x" HexDigit { HexDigit }</entry>
- </row>
- <row rowsep="0">
- <entry>Char</entry>
- <entry>::=</entry>
- <entry><XPCS except NL, Space or unescaped reserved symbols></entry>
- </row>
- <row rowsep="0">
- <entry>QuotedChar</entry>
- <entry>::=</entry>
- <entry><XPCS except unescaped """></entry>
- </row>
- <row rowsep="0">
- <entry>OctDigit</entry>
- <entry>::=</entry>
- <entry><character in the range of "0" - "7"></entry>
- </row>
- <row rowsep="0">
- <entry>DecDigit</entry>
- <entry>::=</entry>
- <entry><character in the range of "0" - "9"></entry>
- </row>
- <row rowsep="0">
- <entry>HexDigit</entry>
- <entry>::=</entry>
- <entry><character in the range of "0" - "9", "a" - "f", "A" - "F"></entry>
- </row>
- <row rowsep="0">
- <entry>Delimiter</entry>
- <entry>::=</entry>
- <entry>Space { Space }</entry>
- </row>
- <row rowsep="0">
- <entry>Space</entry>
- <entry>::=</entry>
- <entry><space> | <horizontal tab></entry>
- </row>
- <row rowsep="0">
- <entry>NL</entry>
- <entry>::=</entry>
- <entry><newline></entry>
- </row>
- </tbody>
- </tgroup>
-</informaltable>
-
-<para>
-Elements separated by vertical bar (|) are alternatives. Curly
-braces ({...}) indicate zero or more repetitions of the enclosed
-elements. Square brackets ([...]) indicate that the enclosed element
-is optional. Quotes ("...") are used around literal characters.
-</para>
-
-<para>
-The backslash, which is not the top character of the NumericString, is
-recognized as an escape character, so that the next one character is
-treated as a literal character. For example, the two-character
-sequence, ""\"""(the backslash followed by the quotation mark) is
-recognized and replaced with a quotation mark character.
-Any whitespace character, that is not the Delimiter, unquoted and
-unescaped, is ignored.
-</para>
-
-</sect1>
-<sect1 id="Contents_of_Database_">
-<title>Contents of Database </title>
-<para>
-The available categories and classes depend on implementation, because
-different platform will require different information set.
-For example, some platform have system locale but some platform don't.
-Furthermore, there might be a difference in functionality even if the
-platform has system locale.
-</para>
-
-<para>
-In current sample implementation, categories listed below are available.
-</para>
-
-<informaltable frame="none">
- <tgroup cols='3' align='left'>
- <colspec colname='c1' colwidth="2*" colsep="0"/>
- <colspec colname='c2' colwidth="1*" colsep="0"/>
- <tbody>
- <row rowsep="0">
- <entry>XLC_FONTSET:XFontSet relative information</entry>
- </row>
- <row rowsep="0">
- <entry>XLC_XLOCALE:Character classification and conversion information</entry>
- </row>
- </tbody>
- </tgroup>
-</informaltable>
-
-</sect1>
-<sect1 id="XLC_FONTSET_Category">
-<title>XLC_FONTSET Category</title>
-<para>
-The XLC_FONTSET category defines the XFontSet relative information.
-It contains the CHARSET_REGISTRY-CHARSET_ENCODING name and character
-mapping side (GL, GR, etc), and is used in Output Method (OM).
-</para>
-
-<informaltable frame="none">
- <tgroup cols='3' align='left'>
- <thead>
- <colspec colname='c1' colwidth="3*" colsep="0"/>
- <colspec colname='c2' colwidth="1*" colsep="0"/>
- <colspec colname='c3' colwidth="3*" colsep="0"/>
- <row>
- <entry>class</entry>
- <entry>super class</entry>
- <entry>description</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>fsN</entry>
- <entry></entry>
- <entry>Nth fontset (N=0,1,2, ...)</entry>
- </row>
- <row rowsep="0">
- <entry>charset</entry>
- <entry>fsN</entry>
- <entry>list of encoding name</entry>
- </row>
- <row rowsep="0">
- <entry>font</entry>
- <entry>fsN</entry>
- <entry>list of font encoding name</entry>
- </row>
- </tbody>
- </tgroup>
-</informaltable>
-
-<variablelist>
- <varlistentry>
- <term>fsN</term>
- <listitem>
- <para>
-Includes an encoding information for Nth charset, where N is
-the index number (0,1,2,...). If there are 4 charsets available
-in current locale, 4 fontsets, fs0, fs1, fs2 and fs3, should be
-defined.
-This class has two subclasses, 'charset' and 'font'.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>charset</term>
- <listitem>
- <para>
-Specifies an encoding information to be used internally in Xlib
-for this fontset. The format of value is;
- </para>
-<informaltable frame="none">
- <tgroup cols='3' align='left'>
- <colspec colname='c1' colwidth="3*" colsep="0"/>
- <colspec colname='c2' colwidth="1*" colsep="0"/>
- <colspec colname='c3' colwidth="4*" colsep="0"/>
- <tbody>
- <row rowsep="0">
- <entry>EncodingInfo</entry>
- <entry>::=</entry>
- <entry>EncodingName [ ":" EncodingSide ]</entry>
- </row>
- <row rowsep="0">
- <entry>EncodingName</entry>
- <entry>::=</entry>
- <entry>CHARSET_REGISTRY-CHARSET_ENCODING</entry>
- </row>
- <row rowsep="0">
- <entry>EncodingSide</entry>
- <entry>::=</entry>
- <entry>"GL" | "GR"</entry>
- </row>
- </tbody>
- </tgroup>
-</informaltable>
-
-<para>
-For detail definition of CHARSET_REGISTRY-CHARSET_ENCODING, refer
-"X Logical Font Descriptions" document.
-</para>
-<literallayout>
-example:
- ISO8859-1:GL
-</literallayout>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>font</term>
- <listitem>
- <para>
-Specifies a list of encoding information which is used for searching
-appropriate font for this fontset. The left most entry has highest
-priority.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-</sect1>
-<sect1 id="XLC_XLOCALE_Category">
-<title>XLC_XLOCALE Category</title>
-<para>
-The XLC_XLOCALE category defines character classification, conversion
-and other character attributes.
-</para>
-
-<informaltable frame="none">
- <tgroup cols='3' align='left'>
- <colspec colname='c1' colwidth="3*" colsep="0"/>
- <colspec colname='c2' colwidth="1*" colsep="0"/>
- <colspec colname='c3' colwidth="3*" colsep="0"/>
- <thead>
- <row>
- <entry>class</entry>
- <entry>super class</entry>
- <entry>description</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>encoding_name</entry>
- <entry></entry>
- <entry>codeset name</entry>
- </row>
- <row rowsep="0">
- <entry>mb_cur_max</entry>
- <entry></entry>
- <entry>MB_CUR_MAX</entry>
- </row>
- <row rowsep="0">
- <entry>state_depend_encoding</entry>
- <entry></entry>
- <entry>state dependent or not</entry>
- </row>
- <row rowsep="0">
- <entry>wc_encoding_mask</entry>
- <entry></entry>
- <entry>for parsing wc string</entry>
- </row>
- <row rowsep="0">
- <entry>wc_shift_bits</entry>
- <entry></entry>
- <entry>for conversion between wc and mb</entry>
- </row>
- <row rowsep="0">
- <entry>csN</entry>
- <entry></entry>
- <entry>Nth charset (N=0,1,2,...)</entry>
- </row>
- <row rowsep="0">
- <entry>side</entry>
- <entry>csN</entry>
- <entry>mapping side (GL, etc)</entry>
- </row>
- <row rowsep="0">
- <entry>length</entry>
- <entry>csN</entry>
- <entry>length of a character</entry>
- </row>
- <row rowsep="0">
- <entry>mb_encoding</entry>
- <entry>csN</entry>
- <entry>for parsing mb string</entry>
- </row>
- <row rowsep="0">
- <entry>wc_encoding</entry>
- <entry>csN</entry>
- <entry>for parsing wc string</entry>
- </row>
- <row rowsep="0">
- <entry>ct_encoding</entry>
- <entry>csN</entry>
- <entry>list of encoding name for ct</entry>
- </row>
- </tbody>
- </tgroup>
-</informaltable>
-
-<variablelist>
- <varlistentry>
- <term>encoding_name</term>
- <listitem>
- <para>
-Specifies a codeset name of current locale.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>mb_cur_max</term>
- <listitem>
- <para>
-Specifies a maximum allowable number of bytes in a multi-byte character.
-It is corresponding to MB_CUR_MAX of "ISO/IEC 9899:1990 C Language Standard".
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>state_depend_encoding</term>
- <listitem>
- <para>
-Indicates a current locale is state dependent. The value should be
-specified "True" or "False".
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>wc_encoding_mask</term>
- <listitem>
- <para>
-Specifies a bit-mask for parsing wide-char string. Each wide character is
-applied bit-and operation with this bit-mask, then is classified into
-the unique charset, by using 'wc_encoding'.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>wc_shift_bits</term>
- <listitem>
- <para>
-Specifies a number of bit to be shifted for converting from a multi-byte
-character to a wide character, and vice-versa.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>csN</term>
- <listitem>
- <para>
-<!-- .br -->
-Includes a character set information for Nth charset, where N is the
-index number (0,1,2,...). If there are 4 charsets available in current
-locale, cs0, cs1, cs2 and cs3 should be defined. This class has five
-subclasses, 'side', 'length', 'mb_encoding' 'wc_encoding' and 'ct_encoding'.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>side</term>
- <listitem>
- <para>
-Specifies a mapping side of this charset. The format of this value is;
- </para>
- <literallayout>
- Side ::= EncodingSide[":Default"]
- </literallayout>
- <para>
-The suffix ":Default" can be specified. It indicates that a character
-belongs to the specified side is mapped to this charset in initial state.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>length</term>
- <listitem>
- <para>
-<!-- .br -->
-Specifies a number of bytes of a multi-byte character of this charset.
-It should not contain the length of any single-shift sequence.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>mb_encoding</term>
- <listitem>
- <para>
-Specifies a list of shift sequence for parsing multi-byte string.
-The format of this value is;
- </para>
-<informaltable frame="none">
- <tgroup cols='3' align='left'>
- <colspec colname='c1' colwidth="3*" colsep="0"/>
- <colspec colname='c2' colwidth="1*" colsep="0"/>
- <colspec colname='c3' colwidth="5*" colsep="0"/>
- <tbody>
- <row rowsep="0">
- <entry>MBEncoding</entry>
- <entry>::=</entry>
- <entry>ShiftType ShiftSequence</entry>
- </row>
- <row rowsep="0">
- <entry></entry>
- <entry>|</entry>
- <entry>ShiftType ShiftSequence ";" MBEncoding</entry>
- </row>
- <row rowsep="0">
- <entry>ShiftType</entry>
- <entry>::=</entry>
- <entry>"<SS>"|"<LSL>"|"<LSR>"</entry>
- </row>
- <row rowsep="0">
- <entry>ShiftSequence</entry>
- <entry>::=</entry>
- <entry>SequenceValue|SequenceValue ShiftSequence</entry>
- </row>
- <row rowsep="0">
- <entry>SequenceValue</entry>
- <entry>::=</entry>
- <entry>NumericString</entry>
- </row>
- </tbody>
- </tgroup>
-</informaltable>
-
- <literallayout>
-example:
- <LSL> \x1b \x28 \x4a; <LSL> \x1b \x28 \x42
- </literallayout>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>wc_encoding</term>
- <listitem>
- <para>
-Specifies an integer value for parsing wide-char string.
-It is used to determine the charset for each wide character, after
-applying bit-and operation using 'wc_encoding_mask'.
-This value should be unique in all csN classes.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>ct_encoding</term>
- <listitem>
- <para>
-Specifies a list of encoding information that can be used for Compound
-Text.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</sect1>
-
-<sect1 id="Sample_of_X_Locale_Database">
-<title>Sample of X Locale Database</title>
-<para>
-The following is sample X Locale Database file.
-</para>
-
-<literallayout class="monospaced">
-# XLocale Database Sample for ja_JP.euc
-#
-
-#
-# XLC_FONTSET category
-#
-XLC_FONTSET
-# fs0 class (7 bit ASCII)
-fs0 {
- charset ISO8859-1:GL
- font ISO8859-1:GL; JISX0201.1976-0:GL
-}
-# fs1 class (Kanji)
-fs1 {
- charset JISX0208.1983-0:GL
- font JISX0208.1983-0:GL
-}
-# fs2 class (Half Kana)
-fs2 {
- charset JISX0201.1976-0:GR
- font JISX0201.1976-0:GR
-}
-# fs3 class (User Defined Character)
-# fs3 {
-# charset JISX0212.1990-0:GL
-# font JISX0212.1990-0:GL
-# }
-END XLC_FONTSET
-
-#
-# XLC_XLOCALE category
-#
-XLC_XLOCALE
-
-encoding_name ja.euc
-mb_cur_max 3
-state_depend_encoding False
-
-wc_encoding_mask \x00008080
-wc_shift_bits 8
-
-# cs0 class
-cs0 {
- side GL:Default
- length 1
- wc_encoding \x00000000
- ct_encoding ISO8859-1:GL; JISX0201.1976-0:GL
-}
-# cs1 class
-cs1 {
- side GR:Default
- length 2
-
- wc_encoding \x00008080
-
- ct_encoding JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
- JISX0208.1983-1:GL; JISX0208.1983-1:GR
-}
-
-# cs2 class
-cs2 {
- side GR
- length 1
- mb_encoding <SS> \x8e
-
- wc_encoding \x00000080
-
- ct_encoding JISX0201.1976-0:GR
-}
-
-# cs3 class
-# cs3 {
-# side GL
-# length 2
-# mb_encoding <SS> \x8f
-# #if HasWChar32
-# wc_encoding \x20000000
-# #else
-# wc_encoding \x00008000
-# #endif
-# ct_encoding JISX0212.1990-0:GL; JISX0212.1990-0:GR
-# }
-
-END XLC_XLOCALE
-</literallayout>
-</sect1>
-
-<sect1 id="Reference">
-<title>Reference</title>
-<para>
-[1] <emphasis remap='I'>ISO/IEC 9899:1990 C Language Standard</emphasis>
-</para>
-<para>
-[2] <emphasis remap='I'>X Logical Font Descriptions</emphasis>
-</para>
-
-</sect1>
-</chapter>
-</book>
+<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> + +<book id="localedb"> + +<bookinfo> + <title>X Locale Database Specification</title> + <authorgroup> + <author> + <firstname>Yoshio</firstname><surname>Horiuchi</surname> + <affiliation><orgname>IBM Japan</orgname></affiliation> + </author> + </authorgroup> + <copyright><year>1994</year><holder>IBM Corporation</holder></copyright> + <copyright><year>1994</year><holder>X Consortium</holder></copyright> + + +<legalnotice> + +<para> +License to use, copy, modify, and distribute this software and its documentation for +any purpose and without fee is hereby granted, provided that the above copyright notice +appear in all copies and that both that copyright notice and this permission notice +appear in supporting documentation, and that the name of IBM not be used in advertising +or publicity pertaining to distribution of the software without specific, written +prior permission. +</para> +<para> +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY, FITNESS, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS, +IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES +OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN +AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +</para> + +<para> +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: +</para> + +<para> +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +</para> + +<para> +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +</para> + +<para> +Except as contained in this notice, the name of The Open Group shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from X Consortium. +</para> + +<para>X Window System is a trademark of The Open Group.</para> + +</legalnotice> +</bookinfo> + +<chapter id="localeDatabase"> +<title>LocaleDB</title> + +<sect1 id="General"> +<title>General</title> +<para> +An X Locale Database contains the subset of a user's environment that +depends on language, in X Window System. It is made up from one or more +categories. Each category consists of some classes and sub-classes. +</para> + +<para> +It is provided as a plain ASCII text file, so a user can change its +contents easily. It allows a user to customize the behavior of +internationalized portion of Xlib without changing Xlib itself. +</para> + +<para> +This document describes; +</para> + +<itemizedlist> + <listitem> + <para> +Database Format Definition + </para> + </listitem> + <listitem> + <para> +Contents of Database in sample implementation +<!-- .RE --> + </para> + </listitem> +</itemizedlist> + +<para> +Since it is hard to define the set of required information for all +platforms, only the flexible database format is defined. +The available entries in database are implementation dependent. +</para> + +</sect1> +<sect1 id="Database_Format_Definition"> +<title>Database Format Definition</title> +<para> +The X Locale Database contains one or more category definitions. +This section describes the format of each category definition. +</para> + +<para> +The category definition consists of one or more class definitions. +Each class definition has a pair of class name and class value, or +has several subclasses which are enclosed by the left brace ({) and +the right brace (}). +</para> + +<para> +Comments can be placed by using the number sign character (#). +Putting the number sign character on the top of the line indicates +that the entire line is comment. Also, putting any whitespace character +followed by the number sign character indicates that a part of the line +(from the number sign to the end of the line) is comment. +A line can be continued by placing backslash (\) character as the +last character on the line; this continuation character will be +discarded from the input. Comment lines cannot be continued on +a subsequent line using an escaped new line character. +</para> + +<para> +X Locale Database only accepts XPCS, the X Portable Character Set. +The reserved symbols are; the quotation mark("), the number sign (#), +the semicolon(;), the backslash(\), the left brace({) and +the right brace(}). +</para> + +<para> +The format of category definition is; +</para> + +<informaltable frame="none"> + <tgroup cols='3' align='left'> + <colspec colname='c1' colwidth="3*" colsep="0"/> + <colspec colname='c2' colwidth="1*" colsep="0"/> + <colspec colname='c3' colwidth="6*" colsep="0"/> + <tbody> + <row rowsep="0"> + <entry>CategoryDefinition</entry> + <entry>::=</entry> + <entry>CategoryHeader CategorySpec CategoryTrailer</entry> + </row> + <row rowsep="0"> + <entry>CategoryHeader</entry> + <entry>::=</entry> + <entry>CategoryName NL</entry> + </row> + <row rowsep="0"> + <entry>CategorySpec</entry> + <entry>::=</entry> + <entry>{ ClassSpec }</entry> + </row> + <row rowsep="0"> + <entry>CategoryTrailer</entry> + <entry>::=</entry> + <entry>"END" Delimiter CategoryName NL</entry> + </row> + <row rowsep="0"> + <entry>CategoryName</entry> + <entry>::=</entry> + <entry>String</entry> + </row> + <row rowsep="0"> + <entry>ClassSpec</entry> + <entry>::=</entry> + <entry>ClassName Delimiter ClassValue NL</entry> + </row> + <row rowsep="0"> + <entry>ClassName</entry> + <entry>::=</entry> + <entry>String</entry> + </row> + <row rowsep="0"> + <entry>ClassValue</entry> + <entry>::=</entry> + <entry>ValueList | "{" NL { ClassSpec } "}"</entry> + </row> + <row rowsep="0"> + <entry>ValueList</entry> + <entry>::=</entry> + <entry>Value | Value ";" ValueList</entry> + </row> + <row rowsep="0"> + <entry>Value</entry> + <entry>::=</entry> + <entry>ValuePiece | ValuePiece Value</entry> + </row> + <row rowsep="0"> + <entry>ValuePiece</entry> + <entry>::=</entry> + <entry>String | QuotedString | NumericString</entry> + </row> + <row rowsep="0"> + <entry>String</entry> + <entry>::=</entry> + <entry>Char { Char }</entry> + </row> + <row rowsep="0"> + <entry>QuotedString</entry> + <entry>::=</entry> + <entry>""" QuotedChar { QuotedChar } """</entry> + </row> + <row rowsep="0"> + <entry>NumericString</entry> + <entry>::=</entry> + <entry>"\\o" OctDigit { OctDigit }</entry> + </row> + <row rowsep="0"> + <entry></entry> + <entry>|</entry> + <entry>"\\d" DecDigit { DecDigit }</entry> + </row> + <row rowsep="0"> + <entry></entry> + <entry>|</entry> + <entry>"\\x" HexDigit { HexDigit }</entry> + </row> + <row rowsep="0"> + <entry>Char</entry> + <entry>::=</entry> + <entry><XPCS except NL, Space or unescaped reserved symbols></entry> + </row> + <row rowsep="0"> + <entry>QuotedChar</entry> + <entry>::=</entry> + <entry><XPCS except unescaped """></entry> + </row> + <row rowsep="0"> + <entry>OctDigit</entry> + <entry>::=</entry> + <entry><character in the range of "0" - "7"></entry> + </row> + <row rowsep="0"> + <entry>DecDigit</entry> + <entry>::=</entry> + <entry><character in the range of "0" - "9"></entry> + </row> + <row rowsep="0"> + <entry>HexDigit</entry> + <entry>::=</entry> + <entry><character in the range of "0" - "9", "a" - "f", "A" - "F"></entry> + </row> + <row rowsep="0"> + <entry>Delimiter</entry> + <entry>::=</entry> + <entry>Space { Space }</entry> + </row> + <row rowsep="0"> + <entry>Space</entry> + <entry>::=</entry> + <entry><space> | <horizontal tab></entry> + </row> + <row rowsep="0"> + <entry>NL</entry> + <entry>::=</entry> + <entry><newline></entry> + </row> + </tbody> + </tgroup> +</informaltable> + +<para> +Elements separated by vertical bar (|) are alternatives. Curly +braces ({...}) indicate zero or more repetitions of the enclosed +elements. Square brackets ([...]) indicate that the enclosed element +is optional. Quotes ("...") are used around literal characters. +</para> + +<para> +The backslash, which is not the top character of the NumericString, is +recognized as an escape character, so that the next one character is +treated as a literal character. For example, the two-character +sequence, ""\"""(the backslash followed by the quotation mark) is +recognized and replaced with a quotation mark character. +Any whitespace character, that is not the Delimiter, unquoted and +unescaped, is ignored. +</para> + +</sect1> +<sect1 id="Contents_of_Database_"> +<title>Contents of Database </title> +<para> +The available categories and classes depend on implementation, because +different platform will require different information set. +For example, some platform have system locale but some platform don't. +Furthermore, there might be a difference in functionality even if the +platform has system locale. +</para> + +<para> +In current sample implementation, categories listed below are available. +</para> + +<informaltable frame="none"> + <tgroup cols='3' align='left'> + <colspec colname='c1' colwidth="2*" colsep="0"/> + <colspec colname='c2' colwidth="1*" colsep="0"/> + <tbody> + <row rowsep="0"> + <entry>XLC_FONTSET:XFontSet relative information</entry> + </row> + <row rowsep="0"> + <entry>XLC_XLOCALE:Character classification and conversion information</entry> + </row> + </tbody> + </tgroup> +</informaltable> + +</sect1> +<sect1 id="XLC_FONTSET_Category"> +<title>XLC_FONTSET Category</title> +<para> +The XLC_FONTSET category defines the XFontSet relative information. +It contains the CHARSET_REGISTRY-CHARSET_ENCODING name and character +mapping side (GL, GR, etc), and is used in Output Method (OM). +</para> + +<informaltable frame="none"> + <tgroup cols='3' align='left'> + <thead> + <colspec colname='c1' colwidth="3*" colsep="0"/> + <colspec colname='c2' colwidth="1*" colsep="0"/> + <colspec colname='c3' colwidth="3*" colsep="0"/> + <row> + <entry>class</entry> + <entry>super class</entry> + <entry>description</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>fsN</entry> + <entry></entry> + <entry>Nth fontset (N=0,1,2, ...)</entry> + </row> + <row rowsep="0"> + <entry>charset</entry> + <entry>fsN</entry> + <entry>list of encoding name</entry> + </row> + <row rowsep="0"> + <entry>font</entry> + <entry>fsN</entry> + <entry>list of font encoding name</entry> + </row> + </tbody> + </tgroup> +</informaltable> + +<variablelist> + <varlistentry> + <term>fsN</term> + <listitem> + <para> +Includes an encoding information for Nth charset, where N is +the index number (0,1,2,...). If there are 4 charsets available +in current locale, 4 fontsets, fs0, fs1, fs2 and fs3, should be +defined. +This class has two subclasses, 'charset' and 'font'. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>charset</term> + <listitem> + <para> +Specifies an encoding information to be used internally in Xlib +for this fontset. The format of value is; + </para> +<informaltable frame="none"> + <tgroup cols='3' align='left'> + <colspec colname='c1' colwidth="3*" colsep="0"/> + <colspec colname='c2' colwidth="1*" colsep="0"/> + <colspec colname='c3' colwidth="4*" colsep="0"/> + <tbody> + <row rowsep="0"> + <entry>EncodingInfo</entry> + <entry>::=</entry> + <entry>EncodingName [ ":" EncodingSide ]</entry> + </row> + <row rowsep="0"> + <entry>EncodingName</entry> + <entry>::=</entry> + <entry>CHARSET_REGISTRY-CHARSET_ENCODING</entry> + </row> + <row rowsep="0"> + <entry>EncodingSide</entry> + <entry>::=</entry> + <entry>"GL" | "GR"</entry> + </row> + </tbody> + </tgroup> +</informaltable> + +<para> +For detail definition of CHARSET_REGISTRY-CHARSET_ENCODING, refer +"X Logical Font Descriptions" document. +</para> +<literallayout> +example: + ISO8859-1:GL +</literallayout> + </listitem> + </varlistentry> + <varlistentry> + <term>font</term> + <listitem> + <para> +Specifies a list of encoding information which is used for searching +appropriate font for this fontset. The left most entry has highest +priority. + </para> + </listitem> + </varlistentry> +</variablelist> + +</sect1> +<sect1 id="XLC_XLOCALE_Category"> +<title>XLC_XLOCALE Category</title> +<para> +The XLC_XLOCALE category defines character classification, conversion +and other character attributes. +</para> + +<informaltable frame="none"> + <tgroup cols='3' align='left'> + <colspec colname='c1' colwidth="3*" colsep="0"/> + <colspec colname='c2' colwidth="1*" colsep="0"/> + <colspec colname='c3' colwidth="3*" colsep="0"/> + <thead> + <row> + <entry>class</entry> + <entry>super class</entry> + <entry>description</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>encoding_name</entry> + <entry></entry> + <entry>codeset name</entry> + </row> + <row rowsep="0"> + <entry>mb_cur_max</entry> + <entry></entry> + <entry>MB_CUR_MAX</entry> + </row> + <row rowsep="0"> + <entry>state_depend_encoding</entry> + <entry></entry> + <entry>state dependent or not</entry> + </row> + <row rowsep="0"> + <entry>wc_encoding_mask</entry> + <entry></entry> + <entry>for parsing wc string</entry> + </row> + <row rowsep="0"> + <entry>wc_shift_bits</entry> + <entry></entry> + <entry>for conversion between wc and mb</entry> + </row> + <row rowsep="0"> + <entry>csN</entry> + <entry></entry> + <entry>Nth charset (N=0,1,2,...)</entry> + </row> + <row rowsep="0"> + <entry>side</entry> + <entry>csN</entry> + <entry>mapping side (GL, etc)</entry> + </row> + <row rowsep="0"> + <entry>length</entry> + <entry>csN</entry> + <entry>length of a character</entry> + </row> + <row rowsep="0"> + <entry>mb_encoding</entry> + <entry>csN</entry> + <entry>for parsing mb string</entry> + </row> + <row rowsep="0"> + <entry>wc_encoding</entry> + <entry>csN</entry> + <entry>for parsing wc string</entry> + </row> + <row rowsep="0"> + <entry>ct_encoding</entry> + <entry>csN</entry> + <entry>list of encoding name for ct</entry> + </row> + </tbody> + </tgroup> +</informaltable> + +<variablelist> + <varlistentry> + <term>encoding_name</term> + <listitem> + <para> +Specifies a codeset name of current locale. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>mb_cur_max</term> + <listitem> + <para> +Specifies a maximum allowable number of bytes in a multi-byte character. +It is corresponding to MB_CUR_MAX of "ISO/IEC 9899:1990 C Language Standard". + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>state_depend_encoding</term> + <listitem> + <para> +Indicates a current locale is state dependent. The value should be +specified "True" or "False". + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>wc_encoding_mask</term> + <listitem> + <para> +Specifies a bit-mask for parsing wide-char string. Each wide character is +applied bit-and operation with this bit-mask, then is classified into +the unique charset, by using 'wc_encoding'. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>wc_shift_bits</term> + <listitem> + <para> +Specifies a number of bit to be shifted for converting from a multi-byte +character to a wide character, and vice-versa. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>csN</term> + <listitem> + <para> +<!-- .br --> +Includes a character set information for Nth charset, where N is the +index number (0,1,2,...). If there are 4 charsets available in current +locale, cs0, cs1, cs2 and cs3 should be defined. This class has five +subclasses, 'side', 'length', 'mb_encoding' 'wc_encoding' and 'ct_encoding'. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>side</term> + <listitem> + <para> +Specifies a mapping side of this charset. The format of this value is; + </para> + <literallayout> + Side ::= EncodingSide[":Default"] + </literallayout> + <para> +The suffix ":Default" can be specified. It indicates that a character +belongs to the specified side is mapped to this charset in initial state. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>length</term> + <listitem> + <para> +<!-- .br --> +Specifies a number of bytes of a multi-byte character of this charset. +It should not contain the length of any single-shift sequence. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>mb_encoding</term> + <listitem> + <para> +Specifies a list of shift sequence for parsing multi-byte string. +The format of this value is; + </para> +<informaltable frame="none"> + <tgroup cols='3' align='left'> + <colspec colname='c1' colwidth="3*" colsep="0"/> + <colspec colname='c2' colwidth="1*" colsep="0"/> + <colspec colname='c3' colwidth="5*" colsep="0"/> + <tbody> + <row rowsep="0"> + <entry>MBEncoding</entry> + <entry>::=</entry> + <entry>ShiftType ShiftSequence</entry> + </row> + <row rowsep="0"> + <entry></entry> + <entry>|</entry> + <entry>ShiftType ShiftSequence ";" MBEncoding</entry> + </row> + <row rowsep="0"> + <entry>ShiftType</entry> + <entry>::=</entry> + <entry>"<SS>"|"<LSL>"|"<LSR>"</entry> + </row> + <row rowsep="0"> + <entry>ShiftSequence</entry> + <entry>::=</entry> + <entry>SequenceValue|SequenceValue ShiftSequence</entry> + </row> + <row rowsep="0"> + <entry>SequenceValue</entry> + <entry>::=</entry> + <entry>NumericString</entry> + </row> + </tbody> + </tgroup> +</informaltable> + + <literallayout> +example: + <LSL> \x1b \x28 \x4a; <LSL> \x1b \x28 \x42 + </literallayout> + </listitem> + </varlistentry> + <varlistentry> + <term>wc_encoding</term> + <listitem> + <para> +Specifies an integer value for parsing wide-char string. +It is used to determine the charset for each wide character, after +applying bit-and operation using 'wc_encoding_mask'. +This value should be unique in all csN classes. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>ct_encoding</term> + <listitem> + <para> +Specifies a list of encoding information that can be used for Compound +Text. + </para> + </listitem> + </varlistentry> +</variablelist> +</sect1> + +<sect1 id="Sample_of_X_Locale_Database"> +<title>Sample of X Locale Database</title> +<para> +The following is sample X Locale Database file. +</para> + +<literallayout class="monospaced"> +# XLocale Database Sample for ja_JP.euc +# + +# +# XLC_FONTSET category +# +XLC_FONTSET +# fs0 class (7 bit ASCII) +fs0 { + charset ISO8859-1:GL + font ISO8859-1:GL; JISX0201.1976-0:GL +} +# fs1 class (Kanji) +fs1 { + charset JISX0208.1983-0:GL + font JISX0208.1983-0:GL +} +# fs2 class (Half Kana) +fs2 { + charset JISX0201.1976-0:GR + font JISX0201.1976-0:GR +} +# fs3 class (User Defined Character) +# fs3 { +# charset JISX0212.1990-0:GL +# font JISX0212.1990-0:GL +# } +END XLC_FONTSET + +# +# XLC_XLOCALE category +# +XLC_XLOCALE + +encoding_name ja.euc +mb_cur_max 3 +state_depend_encoding False + +wc_encoding_mask \x00008080 +wc_shift_bits 8 + +# cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding ISO8859-1:GL; JISX0201.1976-0:GL +} +# cs1 class +cs1 { + side GR:Default + length 2 + + wc_encoding \x00008080 + + ct_encoding JISX0208.1983-0:GL; JISX0208.1983-0:GR;\ + JISX0208.1983-1:GL; JISX0208.1983-1:GR +} + +# cs2 class +cs2 { + side GR + length 1 + mb_encoding <SS> \x8e + + wc_encoding \x00000080 + + ct_encoding JISX0201.1976-0:GR +} + +# cs3 class +# cs3 { +# side GL +# length 2 +# mb_encoding <SS> \x8f +# #if HasWChar32 +# wc_encoding \x20000000 +# #else +# wc_encoding \x00008000 +# #endif +# ct_encoding JISX0212.1990-0:GL; JISX0212.1990-0:GR +# } + +END XLC_XLOCALE +</literallayout> +</sect1> + +<sect1 id="Reference"> +<title>Reference</title> +<para> +[1] <emphasis remap='I'>ISO/IEC 9899:1990 C Language Standard</emphasis> +</para> +<para> +[2] <emphasis remap='I'>X Logical Font Descriptions</emphasis> +</para> + +</sect1> +</chapter> +</book> diff --git a/libX11/specs/i18n/trans/trans.xml b/libX11/specs/i18n/trans/trans.xml index 9a01d97f6..c8447f934 100644 --- a/libX11/specs/i18n/trans/trans.xml +++ b/libX11/specs/i18n/trans/trans.xml @@ -1,1979 +1,1979 @@ -<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
- "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
-
-<book id="xtransportspec">
-
-<bookinfo>
- <title>The XIM Transport Specification</title>
- <subtitle>Revision 0.1</subtitle>
- <releaseinfo>X Version 11, Release 7</releaseinfo>
- <authorgroup>
- <author>
- <firstname>Takashi</firstname><surname>Fujiwara</surname>
- <affiliation><orgname>FUJITSU LIMITED</orgname></affiliation>
- </author>
- </authorgroup>
- <copyright><year>1994</year><holder>FUJITSU LIMITED</holder></copyright>
- <copyright><year>1994</year><holder>X Consortium</holder></copyright>
-
- <productnumber>Revision 0.1</productnumber>
-
-
-<abstract>
-<para>
-This specification describes the transport layer interfaces between Xlib and IM Server,
-which makes various channels usable such as X protocol or TCP/IP, DECnet and etc.
-</para>
-</abstract>
-
-<legalnotice>
-
-<para>
-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:
-</para>
-
-<para>
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-</para>
-
-<para>
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-</para>
-
-<para>
-Except as contained in this notice, the name of The Open Group shall not
-be used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from X Consortium.
-</para>
-
-<para>X Window System is a trademark of The Open Group.</para>
-
-</legalnotice>
-</bookinfo>
-
-<chapter id="xim_transport_specification">
-<title>X Transport Specification</title>
-
-<sect1 id="Introduction">
-<title>Introduction</title>
-<!-- .XS -->
-<!-- (SN Introduction -->
-<!-- .XE -->
-<para>
-<!-- .LP -->
-The Xlib XIM implementation is layered into three functions, a protocol
-layer, an interface layer and a transport layer. The purpose of this
-layering is to make the protocol independent of transport implementation.
-Each function of these layers are:
-<!-- .RS 3 -->
-</para>
-<variablelist>
- <varlistentry>
- <term><emphasis>The protocol layer</emphasis></term>
- <listitem>
- <para>
-implements overall function of XIM and calls the interface layer
-functions when it needs to communicate to IM Server.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><emphasis>The interface layer</emphasis></term>
- <listitem>
- <para>
-separates the implementation of the transport layer from the protocol
-layer, in other words, it provides implementation independent hook for
-the transport layer functions.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term><emphasis>The transport layer</emphasis></term>
- <listitem>
- <para>
-handles actual data communication with IM Server. It is done by a set
-of several functions named transporters.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-<para>
-This specification describes the interface layer and the transport
-layer, which makes various communication channels usable such as
-X protocol or, TCP/IP, DECnet, STREAM, etc., and provides
-the information needed for adding another new transport layer.
-In addition, sample implementations for the transporter using the
-X connection is described in section 4. <!-- xref -->
-</para>
-</sect1>
-
-<sect1 id="Initialization">
-<title>Initialization</title>
-
-<sect2 id="Registering_structure_to_initialize">
-<title>Registering structure to initialize</title>
-
-<para>
-The structure typed as TransportSW contains the list of the transport
-layer the specific implementations supports.
-</para>
-
-<literallayout class="monospaced">
-typedef struct {
- char *transport_name;
- Bool (*config);
-} TransportSW;
-</literallayout>
-
-<informaltable frame="none">
- <tgroup cols="2">
- <colspec colname="col1" colwidth="1*" colsep="0"/>
- <colspec colname="col2" colwidth="1*" colsep="0"/>
- <tbody>
- <row rowsep="0">
- <entry><emphasis>transport_name</emphasis></entry>
- <entry>name of transport<footnote><para>Refer to "The Input Method Protocol: Appendix B</para></footnote></entry>
- </row>
- <row rowsep="0">
- <entry><emphasis>config</emphasis></entry>
- <entry>initial configuration function</entry>
- </row>
- </tbody>
- </tgroup>
-</informaltable>
-
-<para>
-A sample entry for the Xlib supporting transporters is shown below:
-</para>
-
-<literallayout class="monospaced">
-TransportSW _XimTransportRec[] = {
-/* char <emphasis remap='I'>*</emphasis>:
- * transport_name, Bool <emphasis remap='I'>(*config)()</emphasis>
- */
- "X", _XimXConf,
- "tcp", _XimTransConf,
- "local", _XimTransConf,
- "decnet", _XimTransConf,
- "streams", _XimTransConf,
- (char *)NULL, (Bool (*)())NULL,
-};
-</literallayout>
-
-</sect2>
-<sect2 id="Initialization_function">
-<title>Initialization function</title>
-<!-- .XS -->
-<!-- (SN Initialization function -->
-<!-- .XE -->
-<para>
-The following function will be called once when Xlib configures the
-transporter functions.
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function>(*config)</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
- <paramdef>char<parameter> *transport_data</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>transport_data</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the data specific to the transporter, in IM Server address.<footnote><para>Refer to "The Input Method Protocol: Appendix B</para></footnote>
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-<para>
-This function must setup the transporter function pointers.
-</para>
-
-<para>
-<!-- .LP -->
-The actual <emphasis remap='I'>config</emphasis> function will be chosen by IM Server at the
-pre-connection time, matching by the <emphasis remap='I'>transport_name</emphasis> specified
-in the <function>_XimTransportRec</function> array; The specific members of XimProto
-structure listed below must be initialized so that point they
-appropriate transporter functions.
-</para>
-
-<para>
-If the specified transporter has been configured successfully, this
-function returns True. There is no Alternative Entry for config
-function itself.
-</para>
-
-<para>
-The structure XimProto contains the following function pointers:
-</para>
-
-<literallayout class="monospaced">
-Bool (*connect)(); /* Open connection */
-Bool (*shutdown)(); /* Close connection */
-Bool (*write)(); /* Write data */
-Bool (*read)(); /* Read data */
-Bool (*flush)(); /* Flush data buffer */
-Bool (*register_dispatcher)(); /* Register asynchronous data handler */
-Bool (*call_dispatcher)(); /* Call dispatcher */
-</literallayout>
-
-<para>
-These functions are called when Xlib needs to communicate the
-IM Server. These functions must process the appropriate procedure
-described below.
-</para>
-
-</sect2>
-</sect1>
-<sect1 id="The_interface_transport_layer_functions">
-<title>The interface/transport layer functions</title>
-<para>
-Following functions are used for the transport interface.
-</para>
-
-<table frame="all" id="transport_layer_functions_2">
- <title>The Transport Layer Functions</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="3*" colsep="1"/>
- <colspec colname="col2" colwidth="3*" colsep="1"/>
- <colspec colname="col3" colwidth="1*" colsep="1"/>
- <thead>
- <row>
- <entry align="center">Alternate Entry (Interface Layer)</entry>
- <entry align="center">XimProto member (Transport Layer)</entry>
- <entry align="center">Section</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>_XimConnect</entry>
- <entry>connect</entry>
- <entry>3.1</entry>
- </row>
- <row>
- <entry>_XimShutdown</entry>
- <entry>shutdown</entry>
- <entry>3.2</entry>
- </row>
- <row>
- <entry>_XimWrite</entry>
- <entry>write</entry>
- <entry>3.3</entry>
- </row>
- <row>
- <entry>_XimRead</entry>
- <entry>read</entry>
- <entry>3.4</entry>
- </row>
- <row>
- <entry>_XimFlush</entry>
- <entry>flush</entry>
- <entry>3.5</entry>
- </row>
- <row>
- <entry>_XimRegisterDispatcher</entry>
- <entry>register_dispatcher</entry>
- <entry>3.6</entry>
- </row>
- <row>
- <entry>_XimCallDispatcher</entry>
- <entry>call_dispatcher</entry>
- <entry>3.7</entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-
-<para>
-The Protocol layer calls the above functions using the Alternative
-Entry in the left column. The transport implementation defines
-XimProto member function in the right column. The Alternative Entry is
-provided so as to make easier to implement the Protocol Layer.
-</para>
-
-<sect2 id="Opening_connection">
-<title>Opening connection</title>
-<para>
-<!-- .LP -->
-When <function>XOpenIM</function> is called, the following function is called to connect
-with the IM Server.
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function>(*connect)</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-<para>
-This function must establishes the connection to the IM Server. If the
-connection is established successfully, this function returns True.
-The Alternative Entry for this function is:
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function> _XimConnect</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</sect2>
-
-<sect2 id="Closing_connection">
-<title>Closing connection</title>
-<!-- .XS -->
-<!-- (SN Closing connection -->
-<!-- .XE -->
-<para>
-<!-- .LP -->
-When <function>XCloseIM</function> is called, the following function is called to
-disconnect the connection with the IM Server. The Alternative Entry
-for this function is:
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function> (*shutdown)</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-<para>
-<!-- .LP -->
-This function must close connection with the IM Server. If the
-connection is closed successfully, this function returns True. The
-Alternative Entry for this function is:
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function>_XimShutdown</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-</sect2>
-
-<sect2 id="Writing_data">
-<title>Writing data</title>
-<para>
-The following function is called, when Xlib needs to write data to the
-IM Server.
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function> _XimWrite</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
- <paramdef>INT16<parameter> len</parameter></paramdef>
- <paramdef>XPointer<parameter> data</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>len</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the length of writing data.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>data</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the writing data.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-<para>
-This function writes the <emphasis remap='I'>data</emphasis> to the IM Server, regardless
-of the contents. The number of bytes is passed to <emphasis remap='I'>len</emphasis>. The
-writing data is passed to <emphasis remap='I'>data</emphasis>. If data is sent successfully,
-the function returns True. Refer to "The Input Method Protocol" for
-the contents of the writing data. The Alternative Entry for this
-function is:
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function>_XimWrite</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
- <paramdef>INT16<parameter> len</parameter></paramdef>
- <paramdef>XPointer<parameter> data</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>len</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the length of writing data.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>data</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the writing data.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-</sect2>
-<sect2 id="Reading_data">
-<title>Reading data</title>
-<para>
-The following function is called when Xlib waits for response from IM
-server synchronously.
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function> _XimRead</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
- <paramdef>XPointer<parameter> read_buf</parameter></paramdef>
- <paramdef>int<parameter> buf_len</parameter></paramdef>
- <paramdef>int<parameter> *ret_len</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>read_buf</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the buffer to store data.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>buf_len</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the size of the <emphasis remap='I'>buffer</emphasis>
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>ret_len</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the length of stored data.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-<para>
-This function stores the read data in <emphasis remap='I'>read_buf</emphasis>, which size is
-specified as <emphasis remap='I'>buf_len</emphasis>. The size of data is set to <emphasis remap='I'>ret_len</emphasis>.
-This function return True, if the data is read normally or reading
-data is completed.
-</para>
-<para>
-The Alternative Entry for this function is:
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function> _XimRead</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
- <paramdef>INT16<parameter> *ret_len</parameter></paramdef>
- <paramdef>XPointer<parameter> buf</parameter></paramdef>
- <paramdef>int<parameter> buf_len</parameter></paramdef>
- <paramdef>Bool<parameter> (*predicate)()</parameter></paramdef>
- <paramdef>XPointer<parameter> predicate_arg</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>ret_len</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the size of the <emphasis remap='I'>data</emphasis> buffer.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>buf</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the buffer to store data.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>buf_len</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the length of <emphasis remap='I'>buffer</emphasis>.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>predicate</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the predicate for the XIM data.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>predicate_arg</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the predicate specific data.
-<!-- .sp 6p -->
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-<para>
-The predicate procedure indicates whether the <emphasis remap='I'>data</emphasis> is for the
-XIM or not. <emphasis remap='I'>len</emphasis>
-This function stores the read data in <emphasis remap='I'>buf</emphasis>, which size
-is specified as <emphasis remap='I'>buf_len</emphasis>. The size of data is set to
-<emphasis remap='I'>ret_len</emphasis>. If <emphasis remap='I'>preedicate()</emphasis>
-returns True, this function returns True. If not, it calls the registered callback function.
-</para>
-
-<para>
-The procedure and its arguments are:
-</para>
-
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>void <function>(*predicate)</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
- <paramdef>INT16<parameter> len</parameter></paramdef>
- <paramdef>XPointer<parameter> data</parameter></paramdef>
- <paramdef>XPointer<parameter> predicate_arg</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>len</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the size of the <emphasis remap='I'>data</emphasis> buffer.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>data</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the buffer to store data.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>predicate_arg</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the predicate specific data.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-</sect2>
-<sect2 id="Flushing_buffer">
-<title>Flushing buffer</title>
-<para>
-The following function is called when Xlib needs to flush the data.
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>void <function>(*flush)</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-<para>
-This function must flush the data stored in internal buffer on the
-transport layer. If data transfer is completed, the function returns
-True. The Alternative Entry for this function is:
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>void <function> _XimFlush</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-</sect2>
-<sect2 id="Registering_asynchronous_data_handler">
-<title>Registering asynchronous data handler</title>
-<para>
-Xlib needs to handle asynchronous response from IM Server. This is
-because some of the XIM data occur asynchronously to X events.
-</para>
-
-<para>
-Those data will be handled in the <emphasis remap='I'>Filter</emphasis>,
-and the <emphasis remap='I'>Filter</emphasis>
-will call asynchronous data handler in the protocol layer. Then it
-calls dispatchers in the transport layer. The dispatchers are
-implemented by the protocol layer. This function must store the
-information and prepare for later call of the dispatchers using
-<function>_XimCallDispatcher</function>.
-</para>
-
-<para>
-When multiple dispatchers are registered, they will be called
-sequentially in order of registration, on arrival of asynchronous
-data. The register_dispatcher is declared as following:
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function>(*register_dispatcher)</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
- <paramdef>Bool<parameter> (*dispatcher)()</parameter></paramdef>
- <paramdef>XPointer<parameter> call_data</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>dispatcher</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the dispatcher function to register.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>call_data</emphasis>
- </term>
- <listitem>
- <para>
-Specifies a parameter for the <emphasis remap='I'>dispatcher</emphasis>.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-<para>
-The dispatcher is a function of the following type:
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function>(*dispatcher)</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
- <paramdef>INT16<parameter> len</parameter></paramdef>
- <paramdef>XPointer<parameter> data</parameter></paramdef>
- <paramdef>XPointer<parameter> call_data</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>len</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the size of the <emphasis remap='I'>data</emphasis> buffer.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>data</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the buffer to store data.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>call_data</emphasis>
- </term>
- <listitem>
- <para>
-Specifies a parameter passed to the register_dispatcher.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-<para>
-The dispatcher is provided by the protocol layer. They are called once
-for every asynchronous data, in order of registration. If the data is
-used, it must return True. otherwise, it must return False.
-</para>
-
-<para>
-If the dispatcher function returns True, the Transport Layer assume
-that the data has been processed by the upper layer. The Alternative
-Entry for this function is:
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function> _XimRegisterDispatcher</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
- <paramdef>Bool<parameter> (*dispatcher)()</parameter></paramdef>
- <paramdef>XPointer<parameter> call_data</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>dispatcher</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the dispatcher function to register.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>call_data</emphasis>
- </term>
- <listitem>
- <para>
-Specifies a parameter for the <emphasis remap='I'>dispatcher</emphasis>.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-</sect2>
-<sect2 id="Calling_dispatcher">
-<title>Calling dispatcher</title>
-<para>
-The following function is used to call the registered dispatcher
-function, when the asynchronous response from IM Server has arrived.
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function>(*call_dispatcher)</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
- <paramdef>INT16<parameter> len</parameter></paramdef>
- <paramdef>XPointer<parameter> data</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>im</emphasis>
- </term>
- <listitem>
- <para>
-Specifies XIM structure address.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>len</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the size of <emphasis remap='I'>data</emphasis> buffer.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>data</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the buffer to store data.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-
-<para>
-The call_dispatcher must call the dispatcher function, in order of
-their registration. <emphasis remap='I'>len</emphasis> and <emphasis remap='I'>data</emphasis> are the data passed to
-register_dispatcher.
-</para>
-
-<para>
-The return values are checked at each invocation, and if it finds
-True, it immediately return with true for its return value.
-</para>
-
-<para>
-It is depend on the upper layer whether the read data is XIM
-Protocol packet unit or not.
-The Alternative Entry for this function is:
-</para>
-
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function> _XimCallDispatcher</function></funcdef>
- <paramdef>XIM<parameter> im</parameter></paramdef>
- <paramdef>INT16<parameter> len</parameter></paramdef>
- <paramdef>XPointer<parameter> call_data</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-
-</sect2>
-</sect1>
-<sect1 id="Sample_implementations_for_the_Transport_Layer">
-<title>Sample implementations for the Transport Layer</title>
-<para>
-Sample implementations for the transporter using the X connection is
-described here.
-</para>
-
-<sect2 id="X_Transport">
-<title>X Transport</title>
-<para>
-At the beginning of the X Transport connection for the XIM transport
-mechanism, two different windows must be created either in an Xlib XIM
-or in an IM Server, with which the Xlib and the IM Server exchange the
-XIM transports by using the ClientMessage events and Window Properties.
-In the following, the window created by the Xlib is referred as the
-"client communication window", and on the other hand, the window created
-by the IM Server is referred as the "IMS communication window".
-</para>
-
-<sect3 id="Connection">
-<title>Connection</title>
-<para>
-In order to establish a connection, a communication window is created.
-A ClientMessage in the following event's format is sent to the owner
-window of XIM_SERVER selection, which the IM Server has created.
-</para>
-
-<para>
-<!-- .LP -->
-Refer to "The Input Method Protocol" for the XIM_SERVER atom.
-</para>
-
-<table frame="none" id="transport_layer_functions">
- <title>The ClientMessage sent to the IMS window.</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="1*" colsep="0"/>
- <colspec colname="col2" colwidth="1*" colsep="1"/>
- <colspec colname="col3" colwidth="3.5*" colsep="0"/>
- <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/>
- <thead>
- <row>
- <entry align="left" spanname="span-horiz">Structure Member</entry>
- <entry align="left">Contents</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>int</entry>
- <entry>type</entry>
- <entry>ClientMessage</entry>
- </row>
- <row rowsep="0">
- <entry>u_long</entry>
- <entry>serial</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Bool</entry>
- <entry>send_event</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Display</entry>
- <entry>*display</entry>
- <entry>The display to which connects</entry>
- </row>
- <row rowsep="0">
- <entry>Window</entry>
- <entry>window</entry>
- <entry>IMS Window ID</entry>
- </row>
- <row rowsep="0">
- <entry>Atom</entry>
- <entry>message_type</entry>
- <entry>XInternAtom(display, "_XIM_CONNECT", false)</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>format</entry>
- <entry>32</entry>
- </row>
- <row rowsep="0">
- <entry>long</entry>
- <entry>data.1[0]</entry>
- <entry>client communication window ID</entry>
- </row>
- <row rowsep="0">
- <entry>long</entry>
- <entry>data.1[1]</entry>
- <entry>client-major-transport-version(*1)</entry>
- </row>
- <row rowsep="0">
- <entry>long</entry>
- <entry>data.1[2]</entry>
- <entry>client-major-transport-version(*1)</entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-
-<para>
-In order to establish the connection (to notify the IM Server communication
-window), the IM Server sends a ClientMessage in the following event's
-format to the client communication window.
-</para>
-
-<table frame="none" id="clientmessage_sent_by_im_server">
- <title>The ClientMessage sent by IM Server.</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="1*" colsep="0"/>
- <colspec colname="col2" colwidth="1*" colsep="1"/>
- <colspec colname="col3" colwidth="3.5*" colsep="0"/>
- <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/>
- <thead>
- <row>
- <entry align="left" spanname="span-horiz">Structure Member</entry>
- <entry align="left">Contents</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>int</entry>
- <entry>type</entry>
- <entry>ClientMessage</entry>
- </row>
- <row rowsep="0">
- <entry>u_long</entry>
- <entry>serial</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Bool</entry>
- <entry>send_event</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Display</entry>
- <entry>*display</entry>
- <entry>The display to which connects</entry>
- </row>
- <row rowsep="0">
- <entry>Window</entry>
- <entry>window</entry>
- <entry>IMS Window ID</entry>
- </row>
- <row rowsep="0">
- <entry>Atom</entry>
- <entry>message_type</entry>
- <entry>XInternAtom(display, "_XIM_CONNECT", false)</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>format</entry>
- <entry>32</entry>
- </row>
- <row rowsep="0">
- <entry>long</entry>
- <entry>data.1[0]</entry>
- <entry>client communication window ID</entry>
- </row>
- <row rowsep="0">
- <entry>long</entry>
- <entry>data.1[1]</entry>
- <entry>client-major-transport-version(*1)</entry>
- </row>
- <row rowsep="0">
- <entry>long</entry>
- <entry>data.1[2]</entry>
- <entry>client-major-transport-version(*1)</entry>
- </row>
- <row rowsep="0">
- <entry>long</entry>
- <entry>data.1[3]</entry>
- <entry>dividing size between ClientMessage and Property(*2)</entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-
-<para>
-(*1) major/minor-transport-version
-</para>
-
-<para>
-The read/write method is decided by the combination of
-major/minor-transport-version, as follows:
-</para>
-
-<table frame="all" id="readwrite_method_and_the_majorminor_transport_version">
-<title>The read/write method and the major/minor-transport-version</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="1*" colsep="1"/>
- <colspec colname="col2" colwidth="1*" colsep="1"/>
- <colspec colname="col3" colwidth="3*" colsep="1"/>
- <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="center"/>
- <thead>
- <row>
- <entry spanname="span-horiz">Transport-version</entry>
- <entry>read/write</entry>
- </row>
- <row>
- <entry>major</entry>
- <entry>minor</entry>
- <entry></entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry morerows="2">0</entry>
- <entry>0</entry>
- <entry>only-CM & Property-with-CM</entry>
- </row>
- <row rowsep="0">
- <entry>1</entry>
- <entry>only-CM & multi-CM</entry>
- </row>
- <row rowsep="1">
- <entry>2</entry>
- <entry>only-CM & multi-CM & Property-with-CM</entry>
- </row>
- <row rowsep="1">
- <entry>1</entry>
- <entry>0</entry>
- <entry>PropertyNotify</entry>
- </row>
- <row rowsep="0">
- <entry morerows="1">2</entry>
- <entry>0</entry>
- <entry>only-CM & PropertyNotify</entry>
- </row>
- <row>
- <entry>1</entry>
- <entry>only-CM & multi-CM & PropertyNotify</entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-
-<literallayout class="monospaced">
-only-CM : data is sent via a ClientMessage
-multi-CM : data is sent via multiple ClientMessages
-Property-with-CM : data is written in Property, and its Atom
- is send via ClientMessage
-PropertyNotify : data is written in Property, and its Atom
- is send via PropertyNotify
-
-</literallayout>
-
-
-<para>
-The method to decide major/minor-transport-version is as follows:
-</para>
-
-<itemizedlist>
- <listitem>
- <para>
-The client sends 0 as major/minor-transport-version to the IM Server.
-The client must support all methods in Table 4-3. <!-- xref -->
-The client may send another number as major/minor-transport-version to
-use other method than the above in the future.
- </para>
- </listitem>
- <listitem>
- <para>
-The IM Server sends its major/minor-transport-version number to
-the client. The client sends data using the method specified by the
-IM Server.
- </para>
- </listitem>
- <listitem>
- <para>
-If major/minor-transport-version number is not available, it is regarded
-as 0.
- </para>
- </listitem>
-</itemizedlist>
-
-<para>
-(*2) dividing size between ClientMessage and Property
-</para>
-
-<para>
-If data is sent via both of multi-CM and Property, specify the dividing
-size between ClientMessage and Property. The data, which is smaller than
-this size, is sent via multi-CM (or only-CM), and the data, which is
-lager than this size, is sent via Property.
-</para>
-
-</sect3>
-
-<sect3 id="read_write_">
-<title>read/write </title>
-<para>
-The data is transferred via either ClientMessage or Window Property in
-the X Window System.
-</para>
-
-<sect4 id="Format_for_the_data_from_the_Client_to_the_IM_Server">
-<title>Format for the data from the Client to the IM Server</title>
-<para>
-<emphasis role="bold">ClientMessage</emphasis>
-</para>
-
-<para>
-If data is sent via ClientMessage event, the format is as follows:
-</para>
-
-<table frame="none" id="clientmessage_events_format_first_or_middle">
- <title>The ClientMessage event's format (first or middle)</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="1*" colsep="0"/>
- <colspec colname="col2" colwidth="1*" colsep="1"/>
- <colspec colname="col3" colwidth="3.5*" colsep="0"/>
- <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/>
- <thead>
- <row>
- <entry align="left" spanname="span-horiz">Structure Member</entry>
- <entry align="left">Contents</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>int</entry>
- <entry>type</entry>
- <entry>ClientMessage</entry>
- </row>
- <row rowsep="0">
- <entry>u_long</entry>
- <entry>serial</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Bool</entry>
- <entry>send_event</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Display</entry>
- <entry>*display</entry>
- <entry>The display to which connects</entry>
- </row>
- <row rowsep="0">
- <entry>Window</entry>
- <entry>window</entry>
- <entry>IMS Window ID</entry>
- </row>
- <row rowsep="0">
- <entry>Atom</entry>
- <entry>message_type</entry>
- <entry>XInternAtom(display, "_XIM_MOREDATA", False)</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>format</entry>
- <entry>8</entry>
- </row>
- <row rowsep="0">
- <entry>char</entry>
- <entry>data.b[20]</entry>
- <entry>(read/write DATA : 20 byte)</entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-
-
-
-<table frame="none" id="clientmessage_events_format_only_or_last">
- <title>The ClientMessage event's format (only or last)</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="1*" colsep="0"/>
- <colspec colname="col2" colwidth="1*" colsep="1"/>
- <colspec colname="col3" colwidth="3.5*" colsep="0"/>
- <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/>
- <thead>
- <row>
- <entry align="left" spanname="span-horiz">Structure Member</entry>
- <entry align="left">Contents</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>int</entry>
- <entry>type</entry>
- <entry>ClientMessage</entry>
- </row>
- <row rowsep="0">
- <entry>u_long</entry>
- <entry>serial</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Bool</entry>
- <entry>send_event</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Display</entry>
- <entry>*display</entry>
- <entry>The display to which connects</entry>
- </row>
- <row rowsep="0">
- <entry>Window</entry>
- <entry>window</entry>
- <entry>IMS Window ID</entry>
- </row>
- <row rowsep="0">
- <entry>Atom</entry>
- <entry>message_type</entry>
- <entry>XInternAtom(display, "_XIM_PROTOCOL", False)</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>format</entry>
- <entry>8</entry>
- </row>
- <row rowsep="0">
- <entry>char</entry>
- <entry>data.b[20]</entry>
- <entry>(read/write DATA : MAX 20 byte)
-<footnote><para>If the data is smaller
-than 20 bytes, all data other than available data must be 0.
-</para></footnote>
- </entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-
-<para>
-<emphasis role="bold">Property</emphasis>
-</para>
-
-<para>
-In the case of large data, data will be sent via the Window Property
-for the efficiency. There are the following two methods to notify
-Property, and transport-version is decided which method is used.
-</para>
-
-<itemizedlist>
- <listitem>
- <para>
-The XChangeProperty function is used to store data in the client
-communication window, and Atom of the stored data is notified to the
-IM Server via ClientMessage event.
- </para>
- </listitem>
- <listitem>
- <para>
-The XChangeProperty function is used to store data in the client
-communication window, and Atom of the stored data is notified to the
-IM Server via PropertyNotify event.
- </para>
- </listitem>
-</itemizedlist>
-
-<para>
-The arguments of the XChangeProperty are as follows:
-</para>
-
-
-<table frame="none" id="xchangeproperty_events_format">
- <title>The XChangeProperty event's format</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="1*" colsep="0"/>
- <colspec colname="col2" colwidth="1*" colsep="1"/>
- <colspec colname="col3" colwidth="3.5*" colsep="0"/>
- <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/>
- <thead>
- <row>
- <entry align="left" spanname="span-horiz">Argument</entry>
- <entry align="left">Contents</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>Display</entry>
- <entry>*display</entry>
- <entry>The display to which connects</entry>
- </row>
- <row rowsep="0">
- <entry>Window</entry>
- <entry>window</entry>
- <entry>IMS communication window ID</entry>
- </row>
- <row rowsep="0">
- <entry>Atom</entry>
- <entry>property</entry>
- <entry>read/write property Atom (*1)</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>format</entry>
- <entry>8</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>mode</entry>
- <entry>PropModeAppend</entry>
- </row>
- <row rowsep="0">
- <entry>u_char</entry>
- <entry>*data</entry>
- <entry>read/write DATA</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>nelements</entry>
- <entry>length of DATA</entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-
-<para>
-(*1) The read/write property ATOM allocates the following strings by
-<function>XInternAtom</function>.
-"_clientXXX"
-</para>
-
-<para>
-The client changes the property with the mode of PropModeAppend and
-the IM Server will read it with the delete mode i.e. (delete = True).
-</para>
-
-<para>
-If Atom is notified via ClientMessage event, the format of the ClientMessage
-is as follows:
-</para>
-
-<table frame="none" id="clientmessage_events_format_to_send_atom_of_property">
- <title>The ClientMessage event's format to send Atom of property</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="1*" colsep="0"/>
- <colspec colname="col2" colwidth="1*" colsep="1"/>
- <colspec colname="col3" colwidth="3.5*" colsep="0"/>
- <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/>
- <thead>
- <row>
- <entry align="left" spanname="span-horiz">Structure Member</entry>
- <entry align="left">Contents</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>int</entry>
- <entry>type</entry>
- <entry>ClientMessage</entry>
- </row>
- <row rowsep="0">
- <entry>u_long</entry>
- <entry>serial</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Bool</entry>
- <entry>send_event</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Display</entry>
- <entry>*display</entry>
- <entry>The display to which connects</entry>
- </row>
- <row rowsep="0">
- <entry>Window</entry>
- <entry>window</entry>
- <entry>IMS Window ID</entry>
- </row>
- <row rowsep="0">
- <entry>Atom</entry>
- <entry>message_type</entry>
- <entry>XInternAtom(display, "_XIM_PROTOCOL", False)</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>format</entry>
- <entry>8</entry>
- </row>
- <row rowsep="0">
- <entry>long</entry>
- <entry>data.1[0]</entry>
- <entry>length of read/write property Atom</entry>
- </row>
- <row rowsep="0">
- <entry>long</entry>
- <entry>data.1[1]</entry>
- <entry>read/write property Atom</entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-</sect4>
-
-<sect4 id="Format_for_the_data_from_the_IM_Server_to_the_Client">
-<title>Format for the data from the IM Server to the Client</title>
-<para>
-<emphasis role="bold">ClientMessage</emphasis>
-</para>
-
-<para>
-The format of the ClientMessage is as follows:
-</para>
-
-<table frame="none" id="clientmessage_events_format_first_or_middle_2">
- <title>The ClientMessage event's format (first or middle)</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="1*" colsep="0"/>
- <colspec colname="col2" colwidth="1*" colsep="1"/>
- <colspec colname="col3" colwidth="3.5*" colsep="0"/>
- <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/>
- <thead>
- <row>
- <entry align="left" spanname="span-horiz">Structure Member</entry>
- <entry align="left">Contents</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>int</entry>
- <entry>type</entry>
- <entry>ClientMessage</entry>
- </row>
- <row rowsep="0">
- <entry>u_long</entry>
- <entry>serial</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Bool</entry>
- <entry>send_event</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Display</entry>
- <entry>*display</entry>
- <entry>The display to which connects</entry>
- </row>
- <row rowsep="0">
- <entry>Window</entry>
- <entry>window</entry>
- <entry>IMS Window ID</entry>
- </row>
- <row rowsep="0">
- <entry>Atom</entry>
- <entry>message_type</entry>
- <entry>XInternAtom(display, "_XIM_MOREDATA", False)</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>format</entry>
- <entry>8</entry>
- </row>
- <row rowsep="0">
- <entry>char</entry>
- <entry>data.b[20]</entry>
- <entry>(read/write DATA : 20 byte)</entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-
-
-
-
-
-<table frame="none" id="clientmessage_events_format_only_or_last_2">
- <title>The ClientMessage event's format (only or last)</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="1*" colsep="0"/>
- <colspec colname="col2" colwidth="1*" colsep="1"/>
- <colspec colname="col3" colwidth="3.5*" colsep="0"/>
- <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/>
- <thead>
- <row>
- <entry align="left" spanname="span-horiz">Structure Member</entry>
- <entry align="left">Contents</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>int</entry>
- <entry>type</entry>
- <entry>ClientMessage</entry>
- </row>
- <row rowsep="0">
- <entry>u_long</entry>
- <entry>serial</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Bool</entry>
- <entry>send_event</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Display</entry>
- <entry>*display</entry>
- <entry>The display to which connects</entry>
- </row>
- <row rowsep="0">
- <entry>Window</entry>
- <entry>window</entry>
- <entry>IMS Window ID</entry>
- </row>
- <row rowsep="0">
- <entry>Atom</entry>
- <entry>message_type</entry>
- <entry>XInternAtom(display, "_XIM_PROTOCOL", False)</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>format</entry>
- <entry>8</entry>
- </row>
- <row rowsep="0">
- <entry>char</entry>
- <entry>data.b[20]</entry>
- <entry>(read/write DATA : MAX 20 byte) (*1)</entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-
-<para>
-(*1) If the data size is smaller than 20 bytes, all data other than available
-data must be 0.
-</para>
-
-<para>
-<emphasis role="bold">Property</emphasis>
-</para>
-
-<para>
-In the case of large data, data will be sent via the Window Property
-for the efficiency. There are the following two methods to notify
-Property, and transport-version is decided which method is used.
-</para>
-
-<itemizedlist>
- <listitem>
- <para>
-The XChangeProperty function is used to store data in the IMS
-communication window, and Atom of the property is sent via the
-ClientMessage event.
- </para>
- </listitem>
- <listitem>
- <para>
-The XChangeProperty function is used to store data in the IMS
-communication window, and Atom of the property is sent via
-PropertyNotify event.
- </para>
- </listitem>
-</itemizedlist>
-
-<para>
-The arguments of the XChangeProperty are as follows:
-</para>
-
-<table frame="none" id="xchangeproperty_events_format_b">
- <title>The XChangeProperty event's format</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="1*" colsep="0"/>
- <colspec colname="col2" colwidth="1*" colsep="1"/>
- <colspec colname="col3" colwidth="3.5*" colsep="0"/>
- <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/>
- <thead>
- <row>
- <entry align="left" spanname="span-horiz">Argument</entry>
- <entry align="left">Contents</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>Display</entry>
- <entry>*display</entry>
- <entry>The display to which connects</entry>
- </row>
- <row rowsep="0">
- <entry>Window</entry>
- <entry>window</entry>
- <entry>IMS communication window ID</entry>
- </row>
- <row rowsep="0">
- <entry>Atom</entry>
- <entry>property</entry>
- <entry>read/write property Atom (*1)</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>format</entry>
- <entry>8</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>mode</entry>
- <entry>PropModeAppend</entry>
- </row>
- <row rowsep="0">
- <entry>u_char</entry>
- <entry>*data</entry>
- <entry>read/write DATA</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>nelements</entry>
- <entry>length of DATA</entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-
-<para>
-(*1) The read/write property ATOM allocates some strings, which are not
-allocated by the client, by <function>XInternAtom</function>.
-</para>
-
-<para>
-The IM Server changes the property with the mode of PropModeAppend and
-the client reads it with the delete mode, i.e. (delete = True).
-</para>
-
-<para>
-If Atom is notified via ClientMessage event, the format of the ClientMessage
-is as follows:
-</para>
-
-<table frame="none" id="clientmessage_events_format_to_send_atom_of_property_2">
- <title>The ClientMessage event's format to send Atom of property</title>
- <tgroup cols="3">
- <colspec colname="col1" colwidth="1*" colsep="0"/>
- <colspec colname="col2" colwidth="1*" colsep="1"/>
- <colspec colname="col3" colwidth="3.5*" colsep="0"/>
- <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/>
- <thead>
- <row>
- <entry align="left" spanname="span-horiz">Structure Member</entry>
- <entry align="left">Contents</entry>
- </row>
- </thead>
- <tbody>
- <row rowsep="0">
- <entry>int</entry>
- <entry>type</entry>
- <entry>ClientMessage</entry>
- </row>
- <row rowsep="0">
- <entry>u_long</entry>
- <entry>serial</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Bool</entry>
- <entry>send_event</entry>
- <entry>Set by the X Window System</entry>
- </row>
- <row rowsep="0">
- <entry>Display</entry>
- <entry>*display</entry>
- <entry>The display to which connects</entry>
- </row>
- <row rowsep="0">
- <entry>Window</entry>
- <entry>window</entry>
- <entry>IMS Window ID</entry>
- </row>
- <row rowsep="0">
- <entry>Atom</entry>
- <entry>message_type</entry>
- <entry>XInternAtom(display, "_XIM_PROTOCOL", False)</entry>
- </row>
- <row rowsep="0">
- <entry>int</entry>
- <entry>format</entry>
- <entry>8</entry>
- </row>
- <row rowsep="0">
- <entry>long</entry>
- <entry>data.1[0]</entry>
- <entry>length of read/write property Atom</entry>
- </row>
- <row rowsep="0">
- <entry>long</entry>
- <entry>data.1[1]</entry>
- <entry>read/write property Atom</entry>
- </row>
- </tbody>
- </tgroup>
-</table>
-
-</sect4>
-</sect3>
-<sect3 id="Closing_Connection">
-<title>Closing Connection</title>
-
-<para>
-If the client disconnect with the IM Server, shutdown function should
-free the communication window properties and etc..
-</para>
-
-</sect3>
-</sect2>
-</sect1>
-
-<sect1 id="References">
-<title>References</title>
-<para>
-[1] Masahiko Narita and Hideki Hiura, <emphasis remap='I'>"The Input Method Protocol"</emphasis>
-</para>
-</sect1>
-
-</chapter>
-</book>
+<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> + +<book id="trans"> + +<bookinfo> + <title>The XIM Transport Specification</title> + <subtitle>Revision 0.1</subtitle> + <releaseinfo>X Version 11, Release 7</releaseinfo> + <authorgroup> + <author> + <firstname>Takashi</firstname><surname>Fujiwara</surname> + <affiliation><orgname>FUJITSU LIMITED</orgname></affiliation> + </author> + </authorgroup> + <copyright><year>1994</year><holder>FUJITSU LIMITED</holder></copyright> + <copyright><year>1994</year><holder>X Consortium</holder></copyright> + + <productnumber>Revision 0.1</productnumber> + + +<abstract> +<para> +This specification describes the transport layer interfaces between Xlib and IM Server, +which makes various channels usable such as X protocol or TCP/IP, DECnet and etc. +</para> +</abstract> + +<legalnotice> + +<para> +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: +</para> + +<para> +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +</para> + +<para> +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +</para> + +<para> +Except as contained in this notice, the name of The Open Group shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from X Consortium. +</para> + +<para>X Window System is a trademark of The Open Group.</para> + +</legalnotice> +</bookinfo> + +<chapter id="xim_transport_specification"> +<title>X Transport Specification</title> + +<sect1 id="Introduction"> +<title>Introduction</title> +<!-- .XS --> +<!-- (SN Introduction --> +<!-- .XE --> +<para> +<!-- .LP --> +The Xlib XIM implementation is layered into three functions, a protocol +layer, an interface layer and a transport layer. The purpose of this +layering is to make the protocol independent of transport implementation. +Each function of these layers are: +<!-- .RS 3 --> +</para> +<variablelist> + <varlistentry> + <term><emphasis>The protocol layer</emphasis></term> + <listitem> + <para> +implements overall function of XIM and calls the interface layer +functions when it needs to communicate to IM Server. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><emphasis>The interface layer</emphasis></term> + <listitem> + <para> +separates the implementation of the transport layer from the protocol +layer, in other words, it provides implementation independent hook for +the transport layer functions. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><emphasis>The transport layer</emphasis></term> + <listitem> + <para> +handles actual data communication with IM Server. It is done by a set +of several functions named transporters. + </para> + </listitem> + </varlistentry> +</variablelist> + +<para> +This specification describes the interface layer and the transport +layer, which makes various communication channels usable such as +X protocol or, TCP/IP, DECnet, STREAM, etc., and provides +the information needed for adding another new transport layer. +In addition, sample implementations for the transporter using the +X connection is described in section 4. <!-- xref --> +</para> +</sect1> + +<sect1 id="Initialization"> +<title>Initialization</title> + +<sect2 id="Registering_structure_to_initialize"> +<title>Registering structure to initialize</title> + +<para> +The structure typed as TransportSW contains the list of the transport +layer the specific implementations supports. +</para> + +<literallayout class="monospaced"> +typedef struct { + char *transport_name; + Bool (*config); +} TransportSW; +</literallayout> + +<informaltable frame="none"> + <tgroup cols="2"> + <colspec colname="col1" colwidth="1*" colsep="0"/> + <colspec colname="col2" colwidth="1*" colsep="0"/> + <tbody> + <row rowsep="0"> + <entry><emphasis>transport_name</emphasis></entry> + <entry>name of transport<footnote><para>Refer to "The Input Method Protocol: Appendix B</para></footnote></entry> + </row> + <row rowsep="0"> + <entry><emphasis>config</emphasis></entry> + <entry>initial configuration function</entry> + </row> + </tbody> + </tgroup> +</informaltable> + +<para> +A sample entry for the Xlib supporting transporters is shown below: +</para> + +<literallayout class="monospaced"> +TransportSW _XimTransportRec[] = { +/* char <emphasis remap='I'>*</emphasis>: + * transport_name, Bool <emphasis remap='I'>(*config)()</emphasis> + */ + "X", _XimXConf, + "tcp", _XimTransConf, + "local", _XimTransConf, + "decnet", _XimTransConf, + "streams", _XimTransConf, + (char *)NULL, (Bool (*)())NULL, +}; +</literallayout> + +</sect2> +<sect2 id="Initialization_function"> +<title>Initialization function</title> +<!-- .XS --> +<!-- (SN Initialization function --> +<!-- .XE --> +<para> +The following function will be called once when Xlib configures the +transporter functions. +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function>(*config)</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> + <paramdef>char<parameter> *transport_data</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>transport_data</emphasis> + </term> + <listitem> + <para> +Specifies the data specific to the transporter, in IM Server address.<footnote><para>Refer to "The Input Method Protocol: Appendix B</para></footnote> + </para> + </listitem> + </varlistentry> +</variablelist> + +<para> +This function must setup the transporter function pointers. +</para> + +<para> +<!-- .LP --> +The actual <emphasis remap='I'>config</emphasis> function will be chosen by IM Server at the +pre-connection time, matching by the <emphasis remap='I'>transport_name</emphasis> specified +in the <function>_XimTransportRec</function> array; The specific members of XimProto +structure listed below must be initialized so that point they +appropriate transporter functions. +</para> + +<para> +If the specified transporter has been configured successfully, this +function returns True. There is no Alternative Entry for config +function itself. +</para> + +<para> +The structure XimProto contains the following function pointers: +</para> + +<literallayout class="monospaced"> +Bool (*connect)(); /* Open connection */ +Bool (*shutdown)(); /* Close connection */ +Bool (*write)(); /* Write data */ +Bool (*read)(); /* Read data */ +Bool (*flush)(); /* Flush data buffer */ +Bool (*register_dispatcher)(); /* Register asynchronous data handler */ +Bool (*call_dispatcher)(); /* Call dispatcher */ +</literallayout> + +<para> +These functions are called when Xlib needs to communicate the +IM Server. These functions must process the appropriate procedure +described below. +</para> + +</sect2> +</sect1> +<sect1 id="The_interface_transport_layer_functions"> +<title>The interface/transport layer functions</title> +<para> +Following functions are used for the transport interface. +</para> + +<table frame="all" id="transport_layer_functions_2"> + <title>The Transport Layer Functions</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="3*" colsep="1"/> + <colspec colname="col2" colwidth="3*" colsep="1"/> + <colspec colname="col3" colwidth="1*" colsep="1"/> + <thead> + <row> + <entry align="center">Alternate Entry (Interface Layer)</entry> + <entry align="center">XimProto member (Transport Layer)</entry> + <entry align="center">Section</entry> + </row> + </thead> + <tbody> + <row> + <entry>_XimConnect</entry> + <entry>connect</entry> + <entry>3.1</entry> + </row> + <row> + <entry>_XimShutdown</entry> + <entry>shutdown</entry> + <entry>3.2</entry> + </row> + <row> + <entry>_XimWrite</entry> + <entry>write</entry> + <entry>3.3</entry> + </row> + <row> + <entry>_XimRead</entry> + <entry>read</entry> + <entry>3.4</entry> + </row> + <row> + <entry>_XimFlush</entry> + <entry>flush</entry> + <entry>3.5</entry> + </row> + <row> + <entry>_XimRegisterDispatcher</entry> + <entry>register_dispatcher</entry> + <entry>3.6</entry> + </row> + <row> + <entry>_XimCallDispatcher</entry> + <entry>call_dispatcher</entry> + <entry>3.7</entry> + </row> + </tbody> + </tgroup> +</table> + +<para> +The Protocol layer calls the above functions using the Alternative +Entry in the left column. The transport implementation defines +XimProto member function in the right column. The Alternative Entry is +provided so as to make easier to implement the Protocol Layer. +</para> + +<sect2 id="Opening_connection"> +<title>Opening connection</title> +<para> +<!-- .LP --> +When <function>XOpenIM</function> is called, the following function is called to connect +with the IM Server. +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function>(*connect)</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> +</variablelist> + +<para> +This function must establishes the connection to the IM Server. If the +connection is established successfully, this function returns True. +The Alternative Entry for this function is: +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function> _XimConnect</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> +</variablelist> +</sect2> + +<sect2 id="Closing_connection"> +<title>Closing connection</title> +<!-- .XS --> +<!-- (SN Closing connection --> +<!-- .XE --> +<para> +<!-- .LP --> +When <function>XCloseIM</function> is called, the following function is called to +disconnect the connection with the IM Server. The Alternative Entry +for this function is: +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function> (*shutdown)</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> +</variablelist> + +<para> +<!-- .LP --> +This function must close connection with the IM Server. If the +connection is closed successfully, this function returns True. The +Alternative Entry for this function is: +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function>_XimShutdown</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> +</variablelist> + +</sect2> + +<sect2 id="Writing_data"> +<title>Writing data</title> +<para> +The following function is called, when Xlib needs to write data to the +IM Server. +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function> _XimWrite</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> + <paramdef>INT16<parameter> len</parameter></paramdef> + <paramdef>XPointer<parameter> data</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>len</emphasis> + </term> + <listitem> + <para> +Specifies the length of writing data. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>data</emphasis> + </term> + <listitem> + <para> +Specifies the writing data. + </para> + </listitem> + </varlistentry> +</variablelist> + +<para> +This function writes the <emphasis remap='I'>data</emphasis> to the IM Server, regardless +of the contents. The number of bytes is passed to <emphasis remap='I'>len</emphasis>. The +writing data is passed to <emphasis remap='I'>data</emphasis>. If data is sent successfully, +the function returns True. Refer to "The Input Method Protocol" for +the contents of the writing data. The Alternative Entry for this +function is: +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function>_XimWrite</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> + <paramdef>INT16<parameter> len</parameter></paramdef> + <paramdef>XPointer<parameter> data</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>len</emphasis> + </term> + <listitem> + <para> +Specifies the length of writing data. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>data</emphasis> + </term> + <listitem> + <para> +Specifies the writing data. + </para> + </listitem> + </varlistentry> +</variablelist> + +</sect2> +<sect2 id="Reading_data"> +<title>Reading data</title> +<para> +The following function is called when Xlib waits for response from IM +server synchronously. +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function> _XimRead</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> + <paramdef>XPointer<parameter> read_buf</parameter></paramdef> + <paramdef>int<parameter> buf_len</parameter></paramdef> + <paramdef>int<parameter> *ret_len</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>read_buf</emphasis> + </term> + <listitem> + <para> +Specifies the buffer to store data. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>buf_len</emphasis> + </term> + <listitem> + <para> +Specifies the size of the <emphasis remap='I'>buffer</emphasis> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>ret_len</emphasis> + </term> + <listitem> + <para> +Specifies the length of stored data. + </para> + </listitem> + </varlistentry> +</variablelist> + +<para> +This function stores the read data in <emphasis remap='I'>read_buf</emphasis>, which size is +specified as <emphasis remap='I'>buf_len</emphasis>. The size of data is set to <emphasis remap='I'>ret_len</emphasis>. +This function return True, if the data is read normally or reading +data is completed. +</para> +<para> +The Alternative Entry for this function is: +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function> _XimRead</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> + <paramdef>INT16<parameter> *ret_len</parameter></paramdef> + <paramdef>XPointer<parameter> buf</parameter></paramdef> + <paramdef>int<parameter> buf_len</parameter></paramdef> + <paramdef>Bool<parameter> (*predicate)()</parameter></paramdef> + <paramdef>XPointer<parameter> predicate_arg</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>ret_len</emphasis> + </term> + <listitem> + <para> +Specifies the size of the <emphasis remap='I'>data</emphasis> buffer. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>buf</emphasis> + </term> + <listitem> + <para> +Specifies the buffer to store data. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>buf_len</emphasis> + </term> + <listitem> + <para> +Specifies the length of <emphasis remap='I'>buffer</emphasis>. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>predicate</emphasis> + </term> + <listitem> + <para> +Specifies the predicate for the XIM data. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>predicate_arg</emphasis> + </term> + <listitem> + <para> +Specifies the predicate specific data. +<!-- .sp 6p --> + </para> + </listitem> + </varlistentry> +</variablelist> + +<para> +The predicate procedure indicates whether the <emphasis remap='I'>data</emphasis> is for the +XIM or not. <emphasis remap='I'>len</emphasis> +This function stores the read data in <emphasis remap='I'>buf</emphasis>, which size +is specified as <emphasis remap='I'>buf_len</emphasis>. The size of data is set to +<emphasis remap='I'>ret_len</emphasis>. If <emphasis remap='I'>preedicate()</emphasis> +returns True, this function returns True. If not, it calls the registered callback function. +</para> + +<para> +The procedure and its arguments are: +</para> + + +<funcsynopsis> +<funcprototype> + <funcdef>void <function>(*predicate)</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> + <paramdef>INT16<parameter> len</parameter></paramdef> + <paramdef>XPointer<parameter> data</parameter></paramdef> + <paramdef>XPointer<parameter> predicate_arg</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>len</emphasis> + </term> + <listitem> + <para> +Specifies the size of the <emphasis remap='I'>data</emphasis> buffer. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>data</emphasis> + </term> + <listitem> + <para> +Specifies the buffer to store data. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>predicate_arg</emphasis> + </term> + <listitem> + <para> +Specifies the predicate specific data. + </para> + </listitem> + </varlistentry> +</variablelist> + +</sect2> +<sect2 id="Flushing_buffer"> +<title>Flushing buffer</title> +<para> +The following function is called when Xlib needs to flush the data. +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>void <function>(*flush)</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> +</variablelist> + +<para> +This function must flush the data stored in internal buffer on the +transport layer. If data transfer is completed, the function returns +True. The Alternative Entry for this function is: +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>void <function> _XimFlush</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> +</variablelist> + +</sect2> +<sect2 id="Registering_asynchronous_data_handler"> +<title>Registering asynchronous data handler</title> +<para> +Xlib needs to handle asynchronous response from IM Server. This is +because some of the XIM data occur asynchronously to X events. +</para> + +<para> +Those data will be handled in the <emphasis remap='I'>Filter</emphasis>, +and the <emphasis remap='I'>Filter</emphasis> +will call asynchronous data handler in the protocol layer. Then it +calls dispatchers in the transport layer. The dispatchers are +implemented by the protocol layer. This function must store the +information and prepare for later call of the dispatchers using +<function>_XimCallDispatcher</function>. +</para> + +<para> +When multiple dispatchers are registered, they will be called +sequentially in order of registration, on arrival of asynchronous +data. The register_dispatcher is declared as following: +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function>(*register_dispatcher)</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> + <paramdef>Bool<parameter> (*dispatcher)()</parameter></paramdef> + <paramdef>XPointer<parameter> call_data</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>dispatcher</emphasis> + </term> + <listitem> + <para> +Specifies the dispatcher function to register. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>call_data</emphasis> + </term> + <listitem> + <para> +Specifies a parameter for the <emphasis remap='I'>dispatcher</emphasis>. + </para> + </listitem> + </varlistentry> +</variablelist> + +<para> +The dispatcher is a function of the following type: +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function>(*dispatcher)</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> + <paramdef>INT16<parameter> len</parameter></paramdef> + <paramdef>XPointer<parameter> data</parameter></paramdef> + <paramdef>XPointer<parameter> call_data</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>len</emphasis> + </term> + <listitem> + <para> +Specifies the size of the <emphasis remap='I'>data</emphasis> buffer. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>data</emphasis> + </term> + <listitem> + <para> +Specifies the buffer to store data. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>call_data</emphasis> + </term> + <listitem> + <para> +Specifies a parameter passed to the register_dispatcher. + </para> + </listitem> + </varlistentry> +</variablelist> + +<para> +The dispatcher is provided by the protocol layer. They are called once +for every asynchronous data, in order of registration. If the data is +used, it must return True. otherwise, it must return False. +</para> + +<para> +If the dispatcher function returns True, the Transport Layer assume +that the data has been processed by the upper layer. The Alternative +Entry for this function is: +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function> _XimRegisterDispatcher</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> + <paramdef>Bool<parameter> (*dispatcher)()</parameter></paramdef> + <paramdef>XPointer<parameter> call_data</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>dispatcher</emphasis> + </term> + <listitem> + <para> +Specifies the dispatcher function to register. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>call_data</emphasis> + </term> + <listitem> + <para> +Specifies a parameter for the <emphasis remap='I'>dispatcher</emphasis>. + </para> + </listitem> + </varlistentry> +</variablelist> + +</sect2> +<sect2 id="Calling_dispatcher"> +<title>Calling dispatcher</title> +<para> +The following function is used to call the registered dispatcher +function, when the asynchronous response from IM Server has arrived. +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function>(*call_dispatcher)</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> + <paramdef>INT16<parameter> len</parameter></paramdef> + <paramdef>XPointer<parameter> data</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>im</emphasis> + </term> + <listitem> + <para> +Specifies XIM structure address. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>len</emphasis> + </term> + <listitem> + <para> +Specifies the size of <emphasis remap='I'>data</emphasis> buffer. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>data</emphasis> + </term> + <listitem> + <para> +Specifies the buffer to store data. + </para> + </listitem> + </varlistentry> +</variablelist> + +<para> +The call_dispatcher must call the dispatcher function, in order of +their registration. <emphasis remap='I'>len</emphasis> and <emphasis remap='I'>data</emphasis> are the data passed to +register_dispatcher. +</para> + +<para> +The return values are checked at each invocation, and if it finds +True, it immediately return with true for its return value. +</para> + +<para> +It is depend on the upper layer whether the read data is XIM +Protocol packet unit or not. +The Alternative Entry for this function is: +</para> + +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function> _XimCallDispatcher</function></funcdef> + <paramdef>XIM<parameter> im</parameter></paramdef> + <paramdef>INT16<parameter> len</parameter></paramdef> + <paramdef>XPointer<parameter> call_data</parameter></paramdef> +</funcprototype> +</funcsynopsis> + +</sect2> +</sect1> +<sect1 id="Sample_implementations_for_the_Transport_Layer"> +<title>Sample implementations for the Transport Layer</title> +<para> +Sample implementations for the transporter using the X connection is +described here. +</para> + +<sect2 id="X_Transport"> +<title>X Transport</title> +<para> +At the beginning of the X Transport connection for the XIM transport +mechanism, two different windows must be created either in an Xlib XIM +or in an IM Server, with which the Xlib and the IM Server exchange the +XIM transports by using the ClientMessage events and Window Properties. +In the following, the window created by the Xlib is referred as the +"client communication window", and on the other hand, the window created +by the IM Server is referred as the "IMS communication window". +</para> + +<sect3 id="Connection"> +<title>Connection</title> +<para> +In order to establish a connection, a communication window is created. +A ClientMessage in the following event's format is sent to the owner +window of XIM_SERVER selection, which the IM Server has created. +</para> + +<para> +<!-- .LP --> +Refer to "The Input Method Protocol" for the XIM_SERVER atom. +</para> + +<table frame="none" id="transport_layer_functions"> + <title>The ClientMessage sent to the IMS window.</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="1*" colsep="0"/> + <colspec colname="col2" colwidth="1*" colsep="1"/> + <colspec colname="col3" colwidth="3.5*" colsep="0"/> + <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/> + <thead> + <row> + <entry align="left" spanname="span-horiz">Structure Member</entry> + <entry align="left">Contents</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>int</entry> + <entry>type</entry> + <entry>ClientMessage</entry> + </row> + <row rowsep="0"> + <entry>u_long</entry> + <entry>serial</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Bool</entry> + <entry>send_event</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Display</entry> + <entry>*display</entry> + <entry>The display to which connects</entry> + </row> + <row rowsep="0"> + <entry>Window</entry> + <entry>window</entry> + <entry>IMS Window ID</entry> + </row> + <row rowsep="0"> + <entry>Atom</entry> + <entry>message_type</entry> + <entry>XInternAtom(display, "_XIM_CONNECT", false)</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>format</entry> + <entry>32</entry> + </row> + <row rowsep="0"> + <entry>long</entry> + <entry>data.1[0]</entry> + <entry>client communication window ID</entry> + </row> + <row rowsep="0"> + <entry>long</entry> + <entry>data.1[1]</entry> + <entry>client-major-transport-version(*1)</entry> + </row> + <row rowsep="0"> + <entry>long</entry> + <entry>data.1[2]</entry> + <entry>client-major-transport-version(*1)</entry> + </row> + </tbody> + </tgroup> +</table> + +<para> +In order to establish the connection (to notify the IM Server communication +window), the IM Server sends a ClientMessage in the following event's +format to the client communication window. +</para> + +<table frame="none" id="clientmessage_sent_by_im_server"> + <title>The ClientMessage sent by IM Server.</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="1*" colsep="0"/> + <colspec colname="col2" colwidth="1*" colsep="1"/> + <colspec colname="col3" colwidth="3.5*" colsep="0"/> + <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/> + <thead> + <row> + <entry align="left" spanname="span-horiz">Structure Member</entry> + <entry align="left">Contents</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>int</entry> + <entry>type</entry> + <entry>ClientMessage</entry> + </row> + <row rowsep="0"> + <entry>u_long</entry> + <entry>serial</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Bool</entry> + <entry>send_event</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Display</entry> + <entry>*display</entry> + <entry>The display to which connects</entry> + </row> + <row rowsep="0"> + <entry>Window</entry> + <entry>window</entry> + <entry>IMS Window ID</entry> + </row> + <row rowsep="0"> + <entry>Atom</entry> + <entry>message_type</entry> + <entry>XInternAtom(display, "_XIM_CONNECT", false)</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>format</entry> + <entry>32</entry> + </row> + <row rowsep="0"> + <entry>long</entry> + <entry>data.1[0]</entry> + <entry>client communication window ID</entry> + </row> + <row rowsep="0"> + <entry>long</entry> + <entry>data.1[1]</entry> + <entry>client-major-transport-version(*1)</entry> + </row> + <row rowsep="0"> + <entry>long</entry> + <entry>data.1[2]</entry> + <entry>client-major-transport-version(*1)</entry> + </row> + <row rowsep="0"> + <entry>long</entry> + <entry>data.1[3]</entry> + <entry>dividing size between ClientMessage and Property(*2)</entry> + </row> + </tbody> + </tgroup> +</table> + +<para> +(*1) major/minor-transport-version +</para> + +<para> +The read/write method is decided by the combination of +major/minor-transport-version, as follows: +</para> + +<table frame="all" id="readwrite_method_and_the_majorminor_transport_version"> +<title>The read/write method and the major/minor-transport-version</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="1*" colsep="1"/> + <colspec colname="col2" colwidth="1*" colsep="1"/> + <colspec colname="col3" colwidth="3*" colsep="1"/> + <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="center"/> + <thead> + <row> + <entry spanname="span-horiz">Transport-version</entry> + <entry>read/write</entry> + </row> + <row> + <entry>major</entry> + <entry>minor</entry> + <entry></entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry morerows="2">0</entry> + <entry>0</entry> + <entry>only-CM & Property-with-CM</entry> + </row> + <row rowsep="0"> + <entry>1</entry> + <entry>only-CM & multi-CM</entry> + </row> + <row rowsep="1"> + <entry>2</entry> + <entry>only-CM & multi-CM & Property-with-CM</entry> + </row> + <row rowsep="1"> + <entry>1</entry> + <entry>0</entry> + <entry>PropertyNotify</entry> + </row> + <row rowsep="0"> + <entry morerows="1">2</entry> + <entry>0</entry> + <entry>only-CM & PropertyNotify</entry> + </row> + <row> + <entry>1</entry> + <entry>only-CM & multi-CM & PropertyNotify</entry> + </row> + </tbody> + </tgroup> +</table> + +<literallayout class="monospaced"> +only-CM : data is sent via a ClientMessage +multi-CM : data is sent via multiple ClientMessages +Property-with-CM : data is written in Property, and its Atom + is send via ClientMessage +PropertyNotify : data is written in Property, and its Atom + is send via PropertyNotify + +</literallayout> + + +<para> +The method to decide major/minor-transport-version is as follows: +</para> + +<itemizedlist> + <listitem> + <para> +The client sends 0 as major/minor-transport-version to the IM Server. +The client must support all methods in Table 4-3. <!-- xref --> +The client may send another number as major/minor-transport-version to +use other method than the above in the future. + </para> + </listitem> + <listitem> + <para> +The IM Server sends its major/minor-transport-version number to +the client. The client sends data using the method specified by the +IM Server. + </para> + </listitem> + <listitem> + <para> +If major/minor-transport-version number is not available, it is regarded +as 0. + </para> + </listitem> +</itemizedlist> + +<para> +(*2) dividing size between ClientMessage and Property +</para> + +<para> +If data is sent via both of multi-CM and Property, specify the dividing +size between ClientMessage and Property. The data, which is smaller than +this size, is sent via multi-CM (or only-CM), and the data, which is +lager than this size, is sent via Property. +</para> + +</sect3> + +<sect3 id="read_write_"> +<title>read/write </title> +<para> +The data is transferred via either ClientMessage or Window Property in +the X Window System. +</para> + +<sect4 id="Format_for_the_data_from_the_Client_to_the_IM_Server"> +<title>Format for the data from the Client to the IM Server</title> +<para> +<emphasis role="bold">ClientMessage</emphasis> +</para> + +<para> +If data is sent via ClientMessage event, the format is as follows: +</para> + +<table frame="none" id="clientmessage_events_format_first_or_middle"> + <title>The ClientMessage event's format (first or middle)</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="1*" colsep="0"/> + <colspec colname="col2" colwidth="1*" colsep="1"/> + <colspec colname="col3" colwidth="3.5*" colsep="0"/> + <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/> + <thead> + <row> + <entry align="left" spanname="span-horiz">Structure Member</entry> + <entry align="left">Contents</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>int</entry> + <entry>type</entry> + <entry>ClientMessage</entry> + </row> + <row rowsep="0"> + <entry>u_long</entry> + <entry>serial</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Bool</entry> + <entry>send_event</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Display</entry> + <entry>*display</entry> + <entry>The display to which connects</entry> + </row> + <row rowsep="0"> + <entry>Window</entry> + <entry>window</entry> + <entry>IMS Window ID</entry> + </row> + <row rowsep="0"> + <entry>Atom</entry> + <entry>message_type</entry> + <entry>XInternAtom(display, "_XIM_MOREDATA", False)</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>format</entry> + <entry>8</entry> + </row> + <row rowsep="0"> + <entry>char</entry> + <entry>data.b[20]</entry> + <entry>(read/write DATA : 20 byte)</entry> + </row> + </tbody> + </tgroup> +</table> + + + +<table frame="none" id="clientmessage_events_format_only_or_last"> + <title>The ClientMessage event's format (only or last)</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="1*" colsep="0"/> + <colspec colname="col2" colwidth="1*" colsep="1"/> + <colspec colname="col3" colwidth="3.5*" colsep="0"/> + <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/> + <thead> + <row> + <entry align="left" spanname="span-horiz">Structure Member</entry> + <entry align="left">Contents</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>int</entry> + <entry>type</entry> + <entry>ClientMessage</entry> + </row> + <row rowsep="0"> + <entry>u_long</entry> + <entry>serial</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Bool</entry> + <entry>send_event</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Display</entry> + <entry>*display</entry> + <entry>The display to which connects</entry> + </row> + <row rowsep="0"> + <entry>Window</entry> + <entry>window</entry> + <entry>IMS Window ID</entry> + </row> + <row rowsep="0"> + <entry>Atom</entry> + <entry>message_type</entry> + <entry>XInternAtom(display, "_XIM_PROTOCOL", False)</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>format</entry> + <entry>8</entry> + </row> + <row rowsep="0"> + <entry>char</entry> + <entry>data.b[20]</entry> + <entry>(read/write DATA : MAX 20 byte) +<footnote><para>If the data is smaller +than 20 bytes, all data other than available data must be 0. +</para></footnote> + </entry> + </row> + </tbody> + </tgroup> +</table> + +<para> +<emphasis role="bold">Property</emphasis> +</para> + +<para> +In the case of large data, data will be sent via the Window Property +for the efficiency. There are the following two methods to notify +Property, and transport-version is decided which method is used. +</para> + +<itemizedlist> + <listitem> + <para> +The XChangeProperty function is used to store data in the client +communication window, and Atom of the stored data is notified to the +IM Server via ClientMessage event. + </para> + </listitem> + <listitem> + <para> +The XChangeProperty function is used to store data in the client +communication window, and Atom of the stored data is notified to the +IM Server via PropertyNotify event. + </para> + </listitem> +</itemizedlist> + +<para> +The arguments of the XChangeProperty are as follows: +</para> + + +<table frame="none" id="xchangeproperty_events_format"> + <title>The XChangeProperty event's format</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="1*" colsep="0"/> + <colspec colname="col2" colwidth="1*" colsep="1"/> + <colspec colname="col3" colwidth="3.5*" colsep="0"/> + <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/> + <thead> + <row> + <entry align="left" spanname="span-horiz">Argument</entry> + <entry align="left">Contents</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>Display</entry> + <entry>*display</entry> + <entry>The display to which connects</entry> + </row> + <row rowsep="0"> + <entry>Window</entry> + <entry>window</entry> + <entry>IMS communication window ID</entry> + </row> + <row rowsep="0"> + <entry>Atom</entry> + <entry>property</entry> + <entry>read/write property Atom (*1)</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>format</entry> + <entry>8</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>mode</entry> + <entry>PropModeAppend</entry> + </row> + <row rowsep="0"> + <entry>u_char</entry> + <entry>*data</entry> + <entry>read/write DATA</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>nelements</entry> + <entry>length of DATA</entry> + </row> + </tbody> + </tgroup> +</table> + +<para> +(*1) The read/write property ATOM allocates the following strings by +<function>XInternAtom</function>. +"_clientXXX" +</para> + +<para> +The client changes the property with the mode of PropModeAppend and +the IM Server will read it with the delete mode i.e. (delete = True). +</para> + +<para> +If Atom is notified via ClientMessage event, the format of the ClientMessage +is as follows: +</para> + +<table frame="none" id="clientmessage_events_format_to_send_atom_of_property"> + <title>The ClientMessage event's format to send Atom of property</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="1*" colsep="0"/> + <colspec colname="col2" colwidth="1*" colsep="1"/> + <colspec colname="col3" colwidth="3.5*" colsep="0"/> + <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/> + <thead> + <row> + <entry align="left" spanname="span-horiz">Structure Member</entry> + <entry align="left">Contents</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>int</entry> + <entry>type</entry> + <entry>ClientMessage</entry> + </row> + <row rowsep="0"> + <entry>u_long</entry> + <entry>serial</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Bool</entry> + <entry>send_event</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Display</entry> + <entry>*display</entry> + <entry>The display to which connects</entry> + </row> + <row rowsep="0"> + <entry>Window</entry> + <entry>window</entry> + <entry>IMS Window ID</entry> + </row> + <row rowsep="0"> + <entry>Atom</entry> + <entry>message_type</entry> + <entry>XInternAtom(display, "_XIM_PROTOCOL", False)</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>format</entry> + <entry>8</entry> + </row> + <row rowsep="0"> + <entry>long</entry> + <entry>data.1[0]</entry> + <entry>length of read/write property Atom</entry> + </row> + <row rowsep="0"> + <entry>long</entry> + <entry>data.1[1]</entry> + <entry>read/write property Atom</entry> + </row> + </tbody> + </tgroup> +</table> +</sect4> + +<sect4 id="Format_for_the_data_from_the_IM_Server_to_the_Client"> +<title>Format for the data from the IM Server to the Client</title> +<para> +<emphasis role="bold">ClientMessage</emphasis> +</para> + +<para> +The format of the ClientMessage is as follows: +</para> + +<table frame="none" id="clientmessage_events_format_first_or_middle_2"> + <title>The ClientMessage event's format (first or middle)</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="1*" colsep="0"/> + <colspec colname="col2" colwidth="1*" colsep="1"/> + <colspec colname="col3" colwidth="3.5*" colsep="0"/> + <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/> + <thead> + <row> + <entry align="left" spanname="span-horiz">Structure Member</entry> + <entry align="left">Contents</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>int</entry> + <entry>type</entry> + <entry>ClientMessage</entry> + </row> + <row rowsep="0"> + <entry>u_long</entry> + <entry>serial</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Bool</entry> + <entry>send_event</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Display</entry> + <entry>*display</entry> + <entry>The display to which connects</entry> + </row> + <row rowsep="0"> + <entry>Window</entry> + <entry>window</entry> + <entry>IMS Window ID</entry> + </row> + <row rowsep="0"> + <entry>Atom</entry> + <entry>message_type</entry> + <entry>XInternAtom(display, "_XIM_MOREDATA", False)</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>format</entry> + <entry>8</entry> + </row> + <row rowsep="0"> + <entry>char</entry> + <entry>data.b[20]</entry> + <entry>(read/write DATA : 20 byte)</entry> + </row> + </tbody> + </tgroup> +</table> + + + + + +<table frame="none" id="clientmessage_events_format_only_or_last_2"> + <title>The ClientMessage event's format (only or last)</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="1*" colsep="0"/> + <colspec colname="col2" colwidth="1*" colsep="1"/> + <colspec colname="col3" colwidth="3.5*" colsep="0"/> + <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/> + <thead> + <row> + <entry align="left" spanname="span-horiz">Structure Member</entry> + <entry align="left">Contents</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>int</entry> + <entry>type</entry> + <entry>ClientMessage</entry> + </row> + <row rowsep="0"> + <entry>u_long</entry> + <entry>serial</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Bool</entry> + <entry>send_event</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Display</entry> + <entry>*display</entry> + <entry>The display to which connects</entry> + </row> + <row rowsep="0"> + <entry>Window</entry> + <entry>window</entry> + <entry>IMS Window ID</entry> + </row> + <row rowsep="0"> + <entry>Atom</entry> + <entry>message_type</entry> + <entry>XInternAtom(display, "_XIM_PROTOCOL", False)</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>format</entry> + <entry>8</entry> + </row> + <row rowsep="0"> + <entry>char</entry> + <entry>data.b[20]</entry> + <entry>(read/write DATA : MAX 20 byte) (*1)</entry> + </row> + </tbody> + </tgroup> +</table> + +<para> +(*1) If the data size is smaller than 20 bytes, all data other than available +data must be 0. +</para> + +<para> +<emphasis role="bold">Property</emphasis> +</para> + +<para> +In the case of large data, data will be sent via the Window Property +for the efficiency. There are the following two methods to notify +Property, and transport-version is decided which method is used. +</para> + +<itemizedlist> + <listitem> + <para> +The XChangeProperty function is used to store data in the IMS +communication window, and Atom of the property is sent via the +ClientMessage event. + </para> + </listitem> + <listitem> + <para> +The XChangeProperty function is used to store data in the IMS +communication window, and Atom of the property is sent via +PropertyNotify event. + </para> + </listitem> +</itemizedlist> + +<para> +The arguments of the XChangeProperty are as follows: +</para> + +<table frame="none" id="xchangeproperty_events_format_b"> + <title>The XChangeProperty event's format</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="1*" colsep="0"/> + <colspec colname="col2" colwidth="1*" colsep="1"/> + <colspec colname="col3" colwidth="3.5*" colsep="0"/> + <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/> + <thead> + <row> + <entry align="left" spanname="span-horiz">Argument</entry> + <entry align="left">Contents</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>Display</entry> + <entry>*display</entry> + <entry>The display to which connects</entry> + </row> + <row rowsep="0"> + <entry>Window</entry> + <entry>window</entry> + <entry>IMS communication window ID</entry> + </row> + <row rowsep="0"> + <entry>Atom</entry> + <entry>property</entry> + <entry>read/write property Atom (*1)</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>format</entry> + <entry>8</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>mode</entry> + <entry>PropModeAppend</entry> + </row> + <row rowsep="0"> + <entry>u_char</entry> + <entry>*data</entry> + <entry>read/write DATA</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>nelements</entry> + <entry>length of DATA</entry> + </row> + </tbody> + </tgroup> +</table> + +<para> +(*1) The read/write property ATOM allocates some strings, which are not +allocated by the client, by <function>XInternAtom</function>. +</para> + +<para> +The IM Server changes the property with the mode of PropModeAppend and +the client reads it with the delete mode, i.e. (delete = True). +</para> + +<para> +If Atom is notified via ClientMessage event, the format of the ClientMessage +is as follows: +</para> + +<table frame="none" id="clientmessage_events_format_to_send_atom_of_property_2"> + <title>The ClientMessage event's format to send Atom of property</title> + <tgroup cols="3"> + <colspec colname="col1" colwidth="1*" colsep="0"/> + <colspec colname="col2" colwidth="1*" colsep="1"/> + <colspec colname="col3" colwidth="3.5*" colsep="0"/> + <spanspec namest="col1" nameend="col2" spanname="span-horiz" align="left"/> + <thead> + <row> + <entry align="left" spanname="span-horiz">Structure Member</entry> + <entry align="left">Contents</entry> + </row> + </thead> + <tbody> + <row rowsep="0"> + <entry>int</entry> + <entry>type</entry> + <entry>ClientMessage</entry> + </row> + <row rowsep="0"> + <entry>u_long</entry> + <entry>serial</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Bool</entry> + <entry>send_event</entry> + <entry>Set by the X Window System</entry> + </row> + <row rowsep="0"> + <entry>Display</entry> + <entry>*display</entry> + <entry>The display to which connects</entry> + </row> + <row rowsep="0"> + <entry>Window</entry> + <entry>window</entry> + <entry>IMS Window ID</entry> + </row> + <row rowsep="0"> + <entry>Atom</entry> + <entry>message_type</entry> + <entry>XInternAtom(display, "_XIM_PROTOCOL", False)</entry> + </row> + <row rowsep="0"> + <entry>int</entry> + <entry>format</entry> + <entry>8</entry> + </row> + <row rowsep="0"> + <entry>long</entry> + <entry>data.1[0]</entry> + <entry>length of read/write property Atom</entry> + </row> + <row rowsep="0"> + <entry>long</entry> + <entry>data.1[1]</entry> + <entry>read/write property Atom</entry> + </row> + </tbody> + </tgroup> +</table> + +</sect4> +</sect3> +<sect3 id="Closing_Connection"> +<title>Closing Connection</title> + +<para> +If the client disconnect with the IM Server, shutdown function should +free the communication window properties and etc.. +</para> + +</sect3> +</sect2> +</sect1> + +<sect1 id="References"> +<title>References</title> +<para> +[1] Masahiko Narita and Hideki Hiura, <emphasis remap='I'>"The Input Method Protocol"</emphasis> +</para> +</sect1> + +</chapter> +</book> diff --git a/libXext/src/Xge.c b/libXext/src/Xge.c index 724011eab..d28a4f052 100644 --- a/libXext/src/Xge.c +++ b/libXext/src/Xge.c @@ -1,365 +1,365 @@ -/*
- * Copyright © 2007-2008 Peter Hutterer
- *
- * 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.
- *
- * Authors: Peter Hutterer, University of South Australia, NICTA
- */
-
-/*
- * XGE is an extension to re-use a single opcode for multiple events,
- * depending on the extension. XGE allows events >32 bytes.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <X11/extensions/geproto.h>
-#include <X11/extensions/ge.h>
-#include <X11/Xlibint.h>
-#include <X11/extensions/extutil.h>
-#include <X11/extensions/Xge.h>
-
-/***********************************************************************/
-/* internal data structures */
-/***********************************************************************/
-
-typedef struct {
- int present;
- short major_version;
- short minor_version;
-} XGEVersionRec;
-
-/* NULL terminated list of registered extensions. */
-typedef struct _XGEExtNode {
- int extension;
- XExtensionHooks* hooks;
- struct _XGEExtNode* next;
-} XGEExtNode, *XGEExtList;
-
-/* Internal data for GE extension */
-typedef struct _XGEData {
- XEvent data;
- XGEVersionRec *vers;
- XGEExtList extensions;
-} XGEData;
-
-
-/* forward declarations */
-static XExtDisplayInfo* _xgeFindDisplay(Display*);
-static Bool _xgeWireToEvent(Display*, XEvent*, xEvent*);
-static Status _xgeEventToWire(Display*, XEvent*, xEvent*);
-static int _xgeDpyClose(Display*, XExtCodes*);
-static XGEVersionRec* _xgeGetExtensionVersion(Display*,
- _Xconst char*,
- XExtDisplayInfo*);
-static Bool _xgeCheckExtension(Display* dpy, XExtDisplayInfo* info);
-
-/* main extension information data */
-static XExtensionInfo *xge_info;
-static char xge_extension_name[] = GE_NAME;
-static XExtensionHooks xge_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- _xgeDpyClose, /* close_display */
- _xgeWireToEvent, /* wire_to_event */
- _xgeEventToWire, /* event_to_wire */
- NULL, /* error */
- NULL, /* error_string */
-};
-
-
-static XExtDisplayInfo *_xgeFindDisplay(Display *dpy)
-{
- XExtDisplayInfo *dpyinfo;
- if (!xge_info)
- {
- if (!(xge_info = XextCreateExtension()))
- return NULL;
- }
- if (!(dpyinfo = XextFindDisplay (xge_info, dpy)))
- {
- dpyinfo = XextAddDisplay (xge_info,
- dpy,
- xge_extension_name,
- &xge_extension_hooks,
- 0 /* no events, see below */,
- NULL);
- /* We don't use an extension opcode, so we have to set the handlers
- * directly. If GenericEvent would be > 64, the job would be done by
- * XExtAddDisplay */
- XESetWireToEvent (dpy,
- GenericEvent,
- xge_extension_hooks.wire_to_event);
- XESetEventToWire (dpy,
- GenericEvent,
- xge_extension_hooks.event_to_wire);
- }
- return dpyinfo;
-}
-
-/*
- * Check extension is set up and internal data fields are filled.
- */
-static Bool
-_xgeCheckExtInit(Display* dpy, XExtDisplayInfo* info)
-{
- LockDisplay(dpy);
- if(!_xgeCheckExtension(dpy, info))
- {
- goto cleanup;
- }
-
- if (!info->data)
- {
- XGEData* data = (XGEData*)Xmalloc(sizeof(XGEData));
- if (!data) {
- goto cleanup;
- }
- /* get version from server */
- data->vers =
- _xgeGetExtensionVersion(dpy, "Generic Event Extension", info);
- data->extensions = NULL;
- info->data = (XPointer)data;
- }
-
- UnlockDisplay(dpy);
- return True;
-
-cleanup:
- UnlockDisplay(dpy);
- return False;
-}
-
-/* Return 1 if XGE extension exists, 0 otherwise. */
-static Bool
-_xgeCheckExtension(Display* dpy, XExtDisplayInfo* info)
-{
- return XextHasExtension(info);
-}
-
-
-/* Retrieve XGE version number from server. */
-static XGEVersionRec*
-_xgeGetExtensionVersion(Display* dpy,
- _Xconst char* name,
- XExtDisplayInfo*info)
-{
- xGEQueryVersionReply rep;
- xGEQueryVersionReq *req;
- XGEVersionRec *vers;
-
- GetReq(GEQueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->ReqType = X_GEQueryVersion;
- req->majorVersion = GE_MAJOR;
- req->minorVersion = GE_MINOR;
-
- if (!_XReply (dpy, (xReply *) &rep, 0, xTrue))
- {
- Xfree(info);
- return NULL;
- }
-
- vers = (XGEVersionRec*)Xmalloc(sizeof(XGEVersionRec));
- vers->major_version = rep.majorVersion;
- vers->minor_version = rep.minorVersion;
- return vers;
-}
-
-/*
- * Display closing routine.
- */
-
-static int
-_xgeDpyClose(Display* dpy, XExtCodes* codes)
-{
- XExtDisplayInfo *info = _xgeFindDisplay(dpy);
-
- if (info->data != NULL) {
- XGEData* xge_data = (XGEData*)info->data;
-
- if (xge_data->extensions)
- {
- XGEExtList current, next;
- current = xge_data->extensions;
- while(current)
- {
- next = current->next;
- Xfree(current);
- current = next;
- }
- }
-
- XFree(xge_data->vers);
- XFree(xge_data);
- }
-
- return XextRemoveDisplay(xge_info, dpy);
-}
-
-/*
- * protocol to Xlib event conversion routine.
- */
-static Bool
-_xgeWireToEvent(Display* dpy, XEvent* re, xEvent *event)
-{
- int extension;
- XGEExtList it;
- XExtDisplayInfo* info = _xgeFindDisplay(dpy);
- if (!info)
- return False;
- /*
- _xgeCheckExtInit() calls LockDisplay, leading to a SIGABRT.
- Well, I guess we don't need the data we get in CheckExtInit anyway
- if (!_xgeCheckExtInit(dpy, info))
- return False;
- */
-
- extension = ((xGenericEvent*)event)->extension;
-
- it = ((XGEData*)info->data)->extensions;
- while(it)
- {
- if (it->extension == extension)
- {
- return (it->hooks->wire_to_event(dpy, re, event));
- }
- it = it->next;
- }
-
- fprintf(stderr,
- "_xgeWireToEvent: Unknown extension %d, this should never happen.\n",
- extension);
- return False;
-}
-
-/*
- * xlib event to protocol conversion routine.
- */
-static Status
-_xgeEventToWire(Display* dpy, XEvent* re, xEvent* event)
-{
- int extension;
- XGEExtList it;
- XExtDisplayInfo* info = _xgeFindDisplay(dpy);
- if (!info)
- return 1; /* error! */
-
- extension = ((XGenericEvent*)re)->extension;
-
- it = ((XGEData*)info->data)->extensions;
- while(it)
- {
- if (it->extension == extension)
- {
- return (it->hooks->event_to_wire(dpy, re, event));
- }
- it = it->next;
- }
-
- fprintf(stderr,
- "_xgeEventToWire: Unknown extension %d, this should never happen.\n",
- extension);
-
- return Success;
-}
-
-/*
- * Extensions need to register callbacks for their events.
- */
-Bool
-xgeExtRegister(Display* dpy, int offset, XExtensionHooks* callbacks)
-{
- XGEExtNode* newExt;
- XGEData* xge_data;
-
- XExtDisplayInfo* info = _xgeFindDisplay(dpy);
- if (!info)
- return False; /* error! */
-
- if (!_xgeCheckExtInit(dpy, info))
- return False;
-
- xge_data = (XGEData*)info->data;
-
- newExt = (XGEExtNode*)Xmalloc(sizeof(XGEExtNode));
- if (!newExt)
- {
- fprintf(stderr, "xgeExtRegister: Failed to alloc memory.\n");
- return False;
- }
-
- newExt->extension = offset;
- newExt->hooks = callbacks;
- newExt->next = xge_data->extensions;
- xge_data->extensions = newExt;
-
- return True;
-}
-
-/***********************************************************************/
-/* Client interfaces */
-/***********************************************************************/
-
-/* Set event_base and error_base to the matching values for XGE.
- * Note that since XGE doesn't use any errors and events, the actual return
- * value is of limited use.
- */
-Bool
-XGEQueryExtension(Display* dpy, int* event_base, int* error_base)
-{
- XExtDisplayInfo* info = _xgeFindDisplay(dpy);
- if (!_xgeCheckExtInit(dpy, info))
- return False;
-
- *event_base = info->codes->first_event;
- *error_base = info->codes->first_error;
- return True;
-}
-
-/* Get XGE version number.
- * Doesn't actually get it from server, that should have been done beforehand
- * already
- */
-Bool
-XGEQueryVersion(Display* dpy,
- int *major_version,
- int *minor_version)
-{
- XExtDisplayInfo* info = _xgeFindDisplay(dpy);
- if (!info)
- return False;
-
- if (!_xgeCheckExtInit(dpy, info))
- return False;
-
- *major_version = ((XGEData*)info->data)->vers->major_version;
- *minor_version = ((XGEData*)info->data)->vers->minor_version;
-
- return True;
-}
-
+/* + * Copyright © 2007-2008 Peter Hutterer + * + * 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. + * + * Authors: Peter Hutterer, University of South Australia, NICTA + */ + +/* + * XGE is an extension to re-use a single opcode for multiple events, + * depending on the extension. XGE allows events >32 bytes. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <X11/extensions/geproto.h> +#include <X11/extensions/ge.h> +#include <X11/Xlibint.h> +#include <X11/extensions/extutil.h> +#include <X11/extensions/Xge.h> + +/***********************************************************************/ +/* internal data structures */ +/***********************************************************************/ + +typedef struct { + int present; + short major_version; + short minor_version; +} XGEVersionRec; + +/* NULL terminated list of registered extensions. */ +typedef struct _XGEExtNode { + int extension; + XExtensionHooks* hooks; + struct _XGEExtNode* next; +} XGEExtNode, *XGEExtList; + +/* Internal data for GE extension */ +typedef struct _XGEData { + XEvent data; + XGEVersionRec *vers; + XGEExtList extensions; +} XGEData; + + +/* forward declarations */ +static XExtDisplayInfo* _xgeFindDisplay(Display*); +static Bool _xgeWireToEvent(Display*, XEvent*, xEvent*); +static Status _xgeEventToWire(Display*, XEvent*, xEvent*); +static int _xgeDpyClose(Display*, XExtCodes*); +static XGEVersionRec* _xgeGetExtensionVersion(Display*, + _Xconst char*, + XExtDisplayInfo*); +static Bool _xgeCheckExtension(Display* dpy, XExtDisplayInfo* info); + +/* main extension information data */ +static XExtensionInfo *xge_info; +static char xge_extension_name[] = GE_NAME; +static XExtensionHooks xge_extension_hooks = { + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + _xgeDpyClose, /* close_display */ + _xgeWireToEvent, /* wire_to_event */ + _xgeEventToWire, /* event_to_wire */ + NULL, /* error */ + NULL, /* error_string */ +}; + + +static XExtDisplayInfo *_xgeFindDisplay(Display *dpy) +{ + XExtDisplayInfo *dpyinfo; + if (!xge_info) + { + if (!(xge_info = XextCreateExtension())) + return NULL; + } + if (!(dpyinfo = XextFindDisplay (xge_info, dpy))) + { + dpyinfo = XextAddDisplay (xge_info, + dpy, + xge_extension_name, + &xge_extension_hooks, + 0 /* no events, see below */, + NULL); + /* We don't use an extension opcode, so we have to set the handlers + * directly. If GenericEvent would be > 64, the job would be done by + * XExtAddDisplay */ + XESetWireToEvent (dpy, + GenericEvent, + xge_extension_hooks.wire_to_event); + XESetEventToWire (dpy, + GenericEvent, + xge_extension_hooks.event_to_wire); + } + return dpyinfo; +} + +/* + * Check extension is set up and internal data fields are filled. + */ +static Bool +_xgeCheckExtInit(Display* dpy, XExtDisplayInfo* info) +{ + LockDisplay(dpy); + if(!_xgeCheckExtension(dpy, info)) + { + goto cleanup; + } + + if (!info->data) + { + XGEData* data = (XGEData*)Xmalloc(sizeof(XGEData)); + if (!data) { + goto cleanup; + } + /* get version from server */ + data->vers = + _xgeGetExtensionVersion(dpy, "Generic Event Extension", info); + data->extensions = NULL; + info->data = (XPointer)data; + } + + UnlockDisplay(dpy); + return True; + +cleanup: + UnlockDisplay(dpy); + return False; +} + +/* Return 1 if XGE extension exists, 0 otherwise. */ +static Bool +_xgeCheckExtension(Display* dpy, XExtDisplayInfo* info) +{ + return XextHasExtension(info); +} + + +/* Retrieve XGE version number from server. */ +static XGEVersionRec* +_xgeGetExtensionVersion(Display* dpy, + _Xconst char* name, + XExtDisplayInfo*info) +{ + xGEQueryVersionReply rep; + xGEQueryVersionReq *req; + XGEVersionRec *vers; + + GetReq(GEQueryVersion, req); + req->reqType = info->codes->major_opcode; + req->ReqType = X_GEQueryVersion; + req->majorVersion = GE_MAJOR; + req->minorVersion = GE_MINOR; + + if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) + { + Xfree(info); + return NULL; + } + + vers = (XGEVersionRec*)Xmalloc(sizeof(XGEVersionRec)); + vers->major_version = rep.majorVersion; + vers->minor_version = rep.minorVersion; + return vers; +} + +/* + * Display closing routine. + */ + +static int +_xgeDpyClose(Display* dpy, XExtCodes* codes) +{ + XExtDisplayInfo *info = _xgeFindDisplay(dpy); + + if (info->data != NULL) { + XGEData* xge_data = (XGEData*)info->data; + + if (xge_data->extensions) + { + XGEExtList current, next; + current = xge_data->extensions; + while(current) + { + next = current->next; + Xfree(current); + current = next; + } + } + + XFree(xge_data->vers); + XFree(xge_data); + } + + return XextRemoveDisplay(xge_info, dpy); +} + +/* + * protocol to Xlib event conversion routine. + */ +static Bool +_xgeWireToEvent(Display* dpy, XEvent* re, xEvent *event) +{ + int extension; + XGEExtList it; + XExtDisplayInfo* info = _xgeFindDisplay(dpy); + if (!info) + return False; + /* + _xgeCheckExtInit() calls LockDisplay, leading to a SIGABRT. + Well, I guess we don't need the data we get in CheckExtInit anyway + if (!_xgeCheckExtInit(dpy, info)) + return False; + */ + + extension = ((xGenericEvent*)event)->extension; + + it = ((XGEData*)info->data)->extensions; + while(it) + { + if (it->extension == extension) + { + return (it->hooks->wire_to_event(dpy, re, event)); + } + it = it->next; + } + + fprintf(stderr, + "_xgeWireToEvent: Unknown extension %d, this should never happen.\n", + extension); + return False; +} + +/* + * xlib event to protocol conversion routine. + */ +static Status +_xgeEventToWire(Display* dpy, XEvent* re, xEvent* event) +{ + int extension; + XGEExtList it; + XExtDisplayInfo* info = _xgeFindDisplay(dpy); + if (!info) + return 1; /* error! */ + + extension = ((XGenericEvent*)re)->extension; + + it = ((XGEData*)info->data)->extensions; + while(it) + { + if (it->extension == extension) + { + return (it->hooks->event_to_wire(dpy, re, event)); + } + it = it->next; + } + + fprintf(stderr, + "_xgeEventToWire: Unknown extension %d, this should never happen.\n", + extension); + + return Success; +} + +/* + * Extensions need to register callbacks for their events. + */ +Bool +_X_HIDDEN xgeExtRegister(Display* dpy, int offset, XExtensionHooks* callbacks) +{ + XGEExtNode* newExt; + XGEData* xge_data; + + XExtDisplayInfo* info = _xgeFindDisplay(dpy); + if (!info) + return False; /* error! */ + + if (!_xgeCheckExtInit(dpy, info)) + return False; + + xge_data = (XGEData*)info->data; + + newExt = (XGEExtNode*)Xmalloc(sizeof(XGEExtNode)); + if (!newExt) + { + fprintf(stderr, "xgeExtRegister: Failed to alloc memory.\n"); + return False; + } + + newExt->extension = offset; + newExt->hooks = callbacks; + newExt->next = xge_data->extensions; + xge_data->extensions = newExt; + + return True; +} + +/***********************************************************************/ +/* Client interfaces */ +/***********************************************************************/ + +/* Set event_base and error_base to the matching values for XGE. + * Note that since XGE doesn't use any errors and events, the actual return + * value is of limited use. + */ +Bool +XGEQueryExtension(Display* dpy, int* event_base, int* error_base) +{ + XExtDisplayInfo* info = _xgeFindDisplay(dpy); + if (!_xgeCheckExtInit(dpy, info)) + return False; + + *event_base = info->codes->first_event; + *error_base = info->codes->first_error; + return True; +} + +/* Get XGE version number. + * Doesn't actually get it from server, that should have been done beforehand + * already + */ +Bool +XGEQueryVersion(Display* dpy, + int *major_version, + int *minor_version) +{ + XExtDisplayInfo* info = _xgeFindDisplay(dpy); + if (!info) + return False; + + if (!_xgeCheckExtInit(dpy, info)) + return False; + + *major_version = ((XGEData*)info->data)->vers->major_version; + *minor_version = ((XGEData*)info->data)->vers->minor_version; + + return True; +} + diff --git a/mesalib/docs/GL3.txt b/mesalib/docs/GL3.txt index 9ff25a952..0c53bc42d 100644 --- a/mesalib/docs/GL3.txt +++ b/mesalib/docs/GL3.txt @@ -27,7 +27,7 @@ Non-normalized Integer texture/framebuffer formats ~50% done 1D/2D Texture arrays core Mesa, swrast done Packed depth/stencil formats DONE Per-buffer blend and masks (GL_EXT_draw_buffers2) DONE -GL_EXT_texture_compression_rgtc not started +GL_EXT_texture_compression_rgtc DONE (swrast, gallium r600) Red and red/green texture formats DONE (swrast, i965, gallium) Transform feedback (GL_EXT_transform_feedback) ~50% done glBindFragDataLocation, glGetFragDataLocation, diff --git a/mesalib/docs/MESA_multithread_makecurrent.spec b/mesalib/docs/MESA_multithread_makecurrent.spec new file mode 100644 index 000000000..5065c2fc0 --- /dev/null +++ b/mesalib/docs/MESA_multithread_makecurrent.spec @@ -0,0 +1,158 @@ +Name + + MESA_multithread_makecurrent + +Name Strings + + GLX_MESA_multithread_makecurrent + +Contact + + Eric Anholt (eric@anholt.net) + +Status + + Not shipping. + +Version + + Last Modified Date: 21 February 2011 + +Number + + TBD + +Dependencies + + OpenGL 1.0 or later is required. + GLX 1.3 or later is required. + +Overview + + The GLX context setup encourages multithreaded applications to + create a context per thread which each operate on their own + objects in parallel, and leaves synchronization for write access + to shared objects up to the application. + + For some applications, maintaining per-thread contexts and + ensuring that the glFlush happens in one thread before another + thread starts working on that object is difficult. For them, + using the same context across multiple threads and protecting its + usage with a mutex is both higher performance and easier to + implement. This extension gives those applications that option by + relaxing the context binding requirements. + + This new behavior matches the requirements of AGL, while providing + a feature not specified in WGL. + +IP Status + + Open-source; freely implementable. + +Issues + + None. + +New Procedures and Functions + + None. + +New Tokens + + None. + +Changes to Chapter 2 of the GLX 1.3 Specification (Functions and Errors) + + Replace the following sentence from section 2.2 Rendering Contexts: + In addition, a rendering context can be current for only one + thread at a time. + with: + In addition, an indirect rendering context can be current for + only one thread at a time. A direct rendering context may be + current to multiple threads, with synchronization of access to + the context thruogh the GL managed by the application through + mutexes. + +Changes to Chapter 3 of the GLX 1.3 Specification (Functions and Errors) + + Replace the following sentence from section 3.3.7 Rendering Contexts: + If ctx is current to some other thread, then + glXMakeContextCurrent will generate a BadAccess error. + with: + If ctx is an indirect context current to some other thread, + then glXMakeContextCurrent will generate a BadAccess error. + + Replace the following sentence from section 3.5 Rendering Contexts: + If ctx is current to some other thread, then + glXMakeCurrent will generate a BadAccess error. + with: + If ctx is an indirect context current to some other thread, + then glXMakeCurrent will generate a BadAccess error. + +GLX Protocol + + None. The GLX extension only extends to direct rendering contexts. + +Errors + + None. + +New State + + None. + +Issues + + (1) What happens if the app binds a context/drawable in multiple + threads, then binds a different context/thread in one of them? + + As with binding a new context from the current thread, the old + context's refcount is reduced and the new context's refcount is + increased. + + (2) What happens if the app binds a context/drawable in multiple + threads, then binds None/None in one of them? + + The GLX context is unreferenced from that thread, and the other + threads retain their GLX context binding. + + (3) What happens if the app binds a context/drawable in 7 threads, + then destroys the context in one of them? + + As with GLX context destruction previously, the XID is destroyed + but the context remains usable by threads that have the context + current. + + (4) What happens if the app binds a new drawable/readable with + glXMakeCurrent() when it is already bound to another thread? + + The context becomes bound to the new drawable/readable, and + further rendering in either thread will use the new + drawable/readable. + + (5) What requirements should be placed on the user managing contexts + from multiple threads? + + The intention is to allow multithreaded access to the GL at the + minimal performance cost, so requiring that the GL do general + synchronization (beyond that already required by context sharing) + is not an option, and synchronizing of GL's access to the GL + context between multiple threads is left to the application to do + across GL calls. However, it would be unfortunate for a library + doing multithread_makecurrent to require that other libraries + share in synchronization for binding of their own contexts, so the + refcounting of the contexts is required to be threadsafe. + + (6) Does this apply to indirect contexts? + + This was ignored in the initial revision of the spec. Behavior + for indirect contexts is left as-is. + +Revision History + + 20 November 2009 Eric Anholt - initial specification + 22 November 2009 Eric Anholt - added issues from Ian Romanick. + 3 February 2011 Eric Anholt - updated with resolution to issues 1-3 + 3 February 2011 Eric Anholt - added issue 4, 5 + 21 February 2011 Eric Anholt - Include glXMakeCurrent() sentence + along with glXMakeContextCurrent() for removal. diff --git a/mesalib/docs/relnotes-7.11.html b/mesalib/docs/relnotes-7.11.html index 8bc3e2997..4b1730b17 100644 --- a/mesalib/docs/relnotes-7.11.html +++ b/mesalib/docs/relnotes-7.11.html @@ -1,59 +1,60 @@ -<HTML>
-
-<head>
-<TITLE>Mesa Release Notes</TITLE>
-<link rel="stylesheet" type="text/css" href="mesa.css">
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
-</head>
-
-<BODY>
-
-<body bgcolor="#eeeeee">
-
-<H1>Mesa 7.11 Release Notes / (release date TBD)</H1>
-
-<p>
-Mesa 7.11 is a new development release.
-People who are concerned with stability and reliability should stick
-with a previous release or wait for Mesa 7.11.1.
-</p>
-<p>
-Mesa 7.11 implements the OpenGL 2.1 API, but the version reported by
-glGetString(GL_VERSION) depends on the particular driver being used.
-Some drivers don't support all the features required in OpenGL 2.1.
-</p>
-<p>
-See the <a href="install.html">Compiling/Installing page</a> for prerequisites
-for DRI hardware acceleration.
-</p>
-
-
-<h2>MD5 checksums</h2>
-<pre>
-tbd
-</pre>
-
-
-<h2>New features</h2>
-<ul>
-<li>GL_ARB_draw_instanced extension (gallium drivers, swrast)
-<li>GL_ARB_instanced_arrays extension (gallium drivers)
-<li>GL_ARB_draw_buffers_blend (gallium)
-<li>GL_EXT_texture_sRGB_decode (gallium drivers, swrast, i965)
-</ul>
-
-
-<h2>Bug fixes</h2>
-<ul>
-</ul>
-
-
-<h2>Changes</h2>
-<ul>
-<li>The Windows MSVC project files have been removed. They haven't been maintained
-in quite a while. Building with SCons is an alterantive.
-</ul>
-
-
-</body>
-</html>
+<HTML> + +<head> +<TITLE>Mesa Release Notes</TITLE> +<link rel="stylesheet" type="text/css" href="mesa.css"> +<meta http-equiv="content-type" content="text/html; charset=utf-8" /> +</head> + +<BODY> + +<body bgcolor="#eeeeee"> + +<H1>Mesa 7.11 Release Notes / (release date TBD)</H1> + +<p> +Mesa 7.11 is a new development release. +People who are concerned with stability and reliability should stick +with a previous release or wait for Mesa 7.11.1. +</p> +<p> +Mesa 7.11 implements the OpenGL 2.1 API, but the version reported by +glGetString(GL_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 2.1. +</p> +<p> +See the <a href="install.html">Compiling/Installing page</a> for prerequisites +for DRI hardware acceleration. +</p> + + +<h2>MD5 checksums</h2> +<pre> +tbd +</pre> + + +<h2>New features</h2> +<ul> +<li>GL_ARB_draw_instanced extension (gallium drivers, swrast) +<li>GL_ARB_instanced_arrays extension (gallium drivers) +<li>GL_ARB_texture_compression_rgtc (gallium r600, swrast) +<li>GL_ARB_draw_buffers_blend (gallium) +<li>GL_EXT_texture_sRGB_decode (gallium drivers, swrast, i965) +</ul> + + +<h2>Bug fixes</h2> +<ul> +</ul> + + +<h2>Changes</h2> +<ul> +<li>The Windows MSVC project files have been removed. They haven't been maintained +in quite a while. Building with SCons is an alterantive. +</ul> + + +</body> +</html> diff --git a/mesalib/src/glsl/Makefile b/mesalib/src/glsl/Makefile index f964b7487..df031d2d5 100644 --- a/mesalib/src/glsl/Makefile +++ b/mesalib/src/glsl/Makefile @@ -1,213 +1,213 @@ -
-#src/glsl/pp/Makefile
-
-TOP = ../..
-
-include $(TOP)/configs/current
-
-LIBNAME = glsl
-
-LIBGLCPP_SOURCES = \
- glcpp/glcpp-lex.c \
- glcpp/glcpp-parse.c \
- glcpp/pp.c
-
-GLCPP_SOURCES = \
- $(LIBGLCPP_SOURCES) \
- ralloc.c \
- glcpp/glcpp.c
-
-C_SOURCES = \
- strtod.c \
- ralloc.c \
- $(LIBGLCPP_SOURCES)
-
-CXX_SOURCES = \
- ast_expr.cpp \
- ast_function.cpp \
- ast_to_hir.cpp \
- ast_type.cpp \
- glsl_lexer.cpp \
- glsl_parser.cpp \
- glsl_parser_extras.cpp \
- glsl_types.cpp \
- glsl_symbol_table.cpp \
- hir_field_selection.cpp \
- ir_basic_block.cpp \
- ir_clone.cpp \
- ir_constant_expression.cpp \
- ir.cpp \
- ir_expression_flattening.cpp \
- ir_function_can_inline.cpp \
- ir_function.cpp \
- ir_hierarchical_visitor.cpp \
- ir_hv_accept.cpp \
- ir_import_prototypes.cpp \
- ir_print_visitor.cpp \
- ir_reader.cpp \
- ir_rvalue_visitor.cpp \
- ir_set_program_inouts.cpp \
- ir_validate.cpp \
- ir_variable.cpp \
- ir_variable_refcount.cpp \
- linker.cpp \
- link_functions.cpp \
- loop_analysis.cpp \
- loop_controls.cpp \
- loop_unroll.cpp \
- lower_discard.cpp \
- lower_if_to_cond_assign.cpp \
- lower_instructions.cpp \
- lower_jumps.cpp \
- lower_mat_op_to_vec.cpp \
- lower_noise.cpp \
- lower_texture_projection.cpp \
- lower_variable_index_to_cond_assign.cpp \
- lower_vec_index_to_cond_assign.cpp \
- lower_vec_index_to_swizzle.cpp \
- lower_vector.cpp \
- opt_algebraic.cpp \
- opt_constant_folding.cpp \
- opt_constant_propagation.cpp \
- opt_constant_variable.cpp \
- opt_copy_propagation.cpp \
- opt_copy_propagation_elements.cpp \
- opt_dead_code.cpp \
- opt_dead_code_local.cpp \
- opt_dead_functions.cpp \
- opt_discard_simplification.cpp \
- opt_function_inlining.cpp \
- opt_if_simplification.cpp \
- opt_noop_swizzle.cpp \
- opt_redundant_jumps.cpp \
- opt_structure_splitting.cpp \
- opt_swizzle_swizzle.cpp \
- opt_tree_grafting.cpp \
- s_expression.cpp
-
-LIBS = \
- $(TOP)/src/glsl/libglsl.a
-
-APPS = glsl_compiler glcpp/glcpp
-
-GLSL2_C_SOURCES = \
- ../mesa/program/hash_table.c \
- ../mesa/program/symbol_table.c
-GLSL2_CXX_SOURCES = \
- main.cpp
-
-GLSL2_OBJECTS = \
- $(GLSL2_C_SOURCES:.c=.o) \
- $(GLSL2_CXX_SOURCES:.cpp=.o)
-
-### Basic defines ###
-
-DEFINES += \
- $(LIBRARY_DEFINES) \
- $(API_DEFINES)
-
-GLCPP_OBJECTS = \
- $(GLCPP_SOURCES:.c=.o) \
- ../mesa/program/hash_table.o
-
-OBJECTS = \
- $(C_SOURCES:.c=.o) \
- $(CXX_SOURCES:.cpp=.o)
-
-DRICORE_OBJ_DIR = obj-visible
-OBJECTS_DRICORE = $(addprefix $(DRICORE_OBJ_DIR)/,$(OBJECTS))
-
-INCLUDES = \
- -I. \
- -I../mesa \
- -I../mapi \
- -I../../include \
- $(LIBRARY_INCLUDES)
-
-ALL_SOURCES = \
- $(C_SOURCES) \
- $(CXX_SOURCES) \
- $(GLSL2_CXX_SOURCES) \
- $(GLSL2_C_SOURCES)
-
-##### TARGETS #####
-
-default: depend lib$(LIBNAME).a $(APPS) $(DRICORE_GLSL_LIBS)
-
-$(TOP)/$(LIB_DIR)/libglsl.so: $(OBJECTS_DRICORE) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template
- $(MKLIB) -o $@ -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
- -cplusplus -noprefix \
- -install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/$@.dylib \
- $(OBJECTS_DRICORE) builtin_function.o
-
-lib$(LIBNAME).a: $(OBJECTS) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template
- $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS) builtin_function.o
-
-depend: $(ALL_SOURCES) Makefile
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null
-
-# Remove .o and backup files
-clean: clean-dricore
- rm -f $(GLCPP_OBJECTS) $(GLSL2_OBJECTS) $(OBJECTS) lib$(LIBNAME).a depend depend.bak builtin_function.cpp builtin_function.o builtin_stubs.o builtin_compiler
- -rm -f $(APPS)
-
-clean-dricore:
- -rm -f $(DRICORE_OBJ_DIR) $(TOP)/$(LIB_DIR)/libglsl.so libglsl.so
-
-ifneq (,$(DRICORE_GLSL_LIBS))
-DRICORE_INSTALL_TARGET = install-dricore
-endif
-
-# Dummy target
-install: $(DRICORE_INSTALL_TARGET)
- @echo -n ""
-
-install-dricore: default
- $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
- $(INSTALL) -m 755 $(DRICORE_GLSL_LIBS) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
-
-##### RULES #####
-
-glsl_compiler: $(GLSL2_OBJECTS) libglsl.a builtin_stubs.o
- $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) builtin_stubs.o $(LIBS) -o $@
-
-glcpp: glcpp/glcpp
-glcpp/glcpp: $(GLCPP_OBJECTS)
- $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
-
-$(DRICORE_OBJ_DIR)/%.o : %.cpp
- @mkdir -p $(dir $@)
- $(CXX) -c $(INCLUDES) $(DRI_CXXFLAGS) $(DEFINES) $< -o $@
-
-$(DRICORE_OBJ_DIR)/%.o : %.c
- @mkdir -p $(dir $@)
- $(CC) -c $(INCLUDES) $(DRI_CFLAGS) $(DEFINES) $< -o $@
-
-glsl_lexer.cpp: glsl_lexer.lpp
- flex --nounistd -o$@ $<
-
-glsl_parser.cpp: glsl_parser.ypp
- bison -v -o "$@" -p "_mesa_glsl_" --defines=glsl_parser.h $<
-
-glcpp/glcpp-lex.c: glcpp/glcpp-lex.l
- flex --nounistd -o$@ $<
-
-glcpp/glcpp-parse.c: glcpp/glcpp-parse.y
- bison -v -o "$@" --defines=glcpp/glcpp-parse.h $<
-
-builtin_compiler: $(GLSL2_OBJECTS) $(OBJECTS) builtin_stubs.o
- $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(GLSL2_OBJECTS) builtin_stubs.o -o $@
-
-builtin_function.cpp: builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py builtin_compiler
- @echo Regenerating builtin_function.cpp...
- $(PYTHON2) $(PYTHON_FLAGS) builtins/tools/generate_builtins.py ./builtin_compiler > builtin_function.cpp
-
--include depend
+ +#src/glsl/pp/Makefile + +TOP = ../.. + +include $(TOP)/configs/current + +LIBNAME = glsl + +LIBGLCPP_SOURCES = \ + glcpp/glcpp-lex.c \ + glcpp/glcpp-parse.c \ + glcpp/pp.c + +GLCPP_SOURCES = \ + $(LIBGLCPP_SOURCES) \ + ralloc.c \ + glcpp/glcpp.c + +C_SOURCES = \ + strtod.c \ + ralloc.c \ + $(LIBGLCPP_SOURCES) + +CXX_SOURCES = \ + ast_expr.cpp \ + ast_function.cpp \ + ast_to_hir.cpp \ + ast_type.cpp \ + glsl_lexer.cpp \ + glsl_parser.cpp \ + glsl_parser_extras.cpp \ + glsl_types.cpp \ + glsl_symbol_table.cpp \ + hir_field_selection.cpp \ + ir_basic_block.cpp \ + ir_clone.cpp \ + ir_constant_expression.cpp \ + ir.cpp \ + ir_expression_flattening.cpp \ + ir_function_can_inline.cpp \ + ir_function.cpp \ + ir_hierarchical_visitor.cpp \ + ir_hv_accept.cpp \ + ir_import_prototypes.cpp \ + ir_print_visitor.cpp \ + ir_reader.cpp \ + ir_rvalue_visitor.cpp \ + ir_set_program_inouts.cpp \ + ir_validate.cpp \ + ir_variable.cpp \ + ir_variable_refcount.cpp \ + linker.cpp \ + link_functions.cpp \ + loop_analysis.cpp \ + loop_controls.cpp \ + loop_unroll.cpp \ + lower_discard.cpp \ + lower_if_to_cond_assign.cpp \ + lower_instructions.cpp \ + lower_jumps.cpp \ + lower_mat_op_to_vec.cpp \ + lower_noise.cpp \ + lower_texture_projection.cpp \ + lower_variable_index_to_cond_assign.cpp \ + lower_vec_index_to_cond_assign.cpp \ + lower_vec_index_to_swizzle.cpp \ + lower_vector.cpp \ + opt_algebraic.cpp \ + opt_constant_folding.cpp \ + opt_constant_propagation.cpp \ + opt_constant_variable.cpp \ + opt_copy_propagation.cpp \ + opt_copy_propagation_elements.cpp \ + opt_dead_code.cpp \ + opt_dead_code_local.cpp \ + opt_dead_functions.cpp \ + opt_discard_simplification.cpp \ + opt_function_inlining.cpp \ + opt_if_simplification.cpp \ + opt_noop_swizzle.cpp \ + opt_redundant_jumps.cpp \ + opt_structure_splitting.cpp \ + opt_swizzle_swizzle.cpp \ + opt_tree_grafting.cpp \ + s_expression.cpp + +LIBS = \ + $(TOP)/src/glsl/libglsl.a + +APPS = glsl_compiler glcpp/glcpp + +GLSL2_C_SOURCES = \ + ../mesa/program/hash_table.c \ + ../mesa/program/symbol_table.c +GLSL2_CXX_SOURCES = \ + main.cpp + +GLSL2_OBJECTS = \ + $(GLSL2_C_SOURCES:.c=.o) \ + $(GLSL2_CXX_SOURCES:.cpp=.o) + +### Basic defines ### + +DEFINES += \ + $(LIBRARY_DEFINES) \ + $(API_DEFINES) + +GLCPP_OBJECTS = \ + $(GLCPP_SOURCES:.c=.o) \ + ../mesa/program/hash_table.o + +OBJECTS = \ + $(C_SOURCES:.c=.o) \ + $(CXX_SOURCES:.cpp=.o) + +DRICORE_OBJ_DIR = obj-visible +OBJECTS_DRICORE = $(addprefix $(DRICORE_OBJ_DIR)/,$(OBJECTS)) + +INCLUDES = \ + -I. \ + -I../mesa \ + -I../mapi \ + -I../../include \ + $(LIBRARY_INCLUDES) + +ALL_SOURCES = \ + $(C_SOURCES) \ + $(CXX_SOURCES) \ + $(GLSL2_CXX_SOURCES) \ + $(GLSL2_C_SOURCES) + +##### TARGETS ##### + +default: depend lib$(LIBNAME).a $(APPS) $(DRICORE_GLSL_LIBS) + +$(TOP)/$(LIB_DIR)/libglsl.so: $(OBJECTS_DRICORE) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template + $(MKLIB) -o $@ -linker '$(CXX)' -ldflags '$(LDFLAGS)' \ + -cplusplus -noprefix \ + -install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/$@.dylib \ + $(OBJECTS_DRICORE) builtin_function.o + +lib$(LIBNAME).a: $(OBJECTS) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template + $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS) builtin_function.o + +depend: $(ALL_SOURCES) Makefile + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null + +# Remove .o and backup files +clean: clean-dricore + rm -f $(GLCPP_OBJECTS) $(GLSL2_OBJECTS) $(OBJECTS) lib$(LIBNAME).a depend depend.bak builtin_function.cpp builtin_function.o builtin_stubs.o builtin_compiler + -rm -f $(APPS) + +clean-dricore: + -rm -f $(DRICORE_OBJ_DIR) $(TOP)/$(LIB_DIR)/libglsl.so libglsl.so + +ifneq (,$(DRICORE_GLSL_LIBS)) +DRICORE_INSTALL_TARGET = install-dricore +endif + +# Dummy target +install: $(DRICORE_INSTALL_TARGET) + @echo -n "" + +install-dricore: default + $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + $(INSTALL) -m 755 $(DRICORE_GLSL_LIBS) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + +##### RULES ##### + +glsl_compiler: $(GLSL2_OBJECTS) libglsl.a builtin_stubs.o + $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) builtin_stubs.o $(LIBS) -o $@ + +glcpp: glcpp/glcpp +glcpp/glcpp: $(GLCPP_OBJECTS) + $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) -o $@ + +.cpp.o: + $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@ + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +$(DRICORE_OBJ_DIR)/%.o : %.cpp + @mkdir -p $(dir $@) + $(CXX) -c $(INCLUDES) $(DRI_CXXFLAGS) $(DEFINES) $< -o $@ + +$(DRICORE_OBJ_DIR)/%.o : %.c + @mkdir -p $(dir $@) + $(CC) -c $(INCLUDES) $(DRI_CFLAGS) $(DEFINES) $< -o $@ + +glsl_lexer.cpp: glsl_lexer.lpp + flex --nounistd -o$@ $< + +glsl_parser.cpp: glsl_parser.ypp + bison -v -o "$@" -p "_mesa_glsl_" --defines=glsl_parser.h $< + +glcpp/glcpp-lex.c: glcpp/glcpp-lex.l + flex --nounistd -o$@ $< + +glcpp/glcpp-parse.c: glcpp/glcpp-parse.y + bison -v -o "$@" --defines=glcpp/glcpp-parse.h $< + +builtin_compiler: $(GLSL2_OBJECTS) $(OBJECTS) builtin_stubs.o + $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(GLSL2_OBJECTS) builtin_stubs.o -o $@ + +builtin_function.cpp: builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py builtin_compiler + @echo Regenerating builtin_function.cpp... + $(PYTHON2) $(PYTHON_FLAGS) builtins/tools/generate_builtins.py ./builtin_compiler > builtin_function.cpp || rm -f builtin_function.cpp + +-include depend diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index 9f58b45e2..310740b0d 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -1,915 +1,916 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.6
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * 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
- * BRIAN PAUL 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.
- */
-
-
-/**
- * \file
- * \brief Extension handling
- */
-
-
-#include "glheader.h"
-#include "imports.h"
-#include "context.h"
-#include "extensions.h"
-#include "mfeatures.h"
-#include "mtypes.h"
-
-enum {
- DISABLE = 0,
- GL = 1 << API_OPENGL,
- ES1 = 1 << API_OPENGLES,
- ES2 = 1 << API_OPENGLES2,
-};
-
-/**
- * \brief An element of the \c extension_table.
- */
-struct extension {
- /** Name of extension, such as "GL_ARB_depth_clamp". */
- const char *name;
-
- /** Offset (in bytes) of the corresponding member in struct gl_extensions. */
- size_t offset;
-
- /** Set of API's in which the extension exists, as a bitset. */
- uint8_t api_set;
-};
-
-
-/**
- * Given a member \c x of struct gl_extensions, return offset of
- * \c x in bytes.
- */
-#define o(x) offsetof(struct gl_extensions, x)
-
-
-/**
- * \brief Table of supported OpenGL extensions for all API's.
- *
- * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions.
- */
-static const struct extension extension_table[] = {
- /* ARB Extensions */
- { "GL_ARB_ES2_compatibility", o(ARB_ES2_compatibility), GL },
- { "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), GL },
- { "GL_ARB_copy_buffer", o(ARB_copy_buffer), GL },
- { "GL_ARB_depth_buffer_float", o(ARB_depth_buffer_float), GL },
- { "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL },
- { "GL_ARB_depth_texture", o(ARB_depth_texture), GL },
- { "GL_ARB_draw_buffers", o(ARB_draw_buffers), GL },
- { "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL },
- { "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL },
- { "GL_ARB_draw_instanced", o(ARB_draw_instanced), GL },
- { "GL_ARB_explicit_attrib_location", o(ARB_explicit_attrib_location), GL },
- { "GL_ARB_fragment_coord_conventions", o(ARB_fragment_coord_conventions), GL },
- { "GL_ARB_fragment_program", o(ARB_fragment_program), GL },
- { "GL_ARB_fragment_program_shadow", o(ARB_fragment_program_shadow), GL },
- { "GL_ARB_fragment_shader", o(ARB_fragment_shader), GL },
- { "GL_ARB_framebuffer_object", o(ARB_framebuffer_object), GL },
- { "GL_ARB_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL },
- { "GL_ARB_half_float_pixel", o(ARB_half_float_pixel), GL },
- { "GL_ARB_half_float_vertex", o(ARB_half_float_vertex), GL },
- { "GL_ARB_instanced_arrays", o(ARB_instanced_arrays), GL },
- { "GL_ARB_map_buffer_range", o(ARB_map_buffer_range), GL },
- { "GL_ARB_multisample", o(ARB_multisample), GL },
- { "GL_ARB_multitexture", o(ARB_multitexture), GL },
- { "GL_ARB_occlusion_query2", o(ARB_occlusion_query2), GL },
- { "GL_ARB_occlusion_query", o(ARB_occlusion_query), GL },
- { "GL_ARB_pixel_buffer_object", o(EXT_pixel_buffer_object), GL },
- { "GL_ARB_point_parameters", o(EXT_point_parameters), GL },
- { "GL_ARB_point_sprite", o(ARB_point_sprite), GL },
- { "GL_ARB_provoking_vertex", o(EXT_provoking_vertex), GL },
- { "GL_ARB_sampler_objects", o(ARB_sampler_objects), GL },
- { "GL_ARB_seamless_cube_map", o(ARB_seamless_cube_map), GL },
- { "GL_ARB_shader_objects", o(ARB_shader_objects), GL },
- { "GL_ARB_shader_stencil_export", o(ARB_shader_stencil_export), GL },
- { "GL_ARB_shading_language_100", o(ARB_shading_language_100), GL },
- { "GL_ARB_shadow_ambient", o(ARB_shadow_ambient), GL },
- { "GL_ARB_shadow", o(ARB_shadow), GL },
- { "GL_ARB_sync", o(ARB_sync), GL },
- { "GL_ARB_texture_border_clamp", o(ARB_texture_border_clamp), GL },
- { "GL_ARB_texture_buffer_object", o(ARB_texture_buffer_object), GL },
- { "GL_ARB_texture_compression", o(ARB_texture_compression), GL },
- { "GL_ARB_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL },
- { "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), GL },
- { "GL_ARB_texture_env_add", o(EXT_texture_env_add), GL },
- { "GL_ARB_texture_env_combine", o(ARB_texture_env_combine), GL },
- { "GL_ARB_texture_env_crossbar", o(ARB_texture_env_crossbar), GL },
- { "GL_ARB_texture_env_dot3", o(ARB_texture_env_dot3), GL },
- { "GL_ARB_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), GL },
- { "GL_ARB_texture_multisample", o(ARB_texture_multisample), GL },
- { "GL_ARB_texture_non_power_of_two", o(ARB_texture_non_power_of_two), GL },
- { "GL_ARB_texture_rectangle", o(NV_texture_rectangle), GL },
- { "GL_ARB_texture_rgb10_a2ui", o(ARB_texture_rgb10_a2ui), GL },
- { "GL_ARB_texture_rg", o(ARB_texture_rg), GL },
- { "GL_ARB_texture_swizzle", o(EXT_texture_swizzle), GL },
- { "GL_ARB_transform_feedback2", o(ARB_transform_feedback2), GL },
- { "GL_ARB_transpose_matrix", o(ARB_transpose_matrix), GL },
- { "GL_ARB_uniform_buffer_object", o(ARB_uniform_buffer_object), GL },
- { "GL_ARB_vertex_array_bgra", o(EXT_vertex_array_bgra), GL },
- { "GL_ARB_vertex_array_object", o(ARB_vertex_array_object), GL },
- { "GL_ARB_vertex_buffer_object", o(ARB_vertex_buffer_object), GL },
- { "GL_ARB_vertex_program", o(ARB_vertex_program), GL },
- { "GL_ARB_vertex_shader", o(ARB_vertex_shader), GL },
- { "GL_ARB_vertex_type_2_10_10_10_rev", o(ARB_vertex_type_2_10_10_10_rev), GL },
- { "GL_ARB_window_pos", o(ARB_window_pos), GL },
-
- /* EXT extensions */
- { "GL_EXT_abgr", o(EXT_abgr), GL },
- { "GL_EXT_bgra", o(EXT_bgra), GL },
- { "GL_EXT_blend_color", o(EXT_blend_color), GL },
- { "GL_EXT_blend_equation_separate", o(EXT_blend_equation_separate), GL },
- { "GL_EXT_blend_func_separate", o(EXT_blend_func_separate), GL },
- { "GL_EXT_blend_logic_op", o(EXT_blend_logic_op), GL },
- { "GL_EXT_blend_minmax", o(EXT_blend_minmax), GL | ES1 | ES2 },
- { "GL_EXT_blend_subtract", o(EXT_blend_subtract), GL },
- { "GL_EXT_clip_volume_hint", o(EXT_clip_volume_hint), GL },
- { "GL_EXT_compiled_vertex_array", o(EXT_compiled_vertex_array), GL },
- { "GL_EXT_copy_texture", o(EXT_copy_texture), GL },
- { "GL_EXT_depth_bounds_test", o(EXT_depth_bounds_test), GL },
- { "GL_EXT_draw_buffers2", o(EXT_draw_buffers2), GL },
- { "GL_EXT_draw_instanced", o(ARB_draw_instanced), GL },
- { "GL_EXT_draw_range_elements", o(EXT_draw_range_elements), GL },
- { "GL_EXT_fog_coord", o(EXT_fog_coord), GL },
- { "GL_EXT_framebuffer_blit", o(EXT_framebuffer_blit), GL },
- { "GL_EXT_framebuffer_multisample", o(EXT_framebuffer_multisample), GL },
- { "GL_EXT_framebuffer_object", o(EXT_framebuffer_object), GL },
- { "GL_EXT_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL },
- { "GL_EXT_gpu_program_parameters", o(EXT_gpu_program_parameters), GL },
- { "GL_EXT_gpu_shader4", o(EXT_gpu_shader4), GL },
- { "GL_EXT_multi_draw_arrays", o(EXT_multi_draw_arrays), GL | ES1 | ES2 },
- { "GL_EXT_packed_depth_stencil", o(EXT_packed_depth_stencil), GL },
- { "GL_EXT_packed_float", o(EXT_packed_float), GL },
- { "GL_EXT_packed_pixels", o(EXT_packed_pixels), GL },
- { "GL_EXT_paletted_texture", o(EXT_paletted_texture), GL },
- { "GL_EXT_pixel_buffer_object", o(EXT_pixel_buffer_object), GL },
- { "GL_EXT_point_parameters", o(EXT_point_parameters), GL },
- { "GL_EXT_polygon_offset", o(EXT_polygon_offset), GL },
- { "GL_EXT_provoking_vertex", o(EXT_provoking_vertex), GL },
- { "GL_EXT_rescale_normal", o(EXT_rescale_normal), GL },
- { "GL_EXT_secondary_color", o(EXT_secondary_color), GL },
- { "GL_EXT_separate_shader_objects", o(EXT_separate_shader_objects), GL },
- { "GL_EXT_separate_specular_color", o(EXT_separate_specular_color), GL },
- { "GL_EXT_shadow_funcs", o(EXT_shadow_funcs), GL },
- { "GL_EXT_shared_texture_palette", o(EXT_shared_texture_palette), GL },
- { "GL_EXT_stencil_two_side", o(EXT_stencil_two_side), GL },
- { "GL_EXT_stencil_wrap", o(EXT_stencil_wrap), GL },
- { "GL_EXT_subtexture", o(EXT_subtexture), GL },
- { "GL_EXT_texture3D", o(EXT_texture3D), GL },
- { "GL_EXT_texture_array", o(EXT_texture_array), GL },
- { "GL_EXT_texture_compression_dxt1", o(EXT_texture_compression_s3tc), GL | ES1 | ES2 },
- { "GL_EXT_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL },
- { "GL_EXT_texture_compression_s3tc", o(EXT_texture_compression_s3tc), GL },
- { "GL_EXT_texture_cube_map", o(ARB_texture_cube_map), GL },
- { "GL_EXT_texture_edge_clamp", o(SGIS_texture_edge_clamp), GL },
- { "GL_EXT_texture_env_add", o(EXT_texture_env_add), GL },
- { "GL_EXT_texture_env_combine", o(EXT_texture_env_combine), GL },
- { "GL_EXT_texture_env_dot3", o(EXT_texture_env_dot3), GL },
- { "GL_EXT_texture_filter_anisotropic", o(EXT_texture_filter_anisotropic), GL | ES1 | ES2 },
- { "GL_EXT_texture_format_BGRA8888", o(EXT_texture_format_BGRA8888), ES1 | ES2 },
- { "GL_EXT_texture_integer", o(EXT_texture_integer), GL },
- { "GL_EXT_texture_lod_bias", o(EXT_texture_lod_bias), GL | ES1 },
- { "GL_EXT_texture_mirror_clamp", o(EXT_texture_mirror_clamp), GL },
- { "GL_EXT_texture_object", o(EXT_texture_object), GL },
- { "GL_EXT_texture", o(EXT_texture), GL },
- { "GL_EXT_texture_rectangle", o(NV_texture_rectangle), GL },
- { "GL_EXT_texture_shared_exponent", o(EXT_texture_shared_exponent), GL },
- { "GL_EXT_texture_sRGB", o(EXT_texture_sRGB), GL },
- { "GL_EXT_texture_sRGB_decode", o(EXT_texture_sRGB_decode), GL },
- { "GL_EXT_texture_swizzle", o(EXT_texture_swizzle), GL },
- { "GL_EXT_texture_type_2_10_10_10_REV", o(dummy_true), ES2 },
- { "GL_EXT_timer_query", o(EXT_timer_query), GL },
- { "GL_EXT_transform_feedback", o(EXT_transform_feedback), GL },
- { "GL_EXT_vertex_array_bgra", o(EXT_vertex_array_bgra), GL },
- { "GL_EXT_vertex_array", o(EXT_vertex_array), GL },
- { "GL_EXT_vertex_array_set", o(EXT_vertex_array_set), GL },
-
- /* OES extensions */
- { "GL_OES_blend_equation_separate", o(EXT_blend_equation_separate), ES1 },
- { "GL_OES_blend_func_separate", o(EXT_blend_func_separate), ES1 },
- { "GL_OES_blend_subtract", o(EXT_blend_subtract), ES1 },
- { "GL_OES_byte_coordinates", o(dummy_true), ES1 },
- { "GL_OES_compressed_paletted_texture", o(dummy_false), DISABLE },
- { "GL_OES_depth24", o(EXT_framebuffer_object), ES1 | ES2 },
- { "GL_OES_depth32", o(dummy_false), DISABLE },
- { "GL_OES_depth_texture", o(ARB_depth_texture), ES2 },
-#if FEATURE_OES_draw_texture
- { "GL_OES_draw_texture", o(OES_draw_texture), ES1 | ES2 },
-#endif
-#if FEATURE_OES_EGL_image
- /* FIXME: Mesa expects GL_OES_EGL_image to be available in OpenGL contexts. */
- { "GL_OES_EGL_image", o(OES_EGL_image), GL | ES1 | ES2 },
-#endif
- { "GL_OES_element_index_uint", o(EXT_vertex_array), ES1 | ES2 },
- { "GL_OES_fbo_render_mipmap", o(EXT_framebuffer_object), ES1 | ES2 },
- { "GL_OES_fixed_point", o(dummy_true), ES1 },
- { "GL_OES_framebuffer_object", o(EXT_framebuffer_object), ES1 },
- { "GL_OES_mapbuffer", o(ARB_vertex_buffer_object), ES1 | ES2 },
- { "GL_OES_matrix_get", o(dummy_true), ES1 },
- { "GL_OES_packed_depth_stencil", o(EXT_packed_depth_stencil), ES1 | ES2 },
- { "GL_OES_point_size_array", o(dummy_true), ES1 },
- { "GL_OES_point_sprite", o(ARB_point_sprite), ES1 },
- { "GL_OES_query_matrix", o(dummy_true), ES1 },
- { "GL_OES_read_format", o(OES_read_format), GL | ES1 },
- { "GL_OES_rgb8_rgba8", o(EXT_framebuffer_object), ES1 | ES2 },
- { "GL_OES_single_precision", o(dummy_true), ES1 },
- { "GL_OES_standard_derivatives", o(OES_standard_derivatives), ES2 },
- { "GL_OES_stencil1", o(dummy_false), DISABLE },
- { "GL_OES_stencil4", o(dummy_false), DISABLE },
- { "GL_OES_stencil8", o(EXT_framebuffer_object), ES1 | ES2 },
- { "GL_OES_stencil_wrap", o(EXT_stencil_wrap), ES1 },
- /* GL_OES_texture_3D is disabled due to missing GLSL support. */
- { "GL_OES_texture_3D", o(EXT_texture3D), DISABLE },
- { "GL_OES_texture_cube_map", o(ARB_texture_cube_map), ES1 },
- { "GL_OES_texture_env_crossbar", o(ARB_texture_env_crossbar), ES1 },
- { "GL_OES_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), ES1 },
- { "GL_OES_texture_npot", o(ARB_texture_non_power_of_two), ES2 },
-
- /* Vendor extensions */
- { "GL_3DFX_texture_compression_FXT1", o(TDFX_texture_compression_FXT1), GL },
- { "GL_AMD_conservative_depth", o(AMD_conservative_depth), GL },
- { "GL_APPLE_client_storage", o(APPLE_client_storage), GL },
- { "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), GL },
- { "GL_APPLE_packed_pixels", o(APPLE_packed_pixels), GL },
- { "GL_APPLE_vertex_array_object", o(APPLE_vertex_array_object), GL },
- { "GL_ATI_blend_equation_separate", o(EXT_blend_equation_separate), GL },
- { "GL_ATI_envmap_bumpmap", o(ATI_envmap_bumpmap), GL },
- { "GL_ATI_fragment_shader", o(ATI_fragment_shader), GL },
- { "GL_ATI_separate_stencil", o(ATI_separate_stencil), GL },
- { "GL_ATI_texture_env_combine3", o(ATI_texture_env_combine3), GL },
- { "GL_ATI_texture_mirror_once", o(ATI_texture_mirror_once), GL },
- { "GL_IBM_multimode_draw_arrays", o(IBM_multimode_draw_arrays), GL },
- { "GL_IBM_rasterpos_clip", o(IBM_rasterpos_clip), GL },
- { "GL_IBM_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), GL },
- { "GL_INGR_blend_func_separate", o(EXT_blend_func_separate), GL },
- { "GL_MESA_pack_invert", o(MESA_pack_invert), GL },
- { "GL_MESA_resize_buffers", o(MESA_resize_buffers), GL },
- { "GL_MESA_texture_array", o(MESA_texture_array), GL },
- { "GL_MESA_texture_signed_rgba", o(MESA_texture_signed_rgba), GL },
- { "GL_MESA_window_pos", o(ARB_window_pos), GL },
- { "GL_MESAX_texture_float", o(ARB_texture_float), GL },
- { "GL_MESA_ycbcr_texture", o(MESA_ycbcr_texture), GL },
- { "GL_NV_blend_square", o(NV_blend_square), GL },
- { "GL_NV_conditional_render", o(NV_conditional_render), GL },
- { "GL_NV_depth_clamp", o(ARB_depth_clamp), GL },
- { "GL_NV_fragment_program", o(NV_fragment_program), GL },
- { "GL_NV_fragment_program_option", o(NV_fragment_program_option), GL },
- { "GL_NV_light_max_exponent", o(NV_light_max_exponent), GL },
- { "GL_NV_packed_depth_stencil", o(EXT_packed_depth_stencil), GL },
- { "GL_NV_point_sprite", o(NV_point_sprite), GL },
- { "GL_NV_primitive_restart", o(NV_primitive_restart), GL },
- { "GL_NV_texgen_reflection", o(NV_texgen_reflection), GL },
- { "GL_NV_texture_env_combine4", o(NV_texture_env_combine4), GL },
- { "GL_NV_texture_rectangle", o(NV_texture_rectangle), GL },
- { "GL_NV_vertex_program1_1", o(NV_vertex_program1_1), GL },
- { "GL_NV_vertex_program", o(NV_vertex_program), GL },
- { "GL_S3_s3tc", o(S3_s3tc), GL },
- { "GL_SGIS_generate_mipmap", o(SGIS_generate_mipmap), GL },
- { "GL_SGIS_texture_border_clamp", o(ARB_texture_border_clamp), GL },
- { "GL_SGIS_texture_edge_clamp", o(SGIS_texture_edge_clamp), GL },
- { "GL_SGIS_texture_lod", o(SGIS_texture_lod), GL },
- { "GL_SGI_texture_color_table", o(SGI_texture_color_table), GL },
- { "GL_SUN_multi_draw_arrays", o(EXT_multi_draw_arrays), GL },
-
- { 0, 0, 0 },
-};
-
-
-/**
- * Given an extension name, lookup up the corresponding member of struct
- * gl_extensions and return that member's offset (in bytes). If the name is
- * not found in the \c extension_table, return 0.
- *
- * \param name Name of extension.
- * \return Offset of member in struct gl_extensions.
- */
-static size_t
-name_to_offset(const char* name)
-{
- const struct extension *i;
-
- if (name == 0)
- return 0;
-
- for (i = extension_table; i->name != 0; ++i) {
- if (strcmp(name, i->name) == 0)
- return i->offset;
- }
-
- return 0;
-}
-
-
-/**
- * \brief Extensions enabled by default.
- *
- * These extensions are enabled by _mesa_init_extensions().
- *
- * XXX: Should these defaults also apply to GLES?
- */
-static const size_t default_extensions[] = {
- o(ARB_copy_buffer),
- o(ARB_draw_buffers),
- o(ARB_multisample),
- o(ARB_texture_compression),
- o(ARB_transpose_matrix),
- o(ARB_vertex_buffer_object),
- o(ARB_window_pos),
-
- o(EXT_abgr),
- o(EXT_bgra),
- o(EXT_compiled_vertex_array),
- o(EXT_copy_texture),
- o(EXT_draw_range_elements),
- o(EXT_multi_draw_arrays),
- o(EXT_packed_pixels),
- o(EXT_polygon_offset),
- o(EXT_rescale_normal),
- o(EXT_separate_specular_color),
- o(EXT_subtexture),
- o(EXT_texture),
- o(EXT_texture3D),
- o(EXT_texture_object),
- o(EXT_vertex_array),
-
- o(OES_read_format),
- o(OES_standard_derivatives),
-
- /* Vendor Extensions */
- o(APPLE_packed_pixels),
- o(IBM_multimode_draw_arrays),
- o(IBM_rasterpos_clip),
- o(NV_light_max_exponent),
- o(NV_texgen_reflection),
- o(SGIS_generate_mipmap),
- o(SGIS_texture_edge_clamp),
- o(SGIS_texture_lod),
-
- 0,
-};
-
-
-/**
- * Enable all extensions suitable for a software-only renderer.
- * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.
- */
-void
-_mesa_enable_sw_extensions(struct gl_context *ctx)
-{
- /*ctx->Extensions.ARB_copy_buffer = GL_TRUE;*/
- ctx->Extensions.ARB_depth_clamp = GL_TRUE;
- ctx->Extensions.ARB_depth_texture = GL_TRUE;
- /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
- ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE;
- ctx->Extensions.ARB_draw_instanced = GL_TRUE;
- ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE;
- ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE;
-#if FEATURE_ARB_fragment_program
- ctx->Extensions.ARB_fragment_program = GL_TRUE;
- ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE;
-#endif
-#if FEATURE_ARB_fragment_shader
- ctx->Extensions.ARB_fragment_shader = GL_TRUE;
-#endif
-#if FEATURE_ARB_framebuffer_object
- ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
-#endif
-#if FEATURE_ARB_geometry_shader4 && 0
- /* XXX re-enable when GLSL compiler again supports geometry shaders */
- ctx->Extensions.ARB_geometry_shader4 = GL_TRUE;
-#endif
- ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
- ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
- ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
- ctx->Extensions.ARB_multitexture = GL_TRUE;
-#if FEATURE_queryobj
- ctx->Extensions.ARB_occlusion_query = GL_TRUE;
- ctx->Extensions.ARB_occlusion_query2 = GL_TRUE;
-#endif
- ctx->Extensions.ARB_point_sprite = GL_TRUE;
-#if FEATURE_ARB_shader_objects
- ctx->Extensions.ARB_shader_objects = GL_TRUE;
- ctx->Extensions.EXT_separate_shader_objects = GL_TRUE;
-#endif
-#if FEATURE_ARB_shading_language_100
- ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
-#endif
- ctx->Extensions.ARB_shadow = GL_TRUE;
- ctx->Extensions.ARB_shadow_ambient = GL_TRUE;
- ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
- ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
- ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
- ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
- ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
- /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
- ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
- ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
- ctx->Extensions.ARB_texture_rg = GL_TRUE;
- ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
-#if FEATURE_ARB_vertex_program
- ctx->Extensions.ARB_vertex_program = GL_TRUE;
-#endif
-#if FEATURE_ARB_vertex_shader
- ctx->Extensions.ARB_vertex_shader = GL_TRUE;
-#endif
-#if FEATURE_ARB_vertex_buffer_object
- /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
-#endif
-#if FEATURE_ARB_sync
- ctx->Extensions.ARB_sync = GL_TRUE;
-#endif
- ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
-#if FEATURE_APPLE_object_purgeable
- ctx->Extensions.APPLE_object_purgeable = GL_TRUE;
-#endif
- ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE;
-#if FEATURE_ATI_fragment_shader
- ctx->Extensions.ATI_fragment_shader = GL_TRUE;
-#endif
- ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
- ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
- ctx->Extensions.ATI_separate_stencil = GL_TRUE;
- ctx->Extensions.EXT_blend_color = GL_TRUE;
- ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
- ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
- ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
- ctx->Extensions.EXT_blend_minmax = GL_TRUE;
- ctx->Extensions.EXT_blend_subtract = GL_TRUE;
- ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
- ctx->Extensions.EXT_draw_buffers2 = GL_TRUE;
- ctx->Extensions.EXT_fog_coord = GL_TRUE;
-#if FEATURE_EXT_framebuffer_object
- ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
-#endif
-#if FEATURE_EXT_framebuffer_blit
- ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
-#endif
-#if FEATURE_ARB_framebuffer_object
- ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE;
-#endif
- /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
- ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
- ctx->Extensions.EXT_paletted_texture = GL_TRUE;
-#if FEATURE_EXT_pixel_buffer_object
- ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
-#endif
- ctx->Extensions.EXT_point_parameters = GL_TRUE;
- ctx->Extensions.EXT_provoking_vertex = GL_TRUE;
- ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
- ctx->Extensions.EXT_secondary_color = GL_TRUE;
- ctx->Extensions.EXT_shared_texture_palette = GL_TRUE;
- ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
- ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
- ctx->Extensions.EXT_texture_array = GL_TRUE;
- ctx->Extensions.EXT_texture_env_add = GL_TRUE;
- ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
- ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
- ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
- ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
-#if FEATURE_EXT_texture_sRGB
- ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
- ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE;
-#endif
- ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
-#if FEATURE_EXT_transform_feedback
- /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/
-#endif
- ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
- /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
- ctx->Extensions.MESA_pack_invert = GL_TRUE;
- ctx->Extensions.MESA_resize_buffers = GL_TRUE;
- ctx->Extensions.MESA_texture_array = GL_TRUE;
- ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
- ctx->Extensions.NV_blend_square = GL_TRUE;
- ctx->Extensions.NV_conditional_render = GL_TRUE;
- /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
- ctx->Extensions.NV_point_sprite = GL_TRUE;
- ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
- ctx->Extensions.NV_texture_rectangle = GL_TRUE;
- /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
-#if FEATURE_NV_vertex_program
- ctx->Extensions.NV_vertex_program = GL_TRUE;
- ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
-#endif
-#if FEATURE_NV_fragment_program
- ctx->Extensions.NV_fragment_program = GL_TRUE;
-#endif
-#if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program
- ctx->Extensions.NV_fragment_program_option = GL_TRUE;
-#endif
- ctx->Extensions.SGI_texture_color_table = GL_TRUE;
- /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/
- ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE;
-#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
- ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
-#endif
-#if FEATURE_texture_fxt1
- _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
-#endif
-#if FEATURE_texture_s3tc
- if (ctx->Mesa_DXTn) {
- _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
- _mesa_enable_extension(ctx, "GL_S3_s3tc");
- }
-#endif
-}
-
-
-/**
- * Enable common EXT extensions in the ARB_imaging subset.
- */
-void
-_mesa_enable_imaging_extensions(struct gl_context *ctx)
-{
- ctx->Extensions.EXT_blend_color = GL_TRUE;
- ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
- ctx->Extensions.EXT_blend_minmax = GL_TRUE;
- ctx->Extensions.EXT_blend_subtract = GL_TRUE;
-}
-
-
-
-/**
- * Enable all OpenGL 1.3 features and extensions.
- * A convenience function to be called by drivers.
- */
-void
-_mesa_enable_1_3_extensions(struct gl_context *ctx)
-{
- /*ctx->Extensions.ARB_multisample = GL_TRUE;*/
- ctx->Extensions.ARB_multitexture = GL_TRUE;
- ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
- /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/
- ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
- ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
- ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
- ctx->Extensions.EXT_texture_env_add = GL_TRUE;
- /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
-}
-
-
-
-/**
- * Enable all OpenGL 1.4 features and extensions.
- * A convenience function to be called by drivers.
- */
-void
-_mesa_enable_1_4_extensions(struct gl_context *ctx)
-{
- ctx->Extensions.ARB_depth_texture = GL_TRUE;
- ctx->Extensions.ARB_shadow = GL_TRUE;
- ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
- ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
- ctx->Extensions.ARB_window_pos = GL_TRUE;
- ctx->Extensions.EXT_blend_color = GL_TRUE;
- ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
- ctx->Extensions.EXT_blend_minmax = GL_TRUE;
- ctx->Extensions.EXT_blend_subtract = GL_TRUE;
- ctx->Extensions.EXT_fog_coord = GL_TRUE;
- /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
- ctx->Extensions.EXT_point_parameters = GL_TRUE;
- ctx->Extensions.EXT_secondary_color = GL_TRUE;
- ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
- ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
- /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/
-}
-
-
-/**
- * Enable all OpenGL 1.5 features and extensions.
- * A convenience function to be called by drivers.
- */
-void
-_mesa_enable_1_5_extensions(struct gl_context *ctx)
-{
- ctx->Extensions.ARB_occlusion_query = GL_TRUE;
- /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
- ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
-}
-
-
-/**
- * Enable all OpenGL 2.0 features and extensions.
- * A convenience function to be called by drivers.
- */
-void
-_mesa_enable_2_0_extensions(struct gl_context *ctx)
-{
- /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
-#if FEATURE_ARB_fragment_shader
- ctx->Extensions.ARB_fragment_shader = GL_TRUE;
-#endif
- ctx->Extensions.ARB_point_sprite = GL_TRUE;
- ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
- ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
-#if FEATURE_ARB_shader_objects
- ctx->Extensions.ARB_shader_objects = GL_TRUE;
-#endif
-#if FEATURE_ARB_shading_language_100
- ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
-#endif
- ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
-#if FEATURE_ARB_vertex_shader
- ctx->Extensions.ARB_vertex_shader = GL_TRUE;
-#endif
-}
-
-
-/**
- * Enable all OpenGL 2.1 features and extensions.
- * A convenience function to be called by drivers.
- */
-void
-_mesa_enable_2_1_extensions(struct gl_context *ctx)
-{
-#if FEATURE_EXT_pixel_buffer_object
- ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
-#endif
-#if FEATURE_EXT_texture_sRGB
- ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
-#endif
-}
-
-
-/**
- * Either enable or disable the named extension.
- * \return GL_TRUE for success, GL_FALSE if invalid extension name
- */
-static GLboolean
-set_extension( struct gl_context *ctx, const char *name, GLboolean state )
-{
- size_t offset;
-
- if (ctx->Extensions.String) {
- /* The string was already queried - can't change it now! */
- _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
- return GL_FALSE;
- }
-
- offset = name_to_offset(name);
- if (offset == 0) {
- _mesa_problem(ctx, "Trying to enable/disable unknown extension %s",
- name);
- return GL_FALSE;
- } else if (offset == o(dummy_true) && state == GL_FALSE) {
- _mesa_problem(ctx, "Trying to disable a permanently enabled extension: "
- "%s", name);
- return GL_FALSE;
- } else {
- GLboolean *base = (GLboolean *) &ctx->Extensions;
- base[offset] = state;
- return GL_TRUE;
- }
-}
-
-
-/**
- * Enable the named extension.
- * Typically called by drivers.
- */
-void
-_mesa_enable_extension( struct gl_context *ctx, const char *name )
-{
- if (!set_extension(ctx, name, GL_TRUE))
- _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
-}
-
-
-/**
- * Disable the named extension.
- * XXX is this really needed???
- */
-void
-_mesa_disable_extension( struct gl_context *ctx, const char *name )
-{
- if (!set_extension(ctx, name, GL_FALSE))
- _mesa_problem(ctx, "Trying to disable unknown extension: %s", name);
-}
-
-
-/**
- * Test if the named extension is enabled in this context.
- */
-GLboolean
-_mesa_extension_is_enabled( struct gl_context *ctx, const char *name )
-{
- size_t offset;
- GLboolean *base;
-
- if (name == 0)
- return GL_FALSE;
-
- offset = name_to_offset(name);
- if (offset == 0)
- return GL_FALSE;
- base = (GLboolean *) &ctx->Extensions;
- return base[offset];
-}
-
-
-/**
- * \brief Apply the \c MESA_EXTENSION_OVERRIDE environment variable.
- *
- * \c MESA_EXTENSION_OVERRIDE is a space-separated list of extensions to
- * enable or disable. The list is processed thus:
- * - Enable recognized extension names that are prefixed with '+'.
- * - Disable recognized extension names that are prefixed with '-'.
- * - Enable recognized extension names that are not prefixed.
- * - Collect unrecognized extension names in a new string.
- *
- * \return Space-separated list of unrecognized extension names (which must
- * be freed). Does not return \c NULL.
- */
-static char *
-get_extension_override( struct gl_context *ctx )
-{
- const char *env_const= _mesa_getenv("MESA_EXTENSION_OVERRIDE");
- char *env;
- char *ext;
- char *extra_exts;
- int len;
-
- if (env_const == NULL) {
- /* Return the empty string rather than NULL. This simplifies the logic
- * of client functions. */
- return calloc(1, sizeof(char));
- }
-
- /* extra_exts: List of unrecognized extensions. */
- extra_exts = calloc(strlen(env_const), sizeof(char));
-
- /* Copy env_const because strtok() is destructive. */
- env = strdup(env_const);
- for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) {
- int enable;
- int recognized;
- switch (ext[0]) {
- case '+':
- enable = 1;
- ++ext;
- break;
- case '-':
- enable = 0;
- ++ext;
- break;
- default:
- enable = 1;
- break;
- }
- recognized = set_extension(ctx, ext, enable);
- if (!recognized) {
- strcat(extra_exts, ext);
- strcat(extra_exts, " ");
- }
- }
-
- /* Remove trailing space. */
- len = strlen(extra_exts);
- if (extra_exts[len - 1] == ' ')
- extra_exts[len - 1] = '\0';
-
- return extra_exts;
-}
-
-
-/**
- * \brief Initialize extension tables and enable default extensions.
- *
- * This should be called during context initialization.
- * Note: Sets gl_extensions.dummy_true to true.
- */
-void
-_mesa_init_extensions( struct gl_context *ctx )
-{
- GLboolean *base = (GLboolean *) &ctx->Extensions;
- GLboolean *sentinel = base + o(extension_sentinel);
- GLboolean *i;
- const size_t *j;
-
- /* First, turn all extensions off. */
- for (i = base; i != sentinel; ++i)
- *i = GL_FALSE;
-
- /* Then, selectively turn default extensions on. */
- ctx->Extensions.dummy_true = GL_TRUE;
- for (j = default_extensions; *j != 0; ++j)
- base[*j] = GL_TRUE;
-}
-
-
-/**
- * Construct the GL_EXTENSIONS string. Called the first time that
- * glGetString(GL_EXTENSIONS) is called.
- */
-GLubyte*
-_mesa_make_extension_string(struct gl_context *ctx)
-{
- /* The extension string. */
- char *exts = 0;
- /* Length of extension string. */
- size_t length = 0;
- /* String of extra extensions. */
- char *extra_extensions = get_extension_override(ctx);
- GLboolean *base = (GLboolean *) &ctx->Extensions;
- const struct extension *i;
-
- /* Compute length of the extension string. */
- for (i = extension_table; i->name != 0; ++i) {
- if (base[i->offset] && (i->api_set & (1 << ctx->API))) {
- length += strlen(i->name) + 1; /* +1 for space */
- }
- }
- if (extra_extensions != NULL)
- length += 1 + strlen(extra_extensions); /* +1 for space */
-
- exts = (char *) calloc(length + 1, sizeof(char));
- if (exts == NULL) {
- free(extra_extensions);
- return NULL;
- }
-
- /* Build the extension string.*/
- for (i = extension_table; i->name != 0; ++i) {
- if (base[i->offset] && (i->api_set & (1 << ctx->API))) {
- strcat(exts, i->name);
- strcat(exts, " ");
- }
- }
- if (extra_extensions != 0) {
- strcat(exts, extra_extensions);
- free(extra_extensions);
- }
-
- return (GLubyte *) exts;
-}
-
-/**
- * Return number of enabled extensions.
- */
-GLuint
-_mesa_get_extension_count(struct gl_context *ctx)
-{
- GLboolean *base;
- const struct extension *i;
-
- /* only count once */
- if (ctx->Extensions.Count != 0)
- return ctx->Extensions.Count;
-
- base = (GLboolean *) &ctx->Extensions;
- for (i = extension_table; i->name != 0; ++i) {
- if (base[i->offset]) {
- ctx->Extensions.Count++;
- }
- }
- return ctx->Extensions.Count;
-}
-
-/**
- * Return name of i-th enabled extension
- */
-const GLubyte *
-_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index)
-{
- const GLboolean *base;
- size_t n;
- const struct extension *i;
-
- if (index < 0)
- return NULL;
-
- base = (GLboolean*) &ctx->Extensions;
- n = 0;
- for (i = extension_table; i->name != 0; ++i) {
- if (n == index && base[i->offset]) {
- return (GLubyte*) i->name;
- } else if (base[i->offset]) {
- ++n;
- }
- }
-
- return NULL;
-}
+/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * 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 + * BRIAN PAUL 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. + */ + + +/** + * \file + * \brief Extension handling + */ + + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "extensions.h" +#include "mfeatures.h" +#include "mtypes.h" + +enum { + DISABLE = 0, + GL = 1 << API_OPENGL, + ES1 = 1 << API_OPENGLES, + ES2 = 1 << API_OPENGLES2, +}; + +/** + * \brief An element of the \c extension_table. + */ +struct extension { + /** Name of extension, such as "GL_ARB_depth_clamp". */ + const char *name; + + /** Offset (in bytes) of the corresponding member in struct gl_extensions. */ + size_t offset; + + /** Set of API's in which the extension exists, as a bitset. */ + uint8_t api_set; +}; + + +/** + * Given a member \c x of struct gl_extensions, return offset of + * \c x in bytes. + */ +#define o(x) offsetof(struct gl_extensions, x) + + +/** + * \brief Table of supported OpenGL extensions for all API's. + * + * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions. + */ +static const struct extension extension_table[] = { + /* ARB Extensions */ + { "GL_ARB_ES2_compatibility", o(ARB_ES2_compatibility), GL }, + { "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), GL }, + { "GL_ARB_copy_buffer", o(ARB_copy_buffer), GL }, + { "GL_ARB_depth_buffer_float", o(ARB_depth_buffer_float), GL }, + { "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL }, + { "GL_ARB_depth_texture", o(ARB_depth_texture), GL }, + { "GL_ARB_draw_buffers", o(ARB_draw_buffers), GL }, + { "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL }, + { "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL }, + { "GL_ARB_draw_instanced", o(ARB_draw_instanced), GL }, + { "GL_ARB_explicit_attrib_location", o(ARB_explicit_attrib_location), GL }, + { "GL_ARB_fragment_coord_conventions", o(ARB_fragment_coord_conventions), GL }, + { "GL_ARB_fragment_program", o(ARB_fragment_program), GL }, + { "GL_ARB_fragment_program_shadow", o(ARB_fragment_program_shadow), GL }, + { "GL_ARB_fragment_shader", o(ARB_fragment_shader), GL }, + { "GL_ARB_framebuffer_object", o(ARB_framebuffer_object), GL }, + { "GL_ARB_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL }, + { "GL_ARB_half_float_pixel", o(ARB_half_float_pixel), GL }, + { "GL_ARB_half_float_vertex", o(ARB_half_float_vertex), GL }, + { "GL_ARB_instanced_arrays", o(ARB_instanced_arrays), GL }, + { "GL_ARB_map_buffer_range", o(ARB_map_buffer_range), GL }, + { "GL_ARB_multisample", o(ARB_multisample), GL }, + { "GL_ARB_multitexture", o(ARB_multitexture), GL }, + { "GL_ARB_occlusion_query2", o(ARB_occlusion_query2), GL }, + { "GL_ARB_occlusion_query", o(ARB_occlusion_query), GL }, + { "GL_ARB_pixel_buffer_object", o(EXT_pixel_buffer_object), GL }, + { "GL_ARB_point_parameters", o(EXT_point_parameters), GL }, + { "GL_ARB_point_sprite", o(ARB_point_sprite), GL }, + { "GL_ARB_provoking_vertex", o(EXT_provoking_vertex), GL }, + { "GL_ARB_sampler_objects", o(ARB_sampler_objects), GL }, + { "GL_ARB_seamless_cube_map", o(ARB_seamless_cube_map), GL }, + { "GL_ARB_shader_objects", o(ARB_shader_objects), GL }, + { "GL_ARB_shader_stencil_export", o(ARB_shader_stencil_export), GL }, + { "GL_ARB_shading_language_100", o(ARB_shading_language_100), GL }, + { "GL_ARB_shadow_ambient", o(ARB_shadow_ambient), GL }, + { "GL_ARB_shadow", o(ARB_shadow), GL }, + { "GL_ARB_sync", o(ARB_sync), GL }, + { "GL_ARB_texture_border_clamp", o(ARB_texture_border_clamp), GL }, + { "GL_ARB_texture_buffer_object", o(ARB_texture_buffer_object), GL }, + { "GL_ARB_texture_compression", o(ARB_texture_compression), GL }, + { "GL_ARB_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL }, + { "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), GL }, + { "GL_ARB_texture_env_add", o(EXT_texture_env_add), GL }, + { "GL_ARB_texture_env_combine", o(ARB_texture_env_combine), GL }, + { "GL_ARB_texture_env_crossbar", o(ARB_texture_env_crossbar), GL }, + { "GL_ARB_texture_env_dot3", o(ARB_texture_env_dot3), GL }, + { "GL_ARB_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), GL }, + { "GL_ARB_texture_multisample", o(ARB_texture_multisample), GL }, + { "GL_ARB_texture_non_power_of_two", o(ARB_texture_non_power_of_two), GL }, + { "GL_ARB_texture_rectangle", o(NV_texture_rectangle), GL }, + { "GL_ARB_texture_rgb10_a2ui", o(ARB_texture_rgb10_a2ui), GL }, + { "GL_ARB_texture_rg", o(ARB_texture_rg), GL }, + { "GL_ARB_texture_swizzle", o(EXT_texture_swizzle), GL }, + { "GL_ARB_transform_feedback2", o(ARB_transform_feedback2), GL }, + { "GL_ARB_transpose_matrix", o(ARB_transpose_matrix), GL }, + { "GL_ARB_uniform_buffer_object", o(ARB_uniform_buffer_object), GL }, + { "GL_ARB_vertex_array_bgra", o(EXT_vertex_array_bgra), GL }, + { "GL_ARB_vertex_array_object", o(ARB_vertex_array_object), GL }, + { "GL_ARB_vertex_buffer_object", o(ARB_vertex_buffer_object), GL }, + { "GL_ARB_vertex_program", o(ARB_vertex_program), GL }, + { "GL_ARB_vertex_shader", o(ARB_vertex_shader), GL }, + { "GL_ARB_vertex_type_2_10_10_10_rev", o(ARB_vertex_type_2_10_10_10_rev), GL }, + { "GL_ARB_window_pos", o(ARB_window_pos), GL }, + + /* EXT extensions */ + { "GL_EXT_abgr", o(EXT_abgr), GL }, + { "GL_EXT_bgra", o(EXT_bgra), GL }, + { "GL_EXT_blend_color", o(EXT_blend_color), GL }, + { "GL_EXT_blend_equation_separate", o(EXT_blend_equation_separate), GL }, + { "GL_EXT_blend_func_separate", o(EXT_blend_func_separate), GL }, + { "GL_EXT_blend_logic_op", o(EXT_blend_logic_op), GL }, + { "GL_EXT_blend_minmax", o(EXT_blend_minmax), GL | ES1 | ES2 }, + { "GL_EXT_blend_subtract", o(EXT_blend_subtract), GL }, + { "GL_EXT_clip_volume_hint", o(EXT_clip_volume_hint), GL }, + { "GL_EXT_compiled_vertex_array", o(EXT_compiled_vertex_array), GL }, + { "GL_EXT_copy_texture", o(EXT_copy_texture), GL }, + { "GL_EXT_depth_bounds_test", o(EXT_depth_bounds_test), GL }, + { "GL_EXT_draw_buffers2", o(EXT_draw_buffers2), GL }, + { "GL_EXT_draw_instanced", o(ARB_draw_instanced), GL }, + { "GL_EXT_draw_range_elements", o(EXT_draw_range_elements), GL }, + { "GL_EXT_fog_coord", o(EXT_fog_coord), GL }, + { "GL_EXT_framebuffer_blit", o(EXT_framebuffer_blit), GL }, + { "GL_EXT_framebuffer_multisample", o(EXT_framebuffer_multisample), GL }, + { "GL_EXT_framebuffer_object", o(EXT_framebuffer_object), GL }, + { "GL_EXT_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL }, + { "GL_EXT_gpu_program_parameters", o(EXT_gpu_program_parameters), GL }, + { "GL_EXT_gpu_shader4", o(EXT_gpu_shader4), GL }, + { "GL_EXT_multi_draw_arrays", o(EXT_multi_draw_arrays), GL | ES1 | ES2 }, + { "GL_EXT_packed_depth_stencil", o(EXT_packed_depth_stencil), GL }, + { "GL_EXT_packed_float", o(EXT_packed_float), GL }, + { "GL_EXT_packed_pixels", o(EXT_packed_pixels), GL }, + { "GL_EXT_paletted_texture", o(EXT_paletted_texture), GL }, + { "GL_EXT_pixel_buffer_object", o(EXT_pixel_buffer_object), GL }, + { "GL_EXT_point_parameters", o(EXT_point_parameters), GL }, + { "GL_EXT_polygon_offset", o(EXT_polygon_offset), GL }, + { "GL_EXT_provoking_vertex", o(EXT_provoking_vertex), GL }, + { "GL_EXT_rescale_normal", o(EXT_rescale_normal), GL }, + { "GL_EXT_secondary_color", o(EXT_secondary_color), GL }, + { "GL_EXT_separate_shader_objects", o(EXT_separate_shader_objects), GL }, + { "GL_EXT_separate_specular_color", o(EXT_separate_specular_color), GL }, + { "GL_EXT_shadow_funcs", o(EXT_shadow_funcs), GL }, + { "GL_EXT_shared_texture_palette", o(EXT_shared_texture_palette), GL }, + { "GL_EXT_stencil_two_side", o(EXT_stencil_two_side), GL }, + { "GL_EXT_stencil_wrap", o(EXT_stencil_wrap), GL }, + { "GL_EXT_subtexture", o(EXT_subtexture), GL }, + { "GL_EXT_texture3D", o(EXT_texture3D), GL }, + { "GL_EXT_texture_array", o(EXT_texture_array), GL }, + { "GL_EXT_texture_compression_dxt1", o(EXT_texture_compression_s3tc), GL | ES1 | ES2 }, + { "GL_EXT_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL }, + { "GL_EXT_texture_compression_s3tc", o(EXT_texture_compression_s3tc), GL }, + { "GL_EXT_texture_cube_map", o(ARB_texture_cube_map), GL }, + { "GL_EXT_texture_edge_clamp", o(SGIS_texture_edge_clamp), GL }, + { "GL_EXT_texture_env_add", o(EXT_texture_env_add), GL }, + { "GL_EXT_texture_env_combine", o(EXT_texture_env_combine), GL }, + { "GL_EXT_texture_env_dot3", o(EXT_texture_env_dot3), GL }, + { "GL_EXT_texture_filter_anisotropic", o(EXT_texture_filter_anisotropic), GL | ES1 | ES2 }, + { "GL_EXT_texture_format_BGRA8888", o(EXT_texture_format_BGRA8888), ES1 | ES2 }, + { "GL_EXT_texture_integer", o(EXT_texture_integer), GL }, + { "GL_EXT_texture_lod_bias", o(EXT_texture_lod_bias), GL | ES1 }, + { "GL_EXT_texture_mirror_clamp", o(EXT_texture_mirror_clamp), GL }, + { "GL_EXT_texture_object", o(EXT_texture_object), GL }, + { "GL_EXT_texture", o(EXT_texture), GL }, + { "GL_EXT_texture_rectangle", o(NV_texture_rectangle), GL }, + { "GL_EXT_texture_shared_exponent", o(EXT_texture_shared_exponent), GL }, + { "GL_EXT_texture_sRGB", o(EXT_texture_sRGB), GL }, + { "GL_EXT_texture_sRGB_decode", o(EXT_texture_sRGB_decode), GL }, + { "GL_EXT_texture_swizzle", o(EXT_texture_swizzle), GL }, + { "GL_EXT_texture_type_2_10_10_10_REV", o(dummy_true), ES2 }, + { "GL_EXT_timer_query", o(EXT_timer_query), GL }, + { "GL_EXT_transform_feedback", o(EXT_transform_feedback), GL }, + { "GL_EXT_vertex_array_bgra", o(EXT_vertex_array_bgra), GL }, + { "GL_EXT_vertex_array", o(EXT_vertex_array), GL }, + { "GL_EXT_vertex_array_set", o(EXT_vertex_array_set), GL }, + + /* OES extensions */ + { "GL_OES_blend_equation_separate", o(EXT_blend_equation_separate), ES1 }, + { "GL_OES_blend_func_separate", o(EXT_blend_func_separate), ES1 }, + { "GL_OES_blend_subtract", o(EXT_blend_subtract), ES1 }, + { "GL_OES_byte_coordinates", o(dummy_true), ES1 }, + { "GL_OES_compressed_paletted_texture", o(dummy_false), DISABLE }, + { "GL_OES_depth24", o(EXT_framebuffer_object), ES1 | ES2 }, + { "GL_OES_depth32", o(dummy_false), DISABLE }, + { "GL_OES_depth_texture", o(ARB_depth_texture), ES2 }, +#if FEATURE_OES_draw_texture + { "GL_OES_draw_texture", o(OES_draw_texture), ES1 | ES2 }, +#endif +#if FEATURE_OES_EGL_image + /* FIXME: Mesa expects GL_OES_EGL_image to be available in OpenGL contexts. */ + { "GL_OES_EGL_image", o(OES_EGL_image), GL | ES1 | ES2 }, +#endif + { "GL_OES_element_index_uint", o(EXT_vertex_array), ES1 | ES2 }, + { "GL_OES_fbo_render_mipmap", o(EXT_framebuffer_object), ES1 | ES2 }, + { "GL_OES_fixed_point", o(dummy_true), ES1 }, + { "GL_OES_framebuffer_object", o(EXT_framebuffer_object), ES1 }, + { "GL_OES_mapbuffer", o(ARB_vertex_buffer_object), ES1 | ES2 }, + { "GL_OES_matrix_get", o(dummy_true), ES1 }, + { "GL_OES_packed_depth_stencil", o(EXT_packed_depth_stencil), ES1 | ES2 }, + { "GL_OES_point_size_array", o(dummy_true), ES1 }, + { "GL_OES_point_sprite", o(ARB_point_sprite), ES1 }, + { "GL_OES_query_matrix", o(dummy_true), ES1 }, + { "GL_OES_read_format", o(OES_read_format), GL | ES1 }, + { "GL_OES_rgb8_rgba8", o(EXT_framebuffer_object), ES1 | ES2 }, + { "GL_OES_single_precision", o(dummy_true), ES1 }, + { "GL_OES_standard_derivatives", o(OES_standard_derivatives), ES2 }, + { "GL_OES_stencil1", o(dummy_false), DISABLE }, + { "GL_OES_stencil4", o(dummy_false), DISABLE }, + { "GL_OES_stencil8", o(EXT_framebuffer_object), ES1 | ES2 }, + { "GL_OES_stencil_wrap", o(EXT_stencil_wrap), ES1 }, + /* GL_OES_texture_3D is disabled due to missing GLSL support. */ + { "GL_OES_texture_3D", o(EXT_texture3D), DISABLE }, + { "GL_OES_texture_cube_map", o(ARB_texture_cube_map), ES1 }, + { "GL_OES_texture_env_crossbar", o(ARB_texture_env_crossbar), ES1 }, + { "GL_OES_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), ES1 }, + { "GL_OES_texture_npot", o(ARB_texture_non_power_of_two), ES2 }, + + /* Vendor extensions */ + { "GL_3DFX_texture_compression_FXT1", o(TDFX_texture_compression_FXT1), GL }, + { "GL_AMD_conservative_depth", o(AMD_conservative_depth), GL }, + { "GL_APPLE_client_storage", o(APPLE_client_storage), GL }, + { "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), GL }, + { "GL_APPLE_packed_pixels", o(APPLE_packed_pixels), GL }, + { "GL_APPLE_vertex_array_object", o(APPLE_vertex_array_object), GL }, + { "GL_ATI_blend_equation_separate", o(EXT_blend_equation_separate), GL }, + { "GL_ATI_envmap_bumpmap", o(ATI_envmap_bumpmap), GL }, + { "GL_ATI_fragment_shader", o(ATI_fragment_shader), GL }, + { "GL_ATI_separate_stencil", o(ATI_separate_stencil), GL }, + { "GL_ATI_texture_env_combine3", o(ATI_texture_env_combine3), GL }, + { "GL_ATI_texture_mirror_once", o(ATI_texture_mirror_once), GL }, + { "GL_IBM_multimode_draw_arrays", o(IBM_multimode_draw_arrays), GL }, + { "GL_IBM_rasterpos_clip", o(IBM_rasterpos_clip), GL }, + { "GL_IBM_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), GL }, + { "GL_INGR_blend_func_separate", o(EXT_blend_func_separate), GL }, + { "GL_MESA_pack_invert", o(MESA_pack_invert), GL }, + { "GL_MESA_resize_buffers", o(MESA_resize_buffers), GL }, + { "GL_MESA_texture_array", o(MESA_texture_array), GL }, + { "GL_MESA_texture_signed_rgba", o(MESA_texture_signed_rgba), GL }, + { "GL_MESA_window_pos", o(ARB_window_pos), GL }, + { "GL_MESAX_texture_float", o(ARB_texture_float), GL }, + { "GL_MESA_ycbcr_texture", o(MESA_ycbcr_texture), GL }, + { "GL_NV_blend_square", o(NV_blend_square), GL }, + { "GL_NV_conditional_render", o(NV_conditional_render), GL }, + { "GL_NV_depth_clamp", o(ARB_depth_clamp), GL }, + { "GL_NV_fragment_program", o(NV_fragment_program), GL }, + { "GL_NV_fragment_program_option", o(NV_fragment_program_option), GL }, + { "GL_NV_light_max_exponent", o(NV_light_max_exponent), GL }, + { "GL_NV_packed_depth_stencil", o(EXT_packed_depth_stencil), GL }, + { "GL_NV_point_sprite", o(NV_point_sprite), GL }, + { "GL_NV_primitive_restart", o(NV_primitive_restart), GL }, + { "GL_NV_texgen_reflection", o(NV_texgen_reflection), GL }, + { "GL_NV_texture_env_combine4", o(NV_texture_env_combine4), GL }, + { "GL_NV_texture_rectangle", o(NV_texture_rectangle), GL }, + { "GL_NV_vertex_program1_1", o(NV_vertex_program1_1), GL }, + { "GL_NV_vertex_program", o(NV_vertex_program), GL }, + { "GL_S3_s3tc", o(S3_s3tc), GL }, + { "GL_SGIS_generate_mipmap", o(SGIS_generate_mipmap), GL }, + { "GL_SGIS_texture_border_clamp", o(ARB_texture_border_clamp), GL }, + { "GL_SGIS_texture_edge_clamp", o(SGIS_texture_edge_clamp), GL }, + { "GL_SGIS_texture_lod", o(SGIS_texture_lod), GL }, + { "GL_SGI_texture_color_table", o(SGI_texture_color_table), GL }, + { "GL_SUN_multi_draw_arrays", o(EXT_multi_draw_arrays), GL }, + + { 0, 0, 0 }, +}; + + +/** + * Given an extension name, lookup up the corresponding member of struct + * gl_extensions and return that member's offset (in bytes). If the name is + * not found in the \c extension_table, return 0. + * + * \param name Name of extension. + * \return Offset of member in struct gl_extensions. + */ +static size_t +name_to_offset(const char* name) +{ + const struct extension *i; + + if (name == 0) + return 0; + + for (i = extension_table; i->name != 0; ++i) { + if (strcmp(name, i->name) == 0) + return i->offset; + } + + return 0; +} + + +/** + * \brief Extensions enabled by default. + * + * These extensions are enabled by _mesa_init_extensions(). + * + * XXX: Should these defaults also apply to GLES? + */ +static const size_t default_extensions[] = { + o(ARB_copy_buffer), + o(ARB_draw_buffers), + o(ARB_multisample), + o(ARB_texture_compression), + o(ARB_transpose_matrix), + o(ARB_vertex_buffer_object), + o(ARB_window_pos), + + o(EXT_abgr), + o(EXT_bgra), + o(EXT_compiled_vertex_array), + o(EXT_copy_texture), + o(EXT_draw_range_elements), + o(EXT_multi_draw_arrays), + o(EXT_packed_pixels), + o(EXT_polygon_offset), + o(EXT_rescale_normal), + o(EXT_separate_specular_color), + o(EXT_subtexture), + o(EXT_texture), + o(EXT_texture3D), + o(EXT_texture_object), + o(EXT_vertex_array), + + o(OES_read_format), + o(OES_standard_derivatives), + + /* Vendor Extensions */ + o(APPLE_packed_pixels), + o(IBM_multimode_draw_arrays), + o(IBM_rasterpos_clip), + o(NV_light_max_exponent), + o(NV_texgen_reflection), + o(SGIS_generate_mipmap), + o(SGIS_texture_edge_clamp), + o(SGIS_texture_lod), + + 0, +}; + + +/** + * Enable all extensions suitable for a software-only renderer. + * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc. + */ +void +_mesa_enable_sw_extensions(struct gl_context *ctx) +{ + /*ctx->Extensions.ARB_copy_buffer = GL_TRUE;*/ + ctx->Extensions.ARB_depth_clamp = GL_TRUE; + ctx->Extensions.ARB_depth_texture = GL_TRUE; + /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ + ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE; + ctx->Extensions.ARB_draw_instanced = GL_TRUE; + ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE; + ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; +#if FEATURE_ARB_fragment_program + ctx->Extensions.ARB_fragment_program = GL_TRUE; + ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; +#endif +#if FEATURE_ARB_fragment_shader + ctx->Extensions.ARB_fragment_shader = GL_TRUE; +#endif +#if FEATURE_ARB_framebuffer_object + ctx->Extensions.ARB_framebuffer_object = GL_TRUE; +#endif +#if FEATURE_ARB_geometry_shader4 && 0 + /* XXX re-enable when GLSL compiler again supports geometry shaders */ + ctx->Extensions.ARB_geometry_shader4 = GL_TRUE; +#endif + ctx->Extensions.ARB_half_float_pixel = GL_TRUE; + ctx->Extensions.ARB_half_float_vertex = GL_TRUE; + ctx->Extensions.ARB_map_buffer_range = GL_TRUE; + ctx->Extensions.ARB_multitexture = GL_TRUE; +#if FEATURE_queryobj + ctx->Extensions.ARB_occlusion_query = GL_TRUE; + ctx->Extensions.ARB_occlusion_query2 = GL_TRUE; +#endif + ctx->Extensions.ARB_point_sprite = GL_TRUE; +#if FEATURE_ARB_shader_objects + ctx->Extensions.ARB_shader_objects = GL_TRUE; + ctx->Extensions.EXT_separate_shader_objects = GL_TRUE; +#endif +#if FEATURE_ARB_shading_language_100 + ctx->Extensions.ARB_shading_language_100 = GL_TRUE; +#endif + ctx->Extensions.ARB_shadow = GL_TRUE; + ctx->Extensions.ARB_shadow_ambient = GL_TRUE; + ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; + ctx->Extensions.ARB_texture_cube_map = GL_TRUE; + ctx->Extensions.ARB_texture_env_combine = GL_TRUE; + ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; + ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; + /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/ + ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; + ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; + ctx->Extensions.ARB_texture_rg = GL_TRUE; + ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE; + ctx->Extensions.ARB_vertex_array_object = GL_TRUE; +#if FEATURE_ARB_vertex_program + ctx->Extensions.ARB_vertex_program = GL_TRUE; +#endif +#if FEATURE_ARB_vertex_shader + ctx->Extensions.ARB_vertex_shader = GL_TRUE; +#endif +#if FEATURE_ARB_vertex_buffer_object + /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ +#endif +#if FEATURE_ARB_sync + ctx->Extensions.ARB_sync = GL_TRUE; +#endif + ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; +#if FEATURE_APPLE_object_purgeable + ctx->Extensions.APPLE_object_purgeable = GL_TRUE; +#endif + ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE; +#if FEATURE_ATI_fragment_shader + ctx->Extensions.ATI_fragment_shader = GL_TRUE; +#endif + ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; + ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; + ctx->Extensions.ATI_separate_stencil = GL_TRUE; + ctx->Extensions.EXT_blend_color = GL_TRUE; + ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; + ctx->Extensions.EXT_blend_func_separate = GL_TRUE; + ctx->Extensions.EXT_blend_logic_op = GL_TRUE; + ctx->Extensions.EXT_blend_minmax = GL_TRUE; + ctx->Extensions.EXT_blend_subtract = GL_TRUE; + ctx->Extensions.EXT_depth_bounds_test = GL_TRUE; + ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; + ctx->Extensions.EXT_fog_coord = GL_TRUE; +#if FEATURE_EXT_framebuffer_object + ctx->Extensions.EXT_framebuffer_object = GL_TRUE; +#endif +#if FEATURE_EXT_framebuffer_blit + ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; +#endif +#if FEATURE_ARB_framebuffer_object + ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; +#endif + /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ + ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; + ctx->Extensions.EXT_paletted_texture = GL_TRUE; +#if FEATURE_EXT_pixel_buffer_object + ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; +#endif + ctx->Extensions.EXT_point_parameters = GL_TRUE; + ctx->Extensions.EXT_provoking_vertex = GL_TRUE; + ctx->Extensions.EXT_shadow_funcs = GL_TRUE; + ctx->Extensions.EXT_secondary_color = GL_TRUE; + ctx->Extensions.EXT_shared_texture_palette = GL_TRUE; + ctx->Extensions.EXT_stencil_wrap = GL_TRUE; + ctx->Extensions.EXT_stencil_two_side = GL_TRUE; + ctx->Extensions.EXT_texture_array = GL_TRUE; + ctx->Extensions.EXT_texture_env_add = GL_TRUE; + ctx->Extensions.EXT_texture_env_combine = GL_TRUE; + ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; + ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE; + ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; +#if FEATURE_EXT_texture_sRGB + ctx->Extensions.EXT_texture_sRGB = GL_TRUE; + ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE; +#endif + ctx->Extensions.EXT_texture_swizzle = GL_TRUE; +#if FEATURE_EXT_transform_feedback + /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/ +#endif + ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; + /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/ + ctx->Extensions.MESA_pack_invert = GL_TRUE; + ctx->Extensions.MESA_resize_buffers = GL_TRUE; + ctx->Extensions.MESA_texture_array = GL_TRUE; + ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; + ctx->Extensions.NV_blend_square = GL_TRUE; + ctx->Extensions.NV_conditional_render = GL_TRUE; + /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/ + ctx->Extensions.NV_point_sprite = GL_TRUE; + ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; + ctx->Extensions.NV_texture_rectangle = GL_TRUE; + /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/ +#if FEATURE_NV_vertex_program + ctx->Extensions.NV_vertex_program = GL_TRUE; + ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; +#endif +#if FEATURE_NV_fragment_program + ctx->Extensions.NV_fragment_program = GL_TRUE; +#endif +#if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program + ctx->Extensions.NV_fragment_program_option = GL_TRUE; +#endif + ctx->Extensions.SGI_texture_color_table = GL_TRUE; + /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/ + ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE; +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; +#endif +#if FEATURE_texture_fxt1 + _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1"); +#endif +#if FEATURE_texture_s3tc + if (ctx->Mesa_DXTn) { + _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); + _mesa_enable_extension(ctx, "GL_S3_s3tc"); + } +#endif +} + + +/** + * Enable common EXT extensions in the ARB_imaging subset. + */ +void +_mesa_enable_imaging_extensions(struct gl_context *ctx) +{ + ctx->Extensions.EXT_blend_color = GL_TRUE; + ctx->Extensions.EXT_blend_logic_op = GL_TRUE; + ctx->Extensions.EXT_blend_minmax = GL_TRUE; + ctx->Extensions.EXT_blend_subtract = GL_TRUE; +} + + + +/** + * Enable all OpenGL 1.3 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_1_3_extensions(struct gl_context *ctx) +{ + /*ctx->Extensions.ARB_multisample = GL_TRUE;*/ + ctx->Extensions.ARB_multitexture = GL_TRUE; + ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; + /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/ + ctx->Extensions.ARB_texture_cube_map = GL_TRUE; + ctx->Extensions.ARB_texture_env_combine = GL_TRUE; + ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; + ctx->Extensions.EXT_texture_env_add = GL_TRUE; + /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/ +} + + + +/** + * Enable all OpenGL 1.4 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_1_4_extensions(struct gl_context *ctx) +{ + ctx->Extensions.ARB_depth_texture = GL_TRUE; + ctx->Extensions.ARB_shadow = GL_TRUE; + ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; + ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; + ctx->Extensions.ARB_window_pos = GL_TRUE; + ctx->Extensions.EXT_blend_color = GL_TRUE; + ctx->Extensions.EXT_blend_func_separate = GL_TRUE; + ctx->Extensions.EXT_blend_minmax = GL_TRUE; + ctx->Extensions.EXT_blend_subtract = GL_TRUE; + ctx->Extensions.EXT_fog_coord = GL_TRUE; + /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ + ctx->Extensions.EXT_point_parameters = GL_TRUE; + ctx->Extensions.EXT_secondary_color = GL_TRUE; + ctx->Extensions.EXT_stencil_wrap = GL_TRUE; + ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; + /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/ +} + + +/** + * Enable all OpenGL 1.5 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_1_5_extensions(struct gl_context *ctx) +{ + ctx->Extensions.ARB_occlusion_query = GL_TRUE; + /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ + ctx->Extensions.EXT_shadow_funcs = GL_TRUE; +} + + +/** + * Enable all OpenGL 2.0 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_2_0_extensions(struct gl_context *ctx) +{ + /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ +#if FEATURE_ARB_fragment_shader + ctx->Extensions.ARB_fragment_shader = GL_TRUE; +#endif + ctx->Extensions.ARB_point_sprite = GL_TRUE; + ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; + ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; +#if FEATURE_ARB_shader_objects + ctx->Extensions.ARB_shader_objects = GL_TRUE; +#endif +#if FEATURE_ARB_shading_language_100 + ctx->Extensions.ARB_shading_language_100 = GL_TRUE; +#endif + ctx->Extensions.EXT_stencil_two_side = GL_TRUE; +#if FEATURE_ARB_vertex_shader + ctx->Extensions.ARB_vertex_shader = GL_TRUE; +#endif +} + + +/** + * Enable all OpenGL 2.1 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_2_1_extensions(struct gl_context *ctx) +{ +#if FEATURE_EXT_pixel_buffer_object + ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; +#endif +#if FEATURE_EXT_texture_sRGB + ctx->Extensions.EXT_texture_sRGB = GL_TRUE; +#endif +} + + +/** + * Either enable or disable the named extension. + * \return GL_TRUE for success, GL_FALSE if invalid extension name + */ +static GLboolean +set_extension( struct gl_context *ctx, const char *name, GLboolean state ) +{ + size_t offset; + + if (ctx->Extensions.String) { + /* The string was already queried - can't change it now! */ + _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name); + return GL_FALSE; + } + + offset = name_to_offset(name); + if (offset == 0) { + _mesa_problem(ctx, "Trying to enable/disable unknown extension %s", + name); + return GL_FALSE; + } else if (offset == o(dummy_true) && state == GL_FALSE) { + _mesa_problem(ctx, "Trying to disable a permanently enabled extension: " + "%s", name); + return GL_FALSE; + } else { + GLboolean *base = (GLboolean *) &ctx->Extensions; + base[offset] = state; + return GL_TRUE; + } +} + + +/** + * Enable the named extension. + * Typically called by drivers. + */ +void +_mesa_enable_extension( struct gl_context *ctx, const char *name ) +{ + if (!set_extension(ctx, name, GL_TRUE)) + _mesa_problem(ctx, "Trying to enable unknown extension: %s", name); +} + + +/** + * Disable the named extension. + * XXX is this really needed??? + */ +void +_mesa_disable_extension( struct gl_context *ctx, const char *name ) +{ + if (!set_extension(ctx, name, GL_FALSE)) + _mesa_problem(ctx, "Trying to disable unknown extension: %s", name); +} + + +/** + * Test if the named extension is enabled in this context. + */ +GLboolean +_mesa_extension_is_enabled( struct gl_context *ctx, const char *name ) +{ + size_t offset; + GLboolean *base; + + if (name == 0) + return GL_FALSE; + + offset = name_to_offset(name); + if (offset == 0) + return GL_FALSE; + base = (GLboolean *) &ctx->Extensions; + return base[offset]; +} + + +/** + * \brief Apply the \c MESA_EXTENSION_OVERRIDE environment variable. + * + * \c MESA_EXTENSION_OVERRIDE is a space-separated list of extensions to + * enable or disable. The list is processed thus: + * - Enable recognized extension names that are prefixed with '+'. + * - Disable recognized extension names that are prefixed with '-'. + * - Enable recognized extension names that are not prefixed. + * - Collect unrecognized extension names in a new string. + * + * \return Space-separated list of unrecognized extension names (which must + * be freed). Does not return \c NULL. + */ +static char * +get_extension_override( struct gl_context *ctx ) +{ + const char *env_const= _mesa_getenv("MESA_EXTENSION_OVERRIDE"); + char *env; + char *ext; + char *extra_exts; + int len; + + if (env_const == NULL) { + /* Return the empty string rather than NULL. This simplifies the logic + * of client functions. */ + return calloc(1, sizeof(char)); + } + + /* extra_exts: List of unrecognized extensions. */ + extra_exts = calloc(strlen(env_const), sizeof(char)); + + /* Copy env_const because strtok() is destructive. */ + env = strdup(env_const); + for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) { + int enable; + int recognized; + switch (ext[0]) { + case '+': + enable = 1; + ++ext; + break; + case '-': + enable = 0; + ++ext; + break; + default: + enable = 1; + break; + } + recognized = set_extension(ctx, ext, enable); + if (!recognized) { + strcat(extra_exts, ext); + strcat(extra_exts, " "); + } + } + + /* Remove trailing space. */ + len = strlen(extra_exts); + if (extra_exts[len - 1] == ' ') + extra_exts[len - 1] = '\0'; + + return extra_exts; +} + + +/** + * \brief Initialize extension tables and enable default extensions. + * + * This should be called during context initialization. + * Note: Sets gl_extensions.dummy_true to true. + */ +void +_mesa_init_extensions( struct gl_context *ctx ) +{ + GLboolean *base = (GLboolean *) &ctx->Extensions; + GLboolean *sentinel = base + o(extension_sentinel); + GLboolean *i; + const size_t *j; + + /* First, turn all extensions off. */ + for (i = base; i != sentinel; ++i) + *i = GL_FALSE; + + /* Then, selectively turn default extensions on. */ + ctx->Extensions.dummy_true = GL_TRUE; + for (j = default_extensions; *j != 0; ++j) + base[*j] = GL_TRUE; +} + + +/** + * Construct the GL_EXTENSIONS string. Called the first time that + * glGetString(GL_EXTENSIONS) is called. + */ +GLubyte* +_mesa_make_extension_string(struct gl_context *ctx) +{ + /* The extension string. */ + char *exts = 0; + /* Length of extension string. */ + size_t length = 0; + /* String of extra extensions. */ + char *extra_extensions = get_extension_override(ctx); + GLboolean *base = (GLboolean *) &ctx->Extensions; + const struct extension *i; + + /* Compute length of the extension string. */ + for (i = extension_table; i->name != 0; ++i) { + if (base[i->offset] && (i->api_set & (1 << ctx->API))) { + length += strlen(i->name) + 1; /* +1 for space */ + } + } + if (extra_extensions != NULL) + length += 1 + strlen(extra_extensions); /* +1 for space */ + + exts = (char *) calloc(length + 1, sizeof(char)); + if (exts == NULL) { + free(extra_extensions); + return NULL; + } + + /* Build the extension string.*/ + for (i = extension_table; i->name != 0; ++i) { + if (base[i->offset] && (i->api_set & (1 << ctx->API))) { + strcat(exts, i->name); + strcat(exts, " "); + } + } + if (extra_extensions != 0) { + strcat(exts, extra_extensions); + free(extra_extensions); + } + + return (GLubyte *) exts; +} + +/** + * Return number of enabled extensions. + */ +GLuint +_mesa_get_extension_count(struct gl_context *ctx) +{ + GLboolean *base; + const struct extension *i; + + /* only count once */ + if (ctx->Extensions.Count != 0) + return ctx->Extensions.Count; + + base = (GLboolean *) &ctx->Extensions; + for (i = extension_table; i->name != 0; ++i) { + if (base[i->offset]) { + ctx->Extensions.Count++; + } + } + return ctx->Extensions.Count; +} + +/** + * Return name of i-th enabled extension + */ +const GLubyte * +_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index) +{ + const GLboolean *base; + size_t n; + const struct extension *i; + + if (index < 0) + return NULL; + + base = (GLboolean*) &ctx->Extensions; + n = 0; + for (i = extension_table; i->name != 0; ++i) { + if (n == index && base[i->offset]) { + return (GLubyte*) i->name; + } else if (base[i->offset]) { + ++n; + } + } + + return NULL; +} diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index 5c9b3068e..947db84a6 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -1,1618 +1,1658 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.7
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (c) 2008-2009 VMware, Inc.
- *
- * 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
- * BRIAN PAUL 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 "imports.h"
-#include "formats.h"
-#include "mfeatures.h"
-
-
-/**
- * Information about texture formats.
- */
-struct gl_format_info
-{
- gl_format Name;
-
- /** text name for debugging */
- const char *StrName;
-
- /**
- * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA,
- * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA,
- * GL_COLOR_INDEX, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX,
- * GL_DEPTH_STENCIL, GL_DUDV_ATI.
- */
- GLenum BaseFormat;
-
- /**
- * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALED,
- * GL_UNSIGNED_INT, GL_INT, GL_FLOAT.
- */
- GLenum DataType;
-
- GLubyte RedBits;
- GLubyte GreenBits;
- GLubyte BlueBits;
- GLubyte AlphaBits;
- GLubyte LuminanceBits;
- GLubyte IntensityBits;
- GLubyte IndexBits;
- GLubyte DepthBits;
- GLubyte StencilBits;
-
- /**
- * To describe compressed formats. If not compressed, Width=Height=1.
- */
- GLubyte BlockWidth, BlockHeight;
- GLubyte BytesPerBlock;
-};
-
-
-/**
- * Info about each format.
- * These must be in the same order as the MESA_FORMAT_* enums so that
- * we can do lookups without searching.
- */
-static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
-{
- {
- MESA_FORMAT_NONE, /* Name */
- "MESA_FORMAT_NONE", /* StrName */
- GL_NONE, /* BaseFormat */
- GL_NONE, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 0, 0, 0 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_RGBA8888, /* Name */
- "MESA_FORMAT_RGBA8888", /* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_RGBA8888_REV, /* Name */
- "MESA_FORMAT_RGBA8888_REV", /* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_ARGB8888, /* Name */
- "MESA_FORMAT_ARGB8888", /* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_ARGB8888_REV, /* Name */
- "MESA_FORMAT_ARGB8888_REV", /* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_XRGB8888, /* Name */
- "MESA_FORMAT_XRGB8888", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_XRGB8888_REV, /* Name */
- "MESA_FORMAT_XRGB8888_REV", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_RGB888, /* Name */
- "MESA_FORMAT_RGB888", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 3 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_BGR888, /* Name */
- "MESA_FORMAT_BGR888", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 3 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_RGB565, /* Name */
- "MESA_FORMAT_RGB565", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_RGB565_REV, /* Name */
- "MESA_FORMAT_RGB565_REV", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_ARGB4444, /* Name */
- "MESA_FORMAT_ARGB4444", /* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_ARGB4444_REV, /* Name */
- "MESA_FORMAT_ARGB4444_REV", /* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_RGBA5551, /* Name */
- "MESA_FORMAT_RGBA5551", /* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_ARGB1555, /* Name */
- "MESA_FORMAT_ARGB1555", /* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_ARGB1555_REV, /* Name */
- "MESA_FORMAT_ARGB1555_REV", /* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_AL44, /* Name */
- "MESA_FORMAT_AL44", /* StrName */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 4, /* Red/Green/Blue/AlphaBits */
- 4, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_AL88, /* Name */
- "MESA_FORMAT_AL88", /* StrName */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
- 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_AL88_REV, /* Name */
- "MESA_FORMAT_AL88_REV", /* StrName */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
- 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_AL1616, /* Name */
- "MESA_FORMAT_AL1616", /* StrName */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */
- 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_AL1616_REV, /* Name */
- "MESA_FORMAT_AL1616_REV", /* StrName */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */
- 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_RGB332, /* Name */
- "MESA_FORMAT_RGB332", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_A8, /* Name */
- "MESA_FORMAT_A8", /* StrName */
- GL_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_A16, /* Name */
- "MESA_FORMAT_A16", /* StrName */
- GL_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_L8, /* Name */
- "MESA_FORMAT_L8", /* StrName */
- GL_LUMINANCE, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_L16, /* Name */
- "MESA_FORMAT_L16", /* StrName */
- GL_LUMINANCE, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_I8, /* Name */
- "MESA_FORMAT_I8", /* StrName */
- GL_INTENSITY, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_I16, /* Name */
- "MESA_FORMAT_I16", /* StrName */
- GL_INTENSITY, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 16, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_CI8, /* Name */
- "MESA_FORMAT_CI8", /* StrName */
- GL_COLOR_INDEX, /* BaseFormat */
- GL_UNSIGNED_INT, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 8, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_YCBCR, /* Name */
- "MESA_FORMAT_YCBCR", /* StrName */
- GL_YCBCR_MESA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_YCBCR_REV, /* Name */
- "MESA_FORMAT_YCBCR_REV", /* StrName */
- GL_YCBCR_MESA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_R8,
- "MESA_FORMAT_R8",
- GL_RED,
- GL_UNSIGNED_NORMALIZED,
- 8, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_RG88,
- "MESA_FORMAT_RG88",
- GL_RG,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_RG88_REV,
- "MESA_FORMAT_RG88_REV",
- GL_RG,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_R16,
- "MESA_FORMAT_R16",
- GL_RED,
- GL_UNSIGNED_NORMALIZED,
- 16, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_RG1616,
- "MESA_FORMAT_RG1616",
- GL_RG,
- GL_UNSIGNED_NORMALIZED,
- 16, 16, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RG1616_REV,
- "MESA_FORMAT_RG1616_REV",
- GL_RG,
- GL_UNSIGNED_NORMALIZED,
- 16, 16, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_ARGB2101010,
- "MESA_FORMAT_ARGB2101010",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 10, 10, 10, 2,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_Z24_S8, /* Name */
- "MESA_FORMAT_Z24_S8", /* StrName */
- GL_DEPTH_STENCIL, /* BaseFormat */
- GL_UNSIGNED_INT, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_S8_Z24, /* Name */
- "MESA_FORMAT_S8_Z24", /* StrName */
- GL_DEPTH_STENCIL, /* BaseFormat */
- GL_UNSIGNED_INT, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_Z16, /* Name */
- "MESA_FORMAT_Z16", /* StrName */
- GL_DEPTH_COMPONENT, /* BaseFormat */
- GL_UNSIGNED_INT, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_X8_Z24, /* Name */
- "MESA_FORMAT_X8_Z24", /* StrName */
- GL_DEPTH_COMPONENT, /* BaseFormat */
- GL_UNSIGNED_INT, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_Z24_X8, /* Name */
- "MESA_FORMAT_Z24_X8", /* StrName */
- GL_DEPTH_COMPONENT, /* BaseFormat */
- GL_UNSIGNED_INT, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_Z32, /* Name */
- "MESA_FORMAT_Z32", /* StrName */
- GL_DEPTH_COMPONENT, /* BaseFormat */
- GL_UNSIGNED_INT, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_S8, /* Name */
- "MESA_FORMAT_S8", /* StrName */
- GL_STENCIL_INDEX, /* BaseFormat */
- GL_UNSIGNED_INT, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_SRGB8,
- "MESA_FORMAT_SRGB8",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 3
- },
- {
- MESA_FORMAT_SRGBA8,
- "MESA_FORMAT_SRGBA8",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_SARGB8,
- "MESA_FORMAT_SARGB8",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_SL8,
- "MESA_FORMAT_SL8",
- GL_LUMINANCE,
- GL_UNSIGNED_NORMALIZED,
- 0, 0, 0, 0,
- 8, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_SLA8,
- "MESA_FORMAT_SLA8",
- GL_LUMINANCE_ALPHA,
- GL_UNSIGNED_NORMALIZED,
- 0, 0, 0, 8,
- 8, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_SRGB_DXT1, /* Name */
- "MESA_FORMAT_SRGB_DXT1", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_SRGBA_DXT1,
- "MESA_FORMAT_SRGBA_DXT1",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_SRGBA_DXT3,
- "MESA_FORMAT_SRGBA_DXT3",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_SRGBA_DXT5,
- "MESA_FORMAT_SRGBA_DXT5",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
-
- {
- MESA_FORMAT_RGB_FXT1,
- "MESA_FORMAT_RGB_FXT1",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 0, /* approx Red/Green/BlueBits */
- 0, 0, 0, 0, 0,
- 8, 4, 16 /* 16 bytes per 8x4 block */
- },
- {
- MESA_FORMAT_RGBA_FXT1,
- "MESA_FORMAT_RGBA_FXT1",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0,
- 8, 4, 16 /* 16 bytes per 8x4 block */
- },
-
- {
- MESA_FORMAT_RGB_DXT1, /* Name */
- "MESA_FORMAT_RGB_DXT1", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_RGBA_DXT1,
- "MESA_FORMAT_RGBA_DXT1",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_RGBA_DXT3,
- "MESA_FORMAT_RGBA_DXT3",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_RGBA_DXT5,
- "MESA_FORMAT_RGBA_DXT5",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_RGBA_FLOAT32,
- "MESA_FORMAT_RGBA_FLOAT32",
- GL_RGBA,
- GL_FLOAT,
- 32, 32, 32, 32,
- 0, 0, 0, 0, 0,
- 1, 1, 16
- },
- {
- MESA_FORMAT_RGBA_FLOAT16,
- "MESA_FORMAT_RGBA_FLOAT16",
- GL_RGBA,
- GL_FLOAT,
- 16, 16, 16, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGB_FLOAT32,
- "MESA_FORMAT_RGB_FLOAT32",
- GL_RGB,
- GL_FLOAT,
- 32, 32, 32, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 12
- },
- {
- MESA_FORMAT_RGB_FLOAT16,
- "MESA_FORMAT_RGB_FLOAT16",
- GL_RGB,
- GL_FLOAT,
- 16, 16, 16, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 6
- },
- {
- MESA_FORMAT_ALPHA_FLOAT32,
- "MESA_FORMAT_ALPHA_FLOAT32",
- GL_ALPHA,
- GL_FLOAT,
- 0, 0, 0, 32,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_ALPHA_FLOAT16,
- "MESA_FORMAT_ALPHA_FLOAT16",
- GL_ALPHA,
- GL_FLOAT,
- 0, 0, 0, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_LUMINANCE_FLOAT32,
- "MESA_FORMAT_LUMINANCE_FLOAT32",
- GL_ALPHA,
- GL_FLOAT,
- 0, 0, 0, 0,
- 32, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_LUMINANCE_FLOAT16,
- "MESA_FORMAT_LUMINANCE_FLOAT16",
- GL_ALPHA,
- GL_FLOAT,
- 0, 0, 0, 0,
- 16, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
- "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32",
- GL_LUMINANCE_ALPHA,
- GL_FLOAT,
- 0, 0, 0, 32,
- 32, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
- "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16",
- GL_LUMINANCE_ALPHA,
- GL_FLOAT,
- 0, 0, 0, 16,
- 16, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_INTENSITY_FLOAT32,
- "MESA_FORMAT_INTENSITY_FLOAT32",
- GL_INTENSITY,
- GL_FLOAT,
- 0, 0, 0, 0,
- 0, 32, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_INTENSITY_FLOAT16,
- "MESA_FORMAT_INTENSITY_FLOAT16",
- GL_INTENSITY,
- GL_FLOAT,
- 0, 0, 0, 0,
- 0, 16, 0, 0, 0,
- 1, 1, 2
- },
-
- /* unnormalized signed int formats */
- {
- MESA_FORMAT_RGBA_INT8,
- "MESA_FORMAT_RGBA_INT8",
- GL_RGBA,
- GL_INT,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RGBA_INT16,
- "MESA_FORMAT_RGBA_INT16",
- GL_RGBA,
- GL_INT,
- 16, 16, 16, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGBA_INT32,
- "MESA_FORMAT_RGBA_INT32",
- GL_RGBA,
- GL_INT,
- 32, 32, 32, 32,
- 0, 0, 0, 0, 0,
- 1, 1, 16
- },
-
- /* unnormalized unsigned int formats */
- {
- MESA_FORMAT_RGBA_UINT8,
- "MESA_FORMAT_RGBA_UINT8",
- GL_RGBA,
- GL_UNSIGNED_INT,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RGBA_UINT16,
- "MESA_FORMAT_RGBA_UINT16",
- GL_RGBA,
- GL_UNSIGNED_INT,
- 16, 16, 16, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGBA_UINT32,
- "MESA_FORMAT_RGBA_UINT32",
- GL_RGBA,
- GL_UNSIGNED_INT,
- 32, 32, 32, 32,
- 0, 0, 0, 0, 0,
- 1, 1, 16
- },
-
-
- {
- MESA_FORMAT_DUDV8,
- "MESA_FORMAT_DUDV8",
- GL_DUDV_ATI,
- GL_SIGNED_NORMALIZED,
- 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
-
- /* Signed 8 bits / channel */
- {
- MESA_FORMAT_SIGNED_R8, /* Name */
- "MESA_FORMAT_SIGNED_R8", /* StrName */
- GL_RED, /* BaseFormat */
- GL_SIGNED_NORMALIZED, /* DataType */
- 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_SIGNED_RG88,
- "MESA_FORMAT_SIGNED_RG88",
- GL_RG,
- GL_SIGNED_NORMALIZED,
- 8, 8, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_SIGNED_RGBX8888,
- "MESA_FORMAT_SIGNED_RGBX8888",
- GL_RGB,
- GL_SIGNED_NORMALIZED,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4 /* 4 bpp, but no alpha */
- },
- {
- MESA_FORMAT_SIGNED_RGBA8888,
- "MESA_FORMAT_SIGNED_RGBA8888",
- GL_RGBA,
- GL_SIGNED_NORMALIZED,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_SIGNED_RGBA8888_REV,
- "MESA_FORMAT_SIGNED_RGBA8888_REV",
- GL_RGBA,
- GL_SIGNED_NORMALIZED,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
-
- /* Signed 16 bits / channel */
- {
- MESA_FORMAT_SIGNED_R_16,
- "MESA_FORMAT_SIGNED_R_16",
- GL_RED,
- GL_SIGNED_NORMALIZED,
- 16, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_SIGNED_RG_16,
- "MESA_FORMAT_SIGNED_RG_16",
- GL_RG,
- GL_SIGNED_NORMALIZED,
- 16, 16, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_SIGNED_RGB_16,
- "MESA_FORMAT_SIGNED_RGB_16",
- GL_RGB,
- GL_SIGNED_NORMALIZED,
- 16, 16, 16, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 6
- },
- {
- MESA_FORMAT_SIGNED_RGBA_16,
- "MESA_FORMAT_SIGNED_RGBA_16",
- GL_RGBA,
- GL_SIGNED_NORMALIZED,
- 16, 16, 16, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGBA_16,
- "MESA_FORMAT_RGBA_16",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 16, 16, 16, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- }
-};
-
-
-
-static const struct gl_format_info *
-_mesa_get_format_info(gl_format format)
-{
- const struct gl_format_info *info = &format_info[format];
- assert(info->Name == format);
- return info;
-}
-
-
-/** Return string name of format (for debugging) */
-const char *
-_mesa_get_format_name(gl_format format)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
- return info->StrName;
-}
-
-
-
-/**
- * Return bytes needed to store a block of pixels in the given format.
- * Normally, a block is 1x1 (a single pixel). But for compressed formats
- * a block may be 4x4 or 8x4, etc.
- */
-GLuint
-_mesa_get_format_bytes(gl_format format)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
- ASSERT(info->BytesPerBlock);
- return info->BytesPerBlock;
-}
-
-
-/**
- * Return bits per component for the given format.
- * \param format one of MESA_FORMAT_x
- * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc.
- */
-GLint
-_mesa_get_format_bits(gl_format format, GLenum pname)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
-
- switch (pname) {
- case GL_RED_BITS:
- case GL_TEXTURE_RED_SIZE:
- case GL_RENDERBUFFER_RED_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
- return info->RedBits;
- case GL_GREEN_BITS:
- case GL_TEXTURE_GREEN_SIZE:
- case GL_RENDERBUFFER_GREEN_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
- return info->GreenBits;
- case GL_BLUE_BITS:
- case GL_TEXTURE_BLUE_SIZE:
- case GL_RENDERBUFFER_BLUE_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
- return info->BlueBits;
- case GL_ALPHA_BITS:
- case GL_TEXTURE_ALPHA_SIZE:
- case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
- return info->AlphaBits;
- case GL_TEXTURE_INTENSITY_SIZE:
- return info->IntensityBits;
- case GL_TEXTURE_LUMINANCE_SIZE:
- return info->LuminanceBits;
- case GL_INDEX_BITS:
- case GL_TEXTURE_INDEX_SIZE_EXT:
- return info->IndexBits;
- case GL_DEPTH_BITS:
- case GL_TEXTURE_DEPTH_SIZE_ARB:
- case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
- return info->DepthBits;
- case GL_STENCIL_BITS:
- case GL_TEXTURE_STENCIL_SIZE_EXT:
- case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
- return info->StencilBits;
- default:
- _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()");
- return 0;
- }
-}
-
-
-/**
- * Return the data type (or more specifically, the data representation)
- * for the given format.
- * The return value will be one of:
- * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1]
- * GL_SIGNED_NORMALIZED = signed int representing [-1, 1]
- * GL_UNSIGNED_INT = an ordinary unsigned integer
- * GL_INT = an ordinary signed integer
- * GL_FLOAT = an ordinary float
- */
-GLenum
-_mesa_get_format_datatype(gl_format format)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
- return info->DataType;
-}
-
-
-/**
- * Return the basic format for the given type. The result will be
- * one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
- * GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, GL_DEPTH_COMPONENT,
- * GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
- */
-GLenum
-_mesa_get_format_base_format(gl_format format)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
- return info->BaseFormat;
-}
-
-
-/**
- * Return the block size (in pixels) for the given format. Normally
- * the block size is 1x1. But compressed formats will have block sizes
- * of 4x4 or 8x4 pixels, etc.
- * \param bw returns block width in pixels
- * \param bh returns block height in pixels
- */
-void
-_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
- *bw = info->BlockWidth;
- *bh = info->BlockHeight;
-}
-
-
-/** Is the given format a compressed format? */
-GLboolean
-_mesa_is_format_compressed(gl_format format)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
- return info->BlockWidth > 1 || info->BlockHeight > 1;
-}
-
-
-/**
- * Determine if the given format represents a packed depth/stencil buffer.
- */
-GLboolean
-_mesa_is_format_packed_depth_stencil(gl_format format)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
-
- return info->BaseFormat == GL_DEPTH_STENCIL;
-}
-
-
-/**
- * Is the given format a signed/unsigned integer color format?
- */
-GLboolean
-_mesa_is_format_integer_color(gl_format format)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
- return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT) &&
- info->BaseFormat != GL_DEPTH_COMPONENT &&
- info->BaseFormat != GL_DEPTH_STENCIL &&
- info->BaseFormat != GL_STENCIL_INDEX;
-}
-
-
-/**
- * Return color encoding for given format.
- * \return GL_LINEAR or GL_SRGB
- */
-GLenum
-_mesa_get_format_color_encoding(gl_format format)
-{
- /* XXX this info should be encoded in gl_format_info */
- switch (format) {
- case MESA_FORMAT_SRGB8:
- case MESA_FORMAT_SRGBA8:
- case MESA_FORMAT_SARGB8:
- case MESA_FORMAT_SL8:
- case MESA_FORMAT_SLA8:
- case MESA_FORMAT_SRGB_DXT1:
- case MESA_FORMAT_SRGBA_DXT1:
- case MESA_FORMAT_SRGBA_DXT3:
- case MESA_FORMAT_SRGBA_DXT5:
- return GL_SRGB;
- default:
- return GL_LINEAR;
- }
-}
-
-
-/**
- * For an sRGB format, return the corresponding linear color space format.
- * For non-sRGB formats, return the format as-is.
- */
-gl_format
-_mesa_get_srgb_format_linear(gl_format format)
-{
- switch (format) {
- case MESA_FORMAT_SRGB8:
- format = MESA_FORMAT_RGB888;
- break;
- case MESA_FORMAT_SRGBA8:
- format = MESA_FORMAT_RGBA8888;
- break;
- case MESA_FORMAT_SARGB8:
- format = MESA_FORMAT_ARGB8888;
- break;
- case MESA_FORMAT_SL8:
- format = MESA_FORMAT_L8;
- break;
- case MESA_FORMAT_SLA8:
- format = MESA_FORMAT_AL88;
- break;
- case MESA_FORMAT_SRGB_DXT1:
- format = MESA_FORMAT_RGB_DXT1;
- break;
- case MESA_FORMAT_SRGBA_DXT1:
- format = MESA_FORMAT_RGBA_DXT1;
- break;
- case MESA_FORMAT_SRGBA_DXT3:
- format = MESA_FORMAT_RGBA_DXT3;
- break;
- case MESA_FORMAT_SRGBA_DXT5:
- format = MESA_FORMAT_RGBA_DXT5;
- break;
- default:
- break;
- }
- return format;
-}
-
-
-/**
- * Return number of bytes needed to store an image of the given size
- * in the given format.
- */
-GLuint
-_mesa_format_image_size(gl_format format, GLsizei width,
- GLsizei height, GLsizei depth)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
- /* Strictly speaking, a conditional isn't needed here */
- if (info->BlockWidth > 1 || info->BlockHeight > 1) {
- /* compressed format (2D only for now) */
- const GLuint bw = info->BlockWidth, bh = info->BlockHeight;
- const GLuint wblocks = (width + bw - 1) / bw;
- const GLuint hblocks = (height + bh - 1) / bh;
- const GLuint sz = wblocks * hblocks * info->BytesPerBlock;
- assert(depth == 1);
- return sz;
- }
- else {
- /* non-compressed */
- const GLuint sz = width * height * depth * info->BytesPerBlock;
- return sz;
- }
-}
-
-
-/**
- * Same as _mesa_format_image_size() but returns a 64-bit value to
- * accomodate very large textures.
- */
-uint64_t
-_mesa_format_image_size64(gl_format format, GLsizei width,
- GLsizei height, GLsizei depth)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
- /* Strictly speaking, a conditional isn't needed here */
- if (info->BlockWidth > 1 || info->BlockHeight > 1) {
- /* compressed format (2D only for now) */
- const uint64_t bw = info->BlockWidth, bh = info->BlockHeight;
- const uint64_t wblocks = (width + bw - 1) / bw;
- const uint64_t hblocks = (height + bh - 1) / bh;
- const uint64_t sz = wblocks * hblocks * info->BytesPerBlock;
- assert(depth == 1);
- return sz;
- }
- else {
- /* non-compressed */
- const uint64_t sz = ((uint64_t) width *
- (uint64_t) height *
- (uint64_t) depth *
- info->BytesPerBlock);
- return sz;
- }
-}
-
-
-
-GLint
-_mesa_format_row_stride(gl_format format, GLsizei width)
-{
- const struct gl_format_info *info = _mesa_get_format_info(format);
- /* Strictly speaking, a conditional isn't needed here */
- if (info->BlockWidth > 1 || info->BlockHeight > 1) {
- /* compressed format */
- const GLuint bw = info->BlockWidth;
- const GLuint wblocks = (width + bw - 1) / bw;
- const GLint stride = wblocks * info->BytesPerBlock;
- return stride;
- }
- else {
- const GLint stride = width * info->BytesPerBlock;
- return stride;
- }
-}
-
-
-/**
- * Debug/test: check that all formats are handled in the
- * _mesa_format_to_type_and_comps() function. When new pixel formats
- * are added to Mesa, that function needs to be updated.
- * This is a no-op after the first call.
- */
-static void
-check_format_to_type_and_comps(void)
-{
- gl_format f;
-
- for (f = MESA_FORMAT_NONE + 1; f < MESA_FORMAT_COUNT; f++) {
- GLenum datatype = 0;
- GLuint comps = 0;
- /* This function will emit a problem/warning if the format is
- * not handled.
- */
- _mesa_format_to_type_and_comps(f, &datatype, &comps);
- }
-}
-
-
-/**
- * Do sanity checking of the format info table.
- */
-void
-_mesa_test_formats(void)
-{
- GLuint i;
-
- assert(Elements(format_info) == MESA_FORMAT_COUNT);
-
- for (i = 0; i < MESA_FORMAT_COUNT; i++) {
- const struct gl_format_info *info = _mesa_get_format_info(i);
- assert(info);
-
- assert(info->Name == i);
-
- if (info->Name == MESA_FORMAT_NONE)
- continue;
-
- if (info->BlockWidth == 1 && info->BlockHeight == 1) {
- if (info->RedBits > 0) {
- GLuint t = info->RedBits + info->GreenBits
- + info->BlueBits + info->AlphaBits;
- assert(t / 8 <= info->BytesPerBlock);
- (void) t;
- }
- }
-
- assert(info->DataType == GL_UNSIGNED_NORMALIZED ||
- info->DataType == GL_SIGNED_NORMALIZED ||
- info->DataType == GL_UNSIGNED_INT ||
- info->DataType == GL_INT ||
- info->DataType == GL_FLOAT);
-
- if (info->BaseFormat == GL_RGB) {
- assert(info->RedBits > 0);
- assert(info->GreenBits > 0);
- assert(info->BlueBits > 0);
- assert(info->AlphaBits == 0);
- assert(info->LuminanceBits == 0);
- assert(info->IntensityBits == 0);
- }
- else if (info->BaseFormat == GL_RGBA) {
- assert(info->RedBits > 0);
- assert(info->GreenBits > 0);
- assert(info->BlueBits > 0);
- assert(info->AlphaBits > 0);
- assert(info->LuminanceBits == 0);
- assert(info->IntensityBits == 0);
- }
- else if (info->BaseFormat == GL_RG) {
- assert(info->RedBits > 0);
- assert(info->GreenBits > 0);
- assert(info->BlueBits == 0);
- assert(info->AlphaBits == 0);
- assert(info->LuminanceBits == 0);
- assert(info->IntensityBits == 0);
- }
- else if (info->BaseFormat == GL_RED) {
- assert(info->RedBits > 0);
- assert(info->GreenBits == 0);
- assert(info->BlueBits == 0);
- assert(info->AlphaBits == 0);
- assert(info->LuminanceBits == 0);
- assert(info->IntensityBits == 0);
- }
- else if (info->BaseFormat == GL_LUMINANCE) {
- assert(info->RedBits == 0);
- assert(info->GreenBits == 0);
- assert(info->BlueBits == 0);
- assert(info->AlphaBits == 0);
- assert(info->LuminanceBits > 0);
- assert(info->IntensityBits == 0);
- }
- else if (info->BaseFormat == GL_INTENSITY) {
- assert(info->RedBits == 0);
- assert(info->GreenBits == 0);
- assert(info->BlueBits == 0);
- assert(info->AlphaBits == 0);
- assert(info->LuminanceBits == 0);
- assert(info->IntensityBits > 0);
- }
- }
-
- check_format_to_type_and_comps();
-}
-
-
-
-/**
- * Return datatype and number of components per texel for the given gl_format.
- * Only used for mipmap generation code.
- */
-void
-_mesa_format_to_type_and_comps(gl_format format,
- GLenum *datatype, GLuint *comps)
-{
- switch (format) {
- case MESA_FORMAT_RGBA8888:
- case MESA_FORMAT_RGBA8888_REV:
- case MESA_FORMAT_ARGB8888:
- case MESA_FORMAT_ARGB8888_REV:
- case MESA_FORMAT_XRGB8888:
- case MESA_FORMAT_XRGB8888_REV:
- *datatype = GL_UNSIGNED_BYTE;
- *comps = 4;
- return;
- case MESA_FORMAT_RGB888:
- case MESA_FORMAT_BGR888:
- *datatype = GL_UNSIGNED_BYTE;
- *comps = 3;
- return;
- case MESA_FORMAT_RGB565:
- case MESA_FORMAT_RGB565_REV:
- *datatype = GL_UNSIGNED_SHORT_5_6_5;
- *comps = 3;
- return;
-
- case MESA_FORMAT_ARGB4444:
- case MESA_FORMAT_ARGB4444_REV:
- *datatype = GL_UNSIGNED_SHORT_4_4_4_4;
- *comps = 4;
- return;
-
- case MESA_FORMAT_ARGB1555:
- case MESA_FORMAT_ARGB1555_REV:
- *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
- *comps = 4;
- return;
-
- case MESA_FORMAT_ARGB2101010:
- *datatype = GL_UNSIGNED_INT_2_10_10_10_REV;
- *comps = 4;
- return;
-
- case MESA_FORMAT_RGBA5551:
- *datatype = GL_UNSIGNED_SHORT_5_5_5_1;
- *comps = 4;
- return;
-
- case MESA_FORMAT_AL44:
- *datatype = MESA_UNSIGNED_BYTE_4_4;
- *comps = 2;
- return;
-
- case MESA_FORMAT_AL88:
- case MESA_FORMAT_AL88_REV:
- case MESA_FORMAT_RG88:
- case MESA_FORMAT_RG88_REV:
- *datatype = GL_UNSIGNED_BYTE;
- *comps = 2;
- return;
-
- case MESA_FORMAT_AL1616:
- case MESA_FORMAT_AL1616_REV:
- case MESA_FORMAT_RG1616:
- case MESA_FORMAT_RG1616_REV:
- *datatype = GL_UNSIGNED_SHORT;
- *comps = 2;
- return;
-
- case MESA_FORMAT_R16:
- case MESA_FORMAT_A16:
- case MESA_FORMAT_L16:
- case MESA_FORMAT_I16:
- *datatype = GL_UNSIGNED_SHORT;
- *comps = 1;
- return;
-
- case MESA_FORMAT_RGB332:
- *datatype = GL_UNSIGNED_BYTE_3_3_2;
- *comps = 3;
- return;
-
- case MESA_FORMAT_A8:
- case MESA_FORMAT_L8:
- case MESA_FORMAT_I8:
- case MESA_FORMAT_CI8:
- case MESA_FORMAT_R8:
- case MESA_FORMAT_S8:
- *datatype = GL_UNSIGNED_BYTE;
- *comps = 1;
- return;
-
- case MESA_FORMAT_YCBCR:
- case MESA_FORMAT_YCBCR_REV:
- *datatype = GL_UNSIGNED_SHORT;
- *comps = 2;
- return;
-
- case MESA_FORMAT_Z24_S8:
- *datatype = GL_UNSIGNED_INT;
- *comps = 1; /* XXX OK? */
- return;
-
- case MESA_FORMAT_S8_Z24:
- *datatype = GL_UNSIGNED_INT;
- *comps = 1; /* XXX OK? */
- return;
-
- case MESA_FORMAT_Z16:
- *datatype = GL_UNSIGNED_SHORT;
- *comps = 1;
- return;
-
- case MESA_FORMAT_X8_Z24:
- *datatype = GL_UNSIGNED_INT;
- *comps = 1;
- return;
-
- case MESA_FORMAT_Z24_X8:
- *datatype = GL_UNSIGNED_INT;
- *comps = 1;
- return;
-
- case MESA_FORMAT_Z32:
- *datatype = GL_UNSIGNED_INT;
- *comps = 1;
- return;
-
- case MESA_FORMAT_DUDV8:
- *datatype = GL_BYTE;
- *comps = 2;
- return;
-
- case MESA_FORMAT_SIGNED_R8:
- *datatype = GL_BYTE;
- *comps = 1;
- return;
- case MESA_FORMAT_SIGNED_RG88:
- *datatype = GL_BYTE;
- *comps = 2;
- return;
- case MESA_FORMAT_SIGNED_RGBA8888:
- case MESA_FORMAT_SIGNED_RGBA8888_REV:
- case MESA_FORMAT_SIGNED_RGBX8888:
- *datatype = GL_BYTE;
- *comps = 4;
- return;
-
- case MESA_FORMAT_RGBA_16:
- *datatype = GL_UNSIGNED_SHORT;
- *comps = 4;
- return;
-
- case MESA_FORMAT_SIGNED_R_16:
- *datatype = GL_SHORT;
- *comps = 1;
- return;
- case MESA_FORMAT_SIGNED_RG_16:
- *datatype = GL_SHORT;
- *comps = 2;
- return;
- case MESA_FORMAT_SIGNED_RGB_16:
- *datatype = GL_SHORT;
- *comps = 3;
- return;
- case MESA_FORMAT_SIGNED_RGBA_16:
- *datatype = GL_SHORT;
- *comps = 4;
- return;
-
-#if FEATURE_EXT_texture_sRGB
- case MESA_FORMAT_SRGB8:
- *datatype = GL_UNSIGNED_BYTE;
- *comps = 3;
- return;
- case MESA_FORMAT_SRGBA8:
- case MESA_FORMAT_SARGB8:
- *datatype = GL_UNSIGNED_BYTE;
- *comps = 4;
- return;
- case MESA_FORMAT_SL8:
- *datatype = GL_UNSIGNED_BYTE;
- *comps = 1;
- return;
- case MESA_FORMAT_SLA8:
- *datatype = GL_UNSIGNED_BYTE;
- *comps = 2;
- return;
-#endif
-
-#if FEATURE_texture_fxt1
- case MESA_FORMAT_RGB_FXT1:
- case MESA_FORMAT_RGBA_FXT1:
-#endif
-#if FEATURE_texture_s3tc
- case MESA_FORMAT_RGB_DXT1:
- case MESA_FORMAT_RGBA_DXT1:
- case MESA_FORMAT_RGBA_DXT3:
- case MESA_FORMAT_RGBA_DXT5:
-#if FEATURE_EXT_texture_sRGB
- case MESA_FORMAT_SRGB_DXT1:
- case MESA_FORMAT_SRGBA_DXT1:
- case MESA_FORMAT_SRGBA_DXT3:
- case MESA_FORMAT_SRGBA_DXT5:
-#endif
-#endif
- /* XXX generate error instead? */
- *datatype = GL_UNSIGNED_BYTE;
- *comps = 0;
- return;
-
- case MESA_FORMAT_RGBA_FLOAT32:
- *datatype = GL_FLOAT;
- *comps = 4;
- return;
- case MESA_FORMAT_RGBA_FLOAT16:
- *datatype = GL_HALF_FLOAT_ARB;
- *comps = 4;
- return;
- case MESA_FORMAT_RGB_FLOAT32:
- *datatype = GL_FLOAT;
- *comps = 3;
- return;
- case MESA_FORMAT_RGB_FLOAT16:
- *datatype = GL_HALF_FLOAT_ARB;
- *comps = 3;
- return;
- case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
- *datatype = GL_FLOAT;
- *comps = 2;
- return;
- case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
- *datatype = GL_HALF_FLOAT_ARB;
- *comps = 2;
- return;
- case MESA_FORMAT_ALPHA_FLOAT32:
- case MESA_FORMAT_LUMINANCE_FLOAT32:
- case MESA_FORMAT_INTENSITY_FLOAT32:
- *datatype = GL_FLOAT;
- *comps = 1;
- return;
- case MESA_FORMAT_ALPHA_FLOAT16:
- case MESA_FORMAT_LUMINANCE_FLOAT16:
- case MESA_FORMAT_INTENSITY_FLOAT16:
- *datatype = GL_HALF_FLOAT_ARB;
- *comps = 1;
- return;
-
- case MESA_FORMAT_RGBA_INT8:
- *datatype = GL_BYTE;
- *comps = 4;
- return;
- case MESA_FORMAT_RGBA_INT16:
- *datatype = GL_SHORT;
- *comps = 4;
- return;
- case MESA_FORMAT_RGBA_INT32:
- *datatype = GL_INT;
- *comps = 4;
- return;
-
- /**
- * \name Non-normalized unsigned integer formats.
- */
- case MESA_FORMAT_RGBA_UINT8:
- *datatype = GL_UNSIGNED_BYTE;
- *comps = 4;
- return;
- case MESA_FORMAT_RGBA_UINT16:
- *datatype = GL_UNSIGNED_SHORT;
- *comps = 4;
- return;
- case MESA_FORMAT_RGBA_UINT32:
- *datatype = GL_UNSIGNED_INT;
- *comps = 4;
- return;
-
- case MESA_FORMAT_COUNT:
- assert(0);
- return;
-
- case MESA_FORMAT_NONE:
- /* For debug builds, warn if any formats are not handled */
-#ifdef DEBUG
- default:
-#endif
- _mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps",
- _mesa_get_format_name(format));
- *datatype = 0;
- *comps = 1;
- }
-}
+/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * 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 + * BRIAN PAUL 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 "imports.h" +#include "formats.h" +#include "mfeatures.h" + + +/** + * Information about texture formats. + */ +struct gl_format_info +{ + gl_format Name; + + /** text name for debugging */ + const char *StrName; + + /** + * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA, + * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, + * GL_COLOR_INDEX, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, + * GL_DEPTH_STENCIL, GL_DUDV_ATI. + */ + GLenum BaseFormat; + + /** + * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALED, + * GL_UNSIGNED_INT, GL_INT, GL_FLOAT. + */ + GLenum DataType; + + GLubyte RedBits; + GLubyte GreenBits; + GLubyte BlueBits; + GLubyte AlphaBits; + GLubyte LuminanceBits; + GLubyte IntensityBits; + GLubyte IndexBits; + GLubyte DepthBits; + GLubyte StencilBits; + + /** + * To describe compressed formats. If not compressed, Width=Height=1. + */ + GLubyte BlockWidth, BlockHeight; + GLubyte BytesPerBlock; +}; + + +/** + * Info about each format. + * These must be in the same order as the MESA_FORMAT_* enums so that + * we can do lookups without searching. + */ +static struct gl_format_info format_info[MESA_FORMAT_COUNT] = +{ + { + MESA_FORMAT_NONE, /* Name */ + "MESA_FORMAT_NONE", /* StrName */ + GL_NONE, /* BaseFormat */ + GL_NONE, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 0, 0, 0 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA8888, /* Name */ + "MESA_FORMAT_RGBA8888", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA8888_REV, /* Name */ + "MESA_FORMAT_RGBA8888_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB8888, /* Name */ + "MESA_FORMAT_ARGB8888", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB8888_REV, /* Name */ + "MESA_FORMAT_ARGB8888_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_XRGB8888, /* Name */ + "MESA_FORMAT_XRGB8888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_XRGB8888_REV, /* Name */ + "MESA_FORMAT_XRGB8888_REV", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB888, /* Name */ + "MESA_FORMAT_RGB888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 3 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_BGR888, /* Name */ + "MESA_FORMAT_BGR888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 3 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB565, /* Name */ + "MESA_FORMAT_RGB565", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB565_REV, /* Name */ + "MESA_FORMAT_RGB565_REV", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB4444, /* Name */ + "MESA_FORMAT_ARGB4444", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB4444_REV, /* Name */ + "MESA_FORMAT_ARGB4444_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA5551, /* Name */ + "MESA_FORMAT_RGBA5551", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB1555, /* Name */ + "MESA_FORMAT_ARGB1555", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB1555_REV, /* Name */ + "MESA_FORMAT_ARGB1555_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL44, /* Name */ + "MESA_FORMAT_AL44", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 4, /* Red/Green/Blue/AlphaBits */ + 4, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL88, /* Name */ + "MESA_FORMAT_AL88", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL88_REV, /* Name */ + "MESA_FORMAT_AL88_REV", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL1616, /* Name */ + "MESA_FORMAT_AL1616", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL1616_REV, /* Name */ + "MESA_FORMAT_AL1616_REV", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB332, /* Name */ + "MESA_FORMAT_RGB332", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_A8, /* Name */ + "MESA_FORMAT_A8", /* StrName */ + GL_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_A16, /* Name */ + "MESA_FORMAT_A16", /* StrName */ + GL_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_L8, /* Name */ + "MESA_FORMAT_L8", /* StrName */ + GL_LUMINANCE, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_L16, /* Name */ + "MESA_FORMAT_L16", /* StrName */ + GL_LUMINANCE, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_I8, /* Name */ + "MESA_FORMAT_I8", /* StrName */ + GL_INTENSITY, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_I16, /* Name */ + "MESA_FORMAT_I16", /* StrName */ + GL_INTENSITY, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 16, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_CI8, /* Name */ + "MESA_FORMAT_CI8", /* StrName */ + GL_COLOR_INDEX, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 8, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_YCBCR, /* Name */ + "MESA_FORMAT_YCBCR", /* StrName */ + GL_YCBCR_MESA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_YCBCR_REV, /* Name */ + "MESA_FORMAT_YCBCR_REV", /* StrName */ + GL_YCBCR_MESA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_R8, + "MESA_FORMAT_R8", + GL_RED, + GL_UNSIGNED_NORMALIZED, + 8, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_RG88, + "MESA_FORMAT_RG88", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_RG88_REV, + "MESA_FORMAT_RG88_REV", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_R16, + "MESA_FORMAT_R16", + GL_RED, + GL_UNSIGNED_NORMALIZED, + 16, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_RG1616, + "MESA_FORMAT_RG1616", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RG1616_REV, + "MESA_FORMAT_RG1616_REV", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_ARGB2101010, + "MESA_FORMAT_ARGB2101010", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 10, 10, 10, 2, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_Z24_S8, /* Name */ + "MESA_FORMAT_Z24_S8", /* StrName */ + GL_DEPTH_STENCIL, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_S8_Z24, /* Name */ + "MESA_FORMAT_S8_Z24", /* StrName */ + GL_DEPTH_STENCIL, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z16, /* Name */ + "MESA_FORMAT_Z16", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_X8_Z24, /* Name */ + "MESA_FORMAT_X8_Z24", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z24_X8, /* Name */ + "MESA_FORMAT_Z24_X8", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z32, /* Name */ + "MESA_FORMAT_Z32", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_S8, /* Name */ + "MESA_FORMAT_S8", /* StrName */ + GL_STENCIL_INDEX, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_SRGB8, + "MESA_FORMAT_SRGB8", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 3 + }, + { + MESA_FORMAT_SRGBA8, + "MESA_FORMAT_SRGBA8", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SARGB8, + "MESA_FORMAT_SARGB8", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SL8, + "MESA_FORMAT_SL8", + GL_LUMINANCE, + GL_UNSIGNED_NORMALIZED, + 0, 0, 0, 0, + 8, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_SLA8, + "MESA_FORMAT_SLA8", + GL_LUMINANCE_ALPHA, + GL_UNSIGNED_NORMALIZED, + 0, 0, 0, 8, + 8, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SRGB_DXT1, /* Name */ + "MESA_FORMAT_SRGB_DXT1", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT1, + "MESA_FORMAT_SRGBA_DXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT3, + "MESA_FORMAT_SRGBA_DXT3", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT5, + "MESA_FORMAT_SRGBA_DXT5", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + + { + MESA_FORMAT_RGB_FXT1, + "MESA_FORMAT_RGB_FXT1", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 0, /* approx Red/Green/BlueBits */ + 0, 0, 0, 0, 0, + 8, 4, 16 /* 16 bytes per 8x4 block */ + }, + { + MESA_FORMAT_RGBA_FXT1, + "MESA_FORMAT_RGBA_FXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, + 8, 4, 16 /* 16 bytes per 8x4 block */ + }, + + { + MESA_FORMAT_RGB_DXT1, /* Name */ + "MESA_FORMAT_RGB_DXT1", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT1, + "MESA_FORMAT_RGBA_DXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT3, + "MESA_FORMAT_RGBA_DXT3", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT5, + "MESA_FORMAT_RGBA_DXT5", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_FLOAT32, + "MESA_FORMAT_RGBA_FLOAT32", + GL_RGBA, + GL_FLOAT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + { + MESA_FORMAT_RGBA_FLOAT16, + "MESA_FORMAT_RGBA_FLOAT16", + GL_RGBA, + GL_FLOAT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGB_FLOAT32, + "MESA_FORMAT_RGB_FLOAT32", + GL_RGB, + GL_FLOAT, + 32, 32, 32, 0, + 0, 0, 0, 0, 0, + 1, 1, 12 + }, + { + MESA_FORMAT_RGB_FLOAT16, + "MESA_FORMAT_RGB_FLOAT16", + GL_RGB, + GL_FLOAT, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 6 + }, + { + MESA_FORMAT_ALPHA_FLOAT32, + "MESA_FORMAT_ALPHA_FLOAT32", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 32, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_ALPHA_FLOAT16, + "MESA_FORMAT_ALPHA_FLOAT16", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 16, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT32, + "MESA_FORMAT_LUMINANCE_FLOAT32", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 0, + 32, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT16, + "MESA_FORMAT_LUMINANCE_FLOAT16", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 0, + 16, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32", + GL_LUMINANCE_ALPHA, + GL_FLOAT, + 0, 0, 0, 32, + 32, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16", + GL_LUMINANCE_ALPHA, + GL_FLOAT, + 0, 0, 0, 16, + 16, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_INTENSITY_FLOAT32, + "MESA_FORMAT_INTENSITY_FLOAT32", + GL_INTENSITY, + GL_FLOAT, + 0, 0, 0, 0, + 0, 32, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_INTENSITY_FLOAT16, + "MESA_FORMAT_INTENSITY_FLOAT16", + GL_INTENSITY, + GL_FLOAT, + 0, 0, 0, 0, + 0, 16, 0, 0, 0, + 1, 1, 2 + }, + + /* unnormalized signed int formats */ + { + MESA_FORMAT_RGBA_INT8, + "MESA_FORMAT_RGBA_INT8", + GL_RGBA, + GL_INT, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RGBA_INT16, + "MESA_FORMAT_RGBA_INT16", + GL_RGBA, + GL_INT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_INT32, + "MESA_FORMAT_RGBA_INT32", + GL_RGBA, + GL_INT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + + /* unnormalized unsigned int formats */ + { + MESA_FORMAT_RGBA_UINT8, + "MESA_FORMAT_RGBA_UINT8", + GL_RGBA, + GL_UNSIGNED_INT, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RGBA_UINT16, + "MESA_FORMAT_RGBA_UINT16", + GL_RGBA, + GL_UNSIGNED_INT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_UINT32, + "MESA_FORMAT_RGBA_UINT32", + GL_RGBA, + GL_UNSIGNED_INT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + + + { + MESA_FORMAT_DUDV8, + "MESA_FORMAT_DUDV8", + GL_DUDV_ATI, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + + /* Signed 8 bits / channel */ + { + MESA_FORMAT_SIGNED_R8, /* Name */ + "MESA_FORMAT_SIGNED_R8", /* StrName */ + GL_RED, /* BaseFormat */ + GL_SIGNED_NORMALIZED, /* DataType */ + 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_SIGNED_RG88, + "MESA_FORMAT_SIGNED_RG88", + GL_RG, + GL_SIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_RGBX8888, + "MESA_FORMAT_SIGNED_RGBX8888", + GL_RGB, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 /* 4 bpp, but no alpha */ + }, + { + MESA_FORMAT_SIGNED_RGBA8888, + "MESA_FORMAT_SIGNED_RGBA8888", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SIGNED_RGBA8888_REV, + "MESA_FORMAT_SIGNED_RGBA8888_REV", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + + /* Signed 16 bits / channel */ + { + MESA_FORMAT_SIGNED_R_16, + "MESA_FORMAT_SIGNED_R_16", + GL_RED, + GL_SIGNED_NORMALIZED, + 16, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_RG_16, + "MESA_FORMAT_SIGNED_RG_16", + GL_RG, + GL_SIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SIGNED_RGB_16, + "MESA_FORMAT_SIGNED_RGB_16", + GL_RGB, + GL_SIGNED_NORMALIZED, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 6 + }, + { + MESA_FORMAT_SIGNED_RGBA_16, + "MESA_FORMAT_SIGNED_RGBA_16", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_16, + "MESA_FORMAT_RGBA_16", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RED_RGTC1, + "MESA_FORMAT_RED_RGTC1", + GL_RED, + GL_UNSIGNED_NORMALIZED, + 4, 0, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SIGNED_RED_RGTC1, + "MESA_FORMAT_SIGNED_RED_RGTC1", + GL_RED, + GL_SIGNED_NORMALIZED, + 4, 0, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RG_RGTC2, + "MESA_FORMAT_RG_RGTC2", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 4, 4, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SIGNED_RG_RGTC2, + "MESA_FORMAT_SIGNED_RG_RGTC2", + GL_RG, + GL_SIGNED_NORMALIZED, + 4, 4, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, +}; + + + +static const struct gl_format_info * +_mesa_get_format_info(gl_format format) +{ + const struct gl_format_info *info = &format_info[format]; + assert(info->Name == format); + return info; +} + + +/** Return string name of format (for debugging) */ +const char * +_mesa_get_format_name(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->StrName; +} + + + +/** + * Return bytes needed to store a block of pixels in the given format. + * Normally, a block is 1x1 (a single pixel). But for compressed formats + * a block may be 4x4 or 8x4, etc. + */ +GLuint +_mesa_get_format_bytes(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + ASSERT(info->BytesPerBlock); + return info->BytesPerBlock; +} + + +/** + * Return bits per component for the given format. + * \param format one of MESA_FORMAT_x + * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc. + */ +GLint +_mesa_get_format_bits(gl_format format, GLenum pname) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + + switch (pname) { + case GL_RED_BITS: + case GL_TEXTURE_RED_SIZE: + case GL_RENDERBUFFER_RED_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + return info->RedBits; + case GL_GREEN_BITS: + case GL_TEXTURE_GREEN_SIZE: + case GL_RENDERBUFFER_GREEN_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + return info->GreenBits; + case GL_BLUE_BITS: + case GL_TEXTURE_BLUE_SIZE: + case GL_RENDERBUFFER_BLUE_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: + return info->BlueBits; + case GL_ALPHA_BITS: + case GL_TEXTURE_ALPHA_SIZE: + case GL_RENDERBUFFER_ALPHA_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: + return info->AlphaBits; + case GL_TEXTURE_INTENSITY_SIZE: + return info->IntensityBits; + case GL_TEXTURE_LUMINANCE_SIZE: + return info->LuminanceBits; + case GL_INDEX_BITS: + case GL_TEXTURE_INDEX_SIZE_EXT: + return info->IndexBits; + case GL_DEPTH_BITS: + case GL_TEXTURE_DEPTH_SIZE_ARB: + case GL_RENDERBUFFER_DEPTH_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: + return info->DepthBits; + case GL_STENCIL_BITS: + case GL_TEXTURE_STENCIL_SIZE_EXT: + case GL_RENDERBUFFER_STENCIL_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + return info->StencilBits; + default: + _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()"); + return 0; + } +} + + +/** + * Return the data type (or more specifically, the data representation) + * for the given format. + * The return value will be one of: + * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1] + * GL_SIGNED_NORMALIZED = signed int representing [-1, 1] + * GL_UNSIGNED_INT = an ordinary unsigned integer + * GL_INT = an ordinary signed integer + * GL_FLOAT = an ordinary float + */ +GLenum +_mesa_get_format_datatype(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->DataType; +} + + +/** + * Return the basic format for the given type. The result will be + * one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, + * GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, GL_DEPTH_COMPONENT, + * GL_STENCIL_INDEX, GL_DEPTH_STENCIL. + */ +GLenum +_mesa_get_format_base_format(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->BaseFormat; +} + + +/** + * Return the block size (in pixels) for the given format. Normally + * the block size is 1x1. But compressed formats will have block sizes + * of 4x4 or 8x4 pixels, etc. + * \param bw returns block width in pixels + * \param bh returns block height in pixels + */ +void +_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + *bw = info->BlockWidth; + *bh = info->BlockHeight; +} + + +/** Is the given format a compressed format? */ +GLboolean +_mesa_is_format_compressed(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->BlockWidth > 1 || info->BlockHeight > 1; +} + + +/** + * Determine if the given format represents a packed depth/stencil buffer. + */ +GLboolean +_mesa_is_format_packed_depth_stencil(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + + return info->BaseFormat == GL_DEPTH_STENCIL; +} + + +/** + * Is the given format a signed/unsigned integer color format? + */ +GLboolean +_mesa_is_format_integer_color(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT) && + info->BaseFormat != GL_DEPTH_COMPONENT && + info->BaseFormat != GL_DEPTH_STENCIL && + info->BaseFormat != GL_STENCIL_INDEX; +} + + +/** + * Return color encoding for given format. + * \return GL_LINEAR or GL_SRGB + */ +GLenum +_mesa_get_format_color_encoding(gl_format format) +{ + /* XXX this info should be encoded in gl_format_info */ + switch (format) { + case MESA_FORMAT_SRGB8: + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SARGB8: + case MESA_FORMAT_SL8: + case MESA_FORMAT_SLA8: + case MESA_FORMAT_SRGB_DXT1: + case MESA_FORMAT_SRGBA_DXT1: + case MESA_FORMAT_SRGBA_DXT3: + case MESA_FORMAT_SRGBA_DXT5: + return GL_SRGB; + default: + return GL_LINEAR; + } +} + + +/** + * For an sRGB format, return the corresponding linear color space format. + * For non-sRGB formats, return the format as-is. + */ +gl_format +_mesa_get_srgb_format_linear(gl_format format) +{ + switch (format) { + case MESA_FORMAT_SRGB8: + format = MESA_FORMAT_RGB888; + break; + case MESA_FORMAT_SRGBA8: + format = MESA_FORMAT_RGBA8888; + break; + case MESA_FORMAT_SARGB8: + format = MESA_FORMAT_ARGB8888; + break; + case MESA_FORMAT_SL8: + format = MESA_FORMAT_L8; + break; + case MESA_FORMAT_SLA8: + format = MESA_FORMAT_AL88; + break; + case MESA_FORMAT_SRGB_DXT1: + format = MESA_FORMAT_RGB_DXT1; + break; + case MESA_FORMAT_SRGBA_DXT1: + format = MESA_FORMAT_RGBA_DXT1; + break; + case MESA_FORMAT_SRGBA_DXT3: + format = MESA_FORMAT_RGBA_DXT3; + break; + case MESA_FORMAT_SRGBA_DXT5: + format = MESA_FORMAT_RGBA_DXT5; + break; + default: + break; + } + return format; +} + + +/** + * Return number of bytes needed to store an image of the given size + * in the given format. + */ +GLuint +_mesa_format_image_size(gl_format format, GLsizei width, + GLsizei height, GLsizei depth) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format (2D only for now) */ + const GLuint bw = info->BlockWidth, bh = info->BlockHeight; + const GLuint wblocks = (width + bw - 1) / bw; + const GLuint hblocks = (height + bh - 1) / bh; + const GLuint sz = wblocks * hblocks * info->BytesPerBlock; + assert(depth == 1); + return sz; + } + else { + /* non-compressed */ + const GLuint sz = width * height * depth * info->BytesPerBlock; + return sz; + } +} + + +/** + * Same as _mesa_format_image_size() but returns a 64-bit value to + * accomodate very large textures. + */ +uint64_t +_mesa_format_image_size64(gl_format format, GLsizei width, + GLsizei height, GLsizei depth) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format (2D only for now) */ + const uint64_t bw = info->BlockWidth, bh = info->BlockHeight; + const uint64_t wblocks = (width + bw - 1) / bw; + const uint64_t hblocks = (height + bh - 1) / bh; + const uint64_t sz = wblocks * hblocks * info->BytesPerBlock; + assert(depth == 1); + return sz; + } + else { + /* non-compressed */ + const uint64_t sz = ((uint64_t) width * + (uint64_t) height * + (uint64_t) depth * + info->BytesPerBlock); + return sz; + } +} + + + +GLint +_mesa_format_row_stride(gl_format format, GLsizei width) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format */ + const GLuint bw = info->BlockWidth; + const GLuint wblocks = (width + bw - 1) / bw; + const GLint stride = wblocks * info->BytesPerBlock; + return stride; + } + else { + const GLint stride = width * info->BytesPerBlock; + return stride; + } +} + + +/** + * Debug/test: check that all formats are handled in the + * _mesa_format_to_type_and_comps() function. When new pixel formats + * are added to Mesa, that function needs to be updated. + * This is a no-op after the first call. + */ +static void +check_format_to_type_and_comps(void) +{ + gl_format f; + + for (f = MESA_FORMAT_NONE + 1; f < MESA_FORMAT_COUNT; f++) { + GLenum datatype = 0; + GLuint comps = 0; + /* This function will emit a problem/warning if the format is + * not handled. + */ + _mesa_format_to_type_and_comps(f, &datatype, &comps); + } +} + + +/** + * Do sanity checking of the format info table. + */ +void +_mesa_test_formats(void) +{ + GLuint i; + + assert(Elements(format_info) == MESA_FORMAT_COUNT); + + for (i = 0; i < MESA_FORMAT_COUNT; i++) { + const struct gl_format_info *info = _mesa_get_format_info(i); + assert(info); + + assert(info->Name == i); + + if (info->Name == MESA_FORMAT_NONE) + continue; + + if (info->BlockWidth == 1 && info->BlockHeight == 1) { + if (info->RedBits > 0) { + GLuint t = info->RedBits + info->GreenBits + + info->BlueBits + info->AlphaBits; + assert(t / 8 <= info->BytesPerBlock); + (void) t; + } + } + + assert(info->DataType == GL_UNSIGNED_NORMALIZED || + info->DataType == GL_SIGNED_NORMALIZED || + info->DataType == GL_UNSIGNED_INT || + info->DataType == GL_INT || + info->DataType == GL_FLOAT); + + if (info->BaseFormat == GL_RGB) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits > 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RGBA) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits > 0); + assert(info->AlphaBits > 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RG) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RED) { + assert(info->RedBits > 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_LUMINANCE) { + assert(info->RedBits == 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits > 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_INTENSITY) { + assert(info->RedBits == 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits > 0); + } + } + + check_format_to_type_and_comps(); +} + + + +/** + * Return datatype and number of components per texel for the given gl_format. + * Only used for mipmap generation code. + */ +void +_mesa_format_to_type_and_comps(gl_format format, + GLenum *datatype, GLuint *comps) +{ + switch (format) { + case MESA_FORMAT_RGBA8888: + case MESA_FORMAT_RGBA8888_REV: + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_ARGB8888_REV: + case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_XRGB8888_REV: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGB888: + case MESA_FORMAT_BGR888: + *datatype = GL_UNSIGNED_BYTE; + *comps = 3; + return; + case MESA_FORMAT_RGB565: + case MESA_FORMAT_RGB565_REV: + *datatype = GL_UNSIGNED_SHORT_5_6_5; + *comps = 3; + return; + + case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_ARGB4444_REV: + *datatype = GL_UNSIGNED_SHORT_4_4_4_4; + *comps = 4; + return; + + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_ARGB1555_REV: + *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; + *comps = 4; + return; + + case MESA_FORMAT_ARGB2101010: + *datatype = GL_UNSIGNED_INT_2_10_10_10_REV; + *comps = 4; + return; + + case MESA_FORMAT_RGBA5551: + *datatype = GL_UNSIGNED_SHORT_5_5_5_1; + *comps = 4; + return; + + case MESA_FORMAT_AL44: + *datatype = MESA_UNSIGNED_BYTE_4_4; + *comps = 2; + return; + + case MESA_FORMAT_AL88: + case MESA_FORMAT_AL88_REV: + case MESA_FORMAT_RG88: + case MESA_FORMAT_RG88_REV: + *datatype = GL_UNSIGNED_BYTE; + *comps = 2; + return; + + case MESA_FORMAT_AL1616: + case MESA_FORMAT_AL1616_REV: + case MESA_FORMAT_RG1616: + case MESA_FORMAT_RG1616_REV: + *datatype = GL_UNSIGNED_SHORT; + *comps = 2; + return; + + case MESA_FORMAT_R16: + case MESA_FORMAT_A16: + case MESA_FORMAT_L16: + case MESA_FORMAT_I16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 1; + return; + + case MESA_FORMAT_RGB332: + *datatype = GL_UNSIGNED_BYTE_3_3_2; + *comps = 3; + return; + + case MESA_FORMAT_A8: + case MESA_FORMAT_L8: + case MESA_FORMAT_I8: + case MESA_FORMAT_CI8: + case MESA_FORMAT_R8: + case MESA_FORMAT_S8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 1; + return; + + case MESA_FORMAT_YCBCR: + case MESA_FORMAT_YCBCR_REV: + *datatype = GL_UNSIGNED_SHORT; + *comps = 2; + return; + + case MESA_FORMAT_Z24_S8: + *datatype = GL_UNSIGNED_INT; + *comps = 1; /* XXX OK? */ + return; + + case MESA_FORMAT_S8_Z24: + *datatype = GL_UNSIGNED_INT; + *comps = 1; /* XXX OK? */ + return; + + case MESA_FORMAT_Z16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 1; + return; + + case MESA_FORMAT_X8_Z24: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_Z24_X8: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_Z32: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_DUDV8: + *datatype = GL_BYTE; + *comps = 2; + return; + + case MESA_FORMAT_SIGNED_R8: + *datatype = GL_BYTE; + *comps = 1; + return; + case MESA_FORMAT_SIGNED_RG88: + *datatype = GL_BYTE; + *comps = 2; + return; + case MESA_FORMAT_SIGNED_RGBA8888: + case MESA_FORMAT_SIGNED_RGBA8888_REV: + case MESA_FORMAT_SIGNED_RGBX8888: + *datatype = GL_BYTE; + *comps = 4; + return; + + case MESA_FORMAT_RGBA_16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 4; + return; + + case MESA_FORMAT_SIGNED_R_16: + *datatype = GL_SHORT; + *comps = 1; + return; + case MESA_FORMAT_SIGNED_RG_16: + *datatype = GL_SHORT; + *comps = 2; + return; + case MESA_FORMAT_SIGNED_RGB_16: + *datatype = GL_SHORT; + *comps = 3; + return; + case MESA_FORMAT_SIGNED_RGBA_16: + *datatype = GL_SHORT; + *comps = 4; + return; + +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 3; + return; + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SARGB8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_SL8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 1; + return; + case MESA_FORMAT_SLA8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 2; + return; +#endif + +#if FEATURE_texture_fxt1 + case MESA_FORMAT_RGB_FXT1: + case MESA_FORMAT_RGBA_FXT1: +#endif +#if FEATURE_texture_s3tc + case MESA_FORMAT_RGB_DXT1: + case MESA_FORMAT_RGBA_DXT1: + case MESA_FORMAT_RGBA_DXT3: + case MESA_FORMAT_RGBA_DXT5: +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB_DXT1: + case MESA_FORMAT_SRGBA_DXT1: + case MESA_FORMAT_SRGBA_DXT3: + case MESA_FORMAT_SRGBA_DXT5: +#endif +#endif + case MESA_FORMAT_RED_RGTC1: + case MESA_FORMAT_SIGNED_RED_RGTC1: + case MESA_FORMAT_RG_RGTC2: + case MESA_FORMAT_SIGNED_RG_RGTC2: + /* XXX generate error instead? */ + *datatype = GL_UNSIGNED_BYTE; + *comps = 0; + return; + + case MESA_FORMAT_RGBA_FLOAT32: + *datatype = GL_FLOAT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 4; + return; + case MESA_FORMAT_RGB_FLOAT32: + *datatype = GL_FLOAT; + *comps = 3; + return; + case MESA_FORMAT_RGB_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 3; + return; + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: + *datatype = GL_FLOAT; + *comps = 2; + return; + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 2; + return; + case MESA_FORMAT_ALPHA_FLOAT32: + case MESA_FORMAT_LUMINANCE_FLOAT32: + case MESA_FORMAT_INTENSITY_FLOAT32: + *datatype = GL_FLOAT; + *comps = 1; + return; + case MESA_FORMAT_ALPHA_FLOAT16: + case MESA_FORMAT_LUMINANCE_FLOAT16: + case MESA_FORMAT_INTENSITY_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 1; + return; + + case MESA_FORMAT_RGBA_INT8: + *datatype = GL_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGBA_INT16: + *datatype = GL_SHORT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_INT32: + *datatype = GL_INT; + *comps = 4; + return; + + /** + * \name Non-normalized unsigned integer formats. + */ + case MESA_FORMAT_RGBA_UINT8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGBA_UINT16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_UINT32: + *datatype = GL_UNSIGNED_INT; + *comps = 4; + return; + + case MESA_FORMAT_COUNT: + assert(0); + return; + + case MESA_FORMAT_NONE: + /* For debug builds, warn if any formats are not handled */ +#ifdef DEBUG + default: +#endif + _mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps", + _mesa_get_format_name(format)); + *datatype = 0; + *comps = 1; + } +} diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h index cd7e0e25e..e21967e2b 100644 --- a/mesalib/src/mesa/main/formats.h +++ b/mesalib/src/mesa/main/formats.h @@ -1,237 +1,243 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.7
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (c) 2008-2009 VMware, Inc.
- *
- * 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
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * Authors:
- * Brian Paul
- */
-
-
-#ifndef FORMATS_H
-#define FORMATS_H
-
-
-#include <GL/gl.h>
-
-/* OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type
- * for GL_LUMINANCE4_ALPHA4. */
-#define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1)
-
-
-/**
- * Mesa texture/renderbuffer image formats.
- */
-typedef enum
-{
- MESA_FORMAT_NONE = 0,
-
- /**
- * \name Basic hardware formats
- */
- /*@{*/
- /* msb <------ TEXEL BITS -----------> lsb */
- /* ---- ---- ---- ---- ---- ---- ---- ---- */
- MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
- MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
- MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
- MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
- MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */
- MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */
- MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */
- MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */
- MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */
- MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */
- MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */
- MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */
- MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */
- MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */
- MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */
- MESA_FORMAT_AL44, /* AAAA LLLL */
- MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */
- MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */
- MESA_FORMAT_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */
- MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */
- MESA_FORMAT_RGB332, /* RRRG GGBB */
- MESA_FORMAT_A8, /* AAAA AAAA */
- MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */
- MESA_FORMAT_L8, /* LLLL LLLL */
- MESA_FORMAT_L16, /* LLLL LLLL LLLL LLLL */
- MESA_FORMAT_I8, /* IIII IIII */
- MESA_FORMAT_I16, /* IIII IIII IIII IIII */
- MESA_FORMAT_CI8, /* CCCC CCCC */
- MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
- MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
- MESA_FORMAT_R8, /* RRRR RRRR */
- MESA_FORMAT_RG88, /* RRRR RRRR GGGG GGGG */
- MESA_FORMAT_RG88_REV, /* GGGG GGGG RRRR RRRR */
- MESA_FORMAT_R16, /* RRRR RRRR RRRR RRRR */
- MESA_FORMAT_RG1616, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */
- MESA_FORMAT_RG1616_REV, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */
- MESA_FORMAT_ARGB2101010, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */
- MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */
- MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
- MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */
- MESA_FORMAT_X8_Z24, /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
- MESA_FORMAT_Z24_X8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */
- MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
- MESA_FORMAT_S8, /* SSSS SSSS */
- /*@}*/
-
- /**
- * \name 8-bit/channel sRGB formats
- */
- /*@{*/
- MESA_FORMAT_SRGB8,
- MESA_FORMAT_SRGBA8,
- MESA_FORMAT_SARGB8,
- MESA_FORMAT_SL8,
- MESA_FORMAT_SLA8,
- MESA_FORMAT_SRGB_DXT1,
- MESA_FORMAT_SRGBA_DXT1,
- MESA_FORMAT_SRGBA_DXT3,
- MESA_FORMAT_SRGBA_DXT5,
- /*@}*/
-
- /**
- * \name Compressed texture formats.
- */
- /*@{*/
- MESA_FORMAT_RGB_FXT1,
- MESA_FORMAT_RGBA_FXT1,
- MESA_FORMAT_RGB_DXT1,
- MESA_FORMAT_RGBA_DXT1,
- MESA_FORMAT_RGBA_DXT3,
- MESA_FORMAT_RGBA_DXT5,
- /*@}*/
-
- /**
- * \name Floating point texture formats.
- */
- /*@{*/
- MESA_FORMAT_RGBA_FLOAT32,
- MESA_FORMAT_RGBA_FLOAT16,
- MESA_FORMAT_RGB_FLOAT32,
- MESA_FORMAT_RGB_FLOAT16,
- MESA_FORMAT_ALPHA_FLOAT32,
- MESA_FORMAT_ALPHA_FLOAT16,
- MESA_FORMAT_LUMINANCE_FLOAT32,
- MESA_FORMAT_LUMINANCE_FLOAT16,
- MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
- MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
- MESA_FORMAT_INTENSITY_FLOAT32,
- MESA_FORMAT_INTENSITY_FLOAT16,
- /*@}*/
-
- /**
- * \name Non-normalized signed integer formats.
- * XXX Note: these are just stand-ins for some better hardware
- * formats TBD such as BGRA or ARGB.
- */
- MESA_FORMAT_RGBA_INT8,
- MESA_FORMAT_RGBA_INT16,
- MESA_FORMAT_RGBA_INT32,
-
- /**
- * \name Non-normalized unsigned integer formats.
- */
- MESA_FORMAT_RGBA_UINT8,
- MESA_FORMAT_RGBA_UINT16,
- MESA_FORMAT_RGBA_UINT32,
-
- /* msb <------ TEXEL BITS -----------> lsb */
- /* ---- ---- ---- ---- ---- ---- ---- ---- */
- /**
- * \name Signed fixed point texture formats.
- */
- /*@{*/
- MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */
- MESA_FORMAT_SIGNED_R8, /* RRRR RRRR */
- MESA_FORMAT_SIGNED_RG88, /* RRRR RRRR GGGG GGGG */
- MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */
- MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
- MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
- MESA_FORMAT_SIGNED_R_16, /* ushort[0]=R */
- MESA_FORMAT_SIGNED_RG_16, /* ushort[0]=R, ushort[1]=G */
- MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */
- MESA_FORMAT_SIGNED_RGBA_16, /* ... */
- MESA_FORMAT_RGBA_16, /* ... */
- /*@}*/
-
- MESA_FORMAT_COUNT
-} gl_format;
-
-
-extern const char *
-_mesa_get_format_name(gl_format format);
-
-extern GLuint
-_mesa_get_format_bytes(gl_format format);
-
-extern GLint
-_mesa_get_format_bits(gl_format format, GLenum pname);
-
-extern GLenum
-_mesa_get_format_datatype(gl_format format);
-
-extern GLenum
-_mesa_get_format_base_format(gl_format format);
-
-extern void
-_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh);
-
-extern GLboolean
-_mesa_is_format_compressed(gl_format format);
-
-extern GLboolean
-_mesa_is_format_packed_depth_stencil(gl_format format);
-
-extern GLboolean
-_mesa_is_format_integer_color(gl_format format);
-
-extern GLenum
-_mesa_get_format_color_encoding(gl_format format);
-
-extern GLuint
-_mesa_format_image_size(gl_format format, GLsizei width,
- GLsizei height, GLsizei depth);
-
-extern uint64_t
-_mesa_format_image_size64(gl_format format, GLsizei width,
- GLsizei height, GLsizei depth);
-
-extern GLint
-_mesa_format_row_stride(gl_format format, GLsizei width);
-
-extern void
-_mesa_format_to_type_and_comps(gl_format format,
- GLenum *datatype, GLuint *comps);
-
-extern void
-_mesa_test_formats(void);
-
-extern gl_format
-_mesa_get_srgb_format_linear(gl_format format);
-
-#endif /* FORMATS_H */
+/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * 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 + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Brian Paul + */ + + +#ifndef FORMATS_H +#define FORMATS_H + + +#include <GL/gl.h> + +/* OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type + * for GL_LUMINANCE4_ALPHA4. */ +#define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1) + + +/** + * Mesa texture/renderbuffer image formats. + */ +typedef enum +{ + MESA_FORMAT_NONE = 0, + + /** + * \name Basic hardware formats + */ + /*@{*/ + /* msb <------ TEXEL BITS -----------> lsb */ + /* ---- ---- ---- ---- ---- ---- ---- ---- */ + MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ + MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ + MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */ + MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ + MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */ + MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */ + MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */ + MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */ + MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */ + MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */ + MESA_FORMAT_AL44, /* AAAA LLLL */ + MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */ + MESA_FORMAT_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ + MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */ + MESA_FORMAT_RGB332, /* RRRG GGBB */ + MESA_FORMAT_A8, /* AAAA AAAA */ + MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */ + MESA_FORMAT_L8, /* LLLL LLLL */ + MESA_FORMAT_L16, /* LLLL LLLL LLLL LLLL */ + MESA_FORMAT_I8, /* IIII IIII */ + MESA_FORMAT_I16, /* IIII IIII IIII IIII */ + MESA_FORMAT_CI8, /* CCCC CCCC */ + MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ + MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ + MESA_FORMAT_R8, /* RRRR RRRR */ + MESA_FORMAT_RG88, /* RRRR RRRR GGGG GGGG */ + MESA_FORMAT_RG88_REV, /* GGGG GGGG RRRR RRRR */ + MESA_FORMAT_R16, /* RRRR RRRR RRRR RRRR */ + MESA_FORMAT_RG1616, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */ + MESA_FORMAT_RG1616_REV, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ + MESA_FORMAT_ARGB2101010, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */ + MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */ + MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_X8_Z24, /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_Z24_X8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */ + MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_S8, /* SSSS SSSS */ + /*@}*/ + + /** + * \name 8-bit/channel sRGB formats + */ + /*@{*/ + MESA_FORMAT_SRGB8, + MESA_FORMAT_SRGBA8, + MESA_FORMAT_SARGB8, + MESA_FORMAT_SL8, + MESA_FORMAT_SLA8, + MESA_FORMAT_SRGB_DXT1, + MESA_FORMAT_SRGBA_DXT1, + MESA_FORMAT_SRGBA_DXT3, + MESA_FORMAT_SRGBA_DXT5, + /*@}*/ + + /** + * \name Compressed texture formats. + */ + /*@{*/ + MESA_FORMAT_RGB_FXT1, + MESA_FORMAT_RGBA_FXT1, + MESA_FORMAT_RGB_DXT1, + MESA_FORMAT_RGBA_DXT1, + MESA_FORMAT_RGBA_DXT3, + MESA_FORMAT_RGBA_DXT5, + /*@}*/ + + /** + * \name Floating point texture formats. + */ + /*@{*/ + MESA_FORMAT_RGBA_FLOAT32, + MESA_FORMAT_RGBA_FLOAT16, + MESA_FORMAT_RGB_FLOAT32, + MESA_FORMAT_RGB_FLOAT16, + MESA_FORMAT_ALPHA_FLOAT32, + MESA_FORMAT_ALPHA_FLOAT16, + MESA_FORMAT_LUMINANCE_FLOAT32, + MESA_FORMAT_LUMINANCE_FLOAT16, + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + MESA_FORMAT_INTENSITY_FLOAT32, + MESA_FORMAT_INTENSITY_FLOAT16, + /*@}*/ + + /** + * \name Non-normalized signed integer formats. + * XXX Note: these are just stand-ins for some better hardware + * formats TBD such as BGRA or ARGB. + */ + MESA_FORMAT_RGBA_INT8, + MESA_FORMAT_RGBA_INT16, + MESA_FORMAT_RGBA_INT32, + + /** + * \name Non-normalized unsigned integer formats. + */ + MESA_FORMAT_RGBA_UINT8, + MESA_FORMAT_RGBA_UINT16, + MESA_FORMAT_RGBA_UINT32, + + /* msb <------ TEXEL BITS -----------> lsb */ + /* ---- ---- ---- ---- ---- ---- ---- ---- */ + /** + * \name Signed fixed point texture formats. + */ + /*@{*/ + MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */ + MESA_FORMAT_SIGNED_R8, /* RRRR RRRR */ + MESA_FORMAT_SIGNED_RG88, /* RRRR RRRR GGGG GGGG */ + MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */ + MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ + MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_SIGNED_R_16, /* ushort[0]=R */ + MESA_FORMAT_SIGNED_RG_16, /* ushort[0]=R, ushort[1]=G */ + MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */ + MESA_FORMAT_SIGNED_RGBA_16, /* ... */ + MESA_FORMAT_RGBA_16, /* ... */ + /*@}*/ + + /*@{*/ + MESA_FORMAT_RED_RGTC1, + MESA_FORMAT_SIGNED_RED_RGTC1, + MESA_FORMAT_RG_RGTC2, + MESA_FORMAT_SIGNED_RG_RGTC2, + /*@}*/ + MESA_FORMAT_COUNT +} gl_format; + + +extern const char * +_mesa_get_format_name(gl_format format); + +extern GLuint +_mesa_get_format_bytes(gl_format format); + +extern GLint +_mesa_get_format_bits(gl_format format, GLenum pname); + +extern GLenum +_mesa_get_format_datatype(gl_format format); + +extern GLenum +_mesa_get_format_base_format(gl_format format); + +extern void +_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh); + +extern GLboolean +_mesa_is_format_compressed(gl_format format); + +extern GLboolean +_mesa_is_format_packed_depth_stencil(gl_format format); + +extern GLboolean +_mesa_is_format_integer_color(gl_format format); + +extern GLenum +_mesa_get_format_color_encoding(gl_format format); + +extern GLuint +_mesa_format_image_size(gl_format format, GLsizei width, + GLsizei height, GLsizei depth); + +extern uint64_t +_mesa_format_image_size64(gl_format format, GLsizei width, + GLsizei height, GLsizei depth); + +extern GLint +_mesa_format_row_stride(gl_format format, GLsizei width); + +extern void +_mesa_format_to_type_and_comps(gl_format format, + GLenum *datatype, GLuint *comps); + +extern void +_mesa_test_formats(void); + +extern gl_format +_mesa_get_srgb_format_linear(gl_format format); + +#endif /* FORMATS_H */ diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c index eaebb06d3..82d02ed0e 100644 --- a/mesalib/src/mesa/main/texcompress.c +++ b/mesalib/src/mesa/main/texcompress.c @@ -1,249 +1,269 @@ -/*
- * Mesa 3-D graphics library
- * Version: 6.5.1
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- * Copyright (c) 2008 VMware, Inc.
- *
- * 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
- * BRIAN PAUL 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.
- */
-
-
-/**
- * \file texcompress.c
- * Helper functions for texture compression.
- */
-
-
-#include "glheader.h"
-#include "imports.h"
-#include "colormac.h"
-#include "formats.h"
-#include "mfeatures.h"
-#include "mtypes.h"
-#include "texcompress.h"
-
-
-/**
- * Return list of (and count of) all specific texture compression
- * formats that are supported.
- *
- * \param ctx the GL context
- * \param formats the resulting format list (may be NULL).
- * \param all if true return all formats, even those with some kind
- * of restrictions/limitations (See GL_ARB_texture_compression
- * spec for more info).
- *
- * \return number of formats.
- */
-GLuint
-_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats, GLboolean all)
-{
- GLuint n = 0;
- if (ctx->Extensions.TDFX_texture_compression_FXT1) {
- if (formats) {
- formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX;
- formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX;
- }
- else {
- n += 2;
- }
- }
- if (ctx->Extensions.EXT_texture_compression_s3tc) {
- if (formats) {
- formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
- /* This format has some restrictions/limitations and so should
- * not be returned via the GL_COMPRESSED_TEXTURE_FORMATS query.
- * Specifically, all transparent pixels become black. NVIDIA
- * omits this format too.
- */
- if (all)
- formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
- formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
- }
- else {
- n += 3;
- if (all)
- n += 1;
- }
- }
- if (ctx->Extensions.S3_s3tc) {
- if (formats) {
- formats[n++] = GL_RGB_S3TC;
- formats[n++] = GL_RGB4_S3TC;
- formats[n++] = GL_RGBA_S3TC;
- formats[n++] = GL_RGBA4_S3TC;
- }
- else {
- n += 4;
- }
- }
-#if FEATURE_EXT_texture_sRGB
- if (ctx->Extensions.EXT_texture_sRGB) {
- if (formats) {
- formats[n++] = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT;
- formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
- formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
- formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
- }
- else {
- n += 4;
- }
- }
-#endif /* FEATURE_EXT_texture_sRGB */
- return n;
-
-#if FEATURE_ES1 || FEATURE_ES2
- if (formats) {
- formats[n++] = GL_PALETTE4_RGB8_OES;
- formats[n++] = GL_PALETTE4_RGBA8_OES;
- formats[n++] = GL_PALETTE4_R5_G6_B5_OES;
- formats[n++] = GL_PALETTE4_RGBA4_OES;
- formats[n++] = GL_PALETTE4_RGB5_A1_OES;
- formats[n++] = GL_PALETTE8_RGB8_OES;
- formats[n++] = GL_PALETTE8_RGBA8_OES;
- formats[n++] = GL_PALETTE8_R5_G6_B5_OES;
- formats[n++] = GL_PALETTE8_RGBA4_OES;
- formats[n++] = GL_PALETTE8_RGB5_A1_OES;
- }
- else {
- n += 10;
- }
-#endif
-}
-
-
-/**
- * Convert a compressed MESA_FORMAT_x to a GLenum.
- */
-gl_format
-_mesa_glenum_to_compressed_format(GLenum format)
-{
- switch (format) {
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- return MESA_FORMAT_RGB_FXT1;
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
- return MESA_FORMAT_RGBA_FXT1;
-
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_RGB_S3TC:
- return MESA_FORMAT_RGB_DXT1;
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_RGB4_S3TC:
- return MESA_FORMAT_RGBA_DXT1;
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_RGBA_S3TC:
- return MESA_FORMAT_RGBA_DXT3;
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- case GL_RGBA4_S3TC:
- return MESA_FORMAT_RGBA_DXT5;
-
- case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
- return MESA_FORMAT_SRGB_DXT1;
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
- return MESA_FORMAT_SRGBA_DXT1;
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
- return MESA_FORMAT_SRGBA_DXT3;
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
- return MESA_FORMAT_SRGBA_DXT5;
-
- default:
- return MESA_FORMAT_NONE;
- }
-}
-
-
-/**
- * Given a compressed MESA_FORMAT_x value, return the corresponding
- * GLenum for that format.
- * This is needed for glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT)
- * which must return the specific texture format used when the user might
- * have originally specified a generic compressed format in their
- * glTexImage2D() call.
- * For non-compressed textures, we always return the user-specified
- * internal format unchanged.
- */
-GLenum
-_mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat)
-{
- switch (mesaFormat) {
-#if FEATURE_texture_fxt1
- case MESA_FORMAT_RGB_FXT1:
- return GL_COMPRESSED_RGB_FXT1_3DFX;
- case MESA_FORMAT_RGBA_FXT1:
- return GL_COMPRESSED_RGBA_FXT1_3DFX;
-#endif
-#if FEATURE_texture_s3tc
- case MESA_FORMAT_RGB_DXT1:
- return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
- case MESA_FORMAT_RGBA_DXT1:
- return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- case MESA_FORMAT_RGBA_DXT3:
- return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
- case MESA_FORMAT_RGBA_DXT5:
- return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
-#if FEATURE_EXT_texture_sRGB
- case MESA_FORMAT_SRGB_DXT1:
- return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT;
- case MESA_FORMAT_SRGBA_DXT1:
- return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
- case MESA_FORMAT_SRGBA_DXT3:
- return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
- case MESA_FORMAT_SRGBA_DXT5:
- return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
-#endif
-#endif
- default:
- _mesa_problem(ctx, "Unexpected mesa texture format in"
- " _mesa_compressed_format_to_glenum()");
- return 0;
- }
-}
-
-
-/*
- * Return the address of the pixel at (col, row, img) in a
- * compressed texture image.
- * \param col, row, img - image position (3D), should be a multiple of the
- * format's block size.
- * \param format - compressed image format
- * \param width - image width (stride) in pixels
- * \param image - the image address
- * \return address of pixel at (row, col, img)
- */
-GLubyte *
-_mesa_compressed_image_address(GLint col, GLint row, GLint img,
- gl_format mesaFormat,
- GLsizei width, const GLubyte *image)
-{
- /* XXX only 2D images implemented, not 3D */
- const GLuint blockSize = _mesa_get_format_bytes(mesaFormat);
- GLuint bw, bh;
- GLint offset;
-
- _mesa_get_format_block_size(mesaFormat, &bw, &bh);
-
- ASSERT(col % bw == 0);
- ASSERT(row % bh == 0);
-
- offset = ((width + bw - 1) / bw) * (row / bh) + col / bw;
- offset *= blockSize;
-
- return (GLubyte *) image + offset;
-}
+/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, Inc. + * + * 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 + * BRIAN PAUL 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. + */ + + +/** + * \file texcompress.c + * Helper functions for texture compression. + */ + + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "formats.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "texcompress.h" + + +/** + * Return list of (and count of) all specific texture compression + * formats that are supported. + * + * \param ctx the GL context + * \param formats the resulting format list (may be NULL). + * \param all if true return all formats, even those with some kind + * of restrictions/limitations (See GL_ARB_texture_compression + * spec for more info). + * + * \return number of formats. + */ +GLuint +_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats, GLboolean all) +{ + GLuint n = 0; + if (ctx->Extensions.TDFX_texture_compression_FXT1) { + if (formats) { + formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX; + formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX; + } + else { + n += 2; + } + } + /* don't return RGTC - ARB_texture_compression_rgtc query 19 */ + if (ctx->Extensions.EXT_texture_compression_s3tc) { + if (formats) { + formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + /* This format has some restrictions/limitations and so should + * not be returned via the GL_COMPRESSED_TEXTURE_FORMATS query. + * Specifically, all transparent pixels become black. NVIDIA + * omits this format too. + */ + if (all) + formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + } + else { + n += 3; + if (all) + n += 1; + } + } + if (ctx->Extensions.S3_s3tc) { + if (formats) { + formats[n++] = GL_RGB_S3TC; + formats[n++] = GL_RGB4_S3TC; + formats[n++] = GL_RGBA_S3TC; + formats[n++] = GL_RGBA4_S3TC; + } + else { + n += 4; + } + } +#if FEATURE_EXT_texture_sRGB + if (ctx->Extensions.EXT_texture_sRGB) { + if (formats) { + formats[n++] = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; + formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + } + else { + n += 4; + } + } +#endif /* FEATURE_EXT_texture_sRGB */ + return n; + +#if FEATURE_ES1 || FEATURE_ES2 + if (formats) { + formats[n++] = GL_PALETTE4_RGB8_OES; + formats[n++] = GL_PALETTE4_RGBA8_OES; + formats[n++] = GL_PALETTE4_R5_G6_B5_OES; + formats[n++] = GL_PALETTE4_RGBA4_OES; + formats[n++] = GL_PALETTE4_RGB5_A1_OES; + formats[n++] = GL_PALETTE8_RGB8_OES; + formats[n++] = GL_PALETTE8_RGBA8_OES; + formats[n++] = GL_PALETTE8_R5_G6_B5_OES; + formats[n++] = GL_PALETTE8_RGBA4_OES; + formats[n++] = GL_PALETTE8_RGB5_A1_OES; + } + else { + n += 10; + } +#endif +} + + +/** + * Convert a compressed MESA_FORMAT_x to a GLenum. + */ +gl_format +_mesa_glenum_to_compressed_format(GLenum format) +{ + switch (format) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + return MESA_FORMAT_RGB_FXT1; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return MESA_FORMAT_RGBA_FXT1; + + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_RGB_S3TC: + return MESA_FORMAT_RGB_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_RGB4_S3TC: + return MESA_FORMAT_RGBA_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_RGBA_S3TC: + return MESA_FORMAT_RGBA_DXT3; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + case GL_RGBA4_S3TC: + return MESA_FORMAT_RGBA_DXT5; + + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + return MESA_FORMAT_SRGB_DXT1; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + return MESA_FORMAT_SRGBA_DXT1; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + return MESA_FORMAT_SRGBA_DXT3; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return MESA_FORMAT_SRGBA_DXT5; + + case GL_COMPRESSED_RED_RGTC1: + return MESA_FORMAT_RED_RGTC1; + case GL_COMPRESSED_SIGNED_RED_RGTC1: + return MESA_FORMAT_SIGNED_RED_RGTC1; + case GL_COMPRESSED_RG_RGTC2: + return MESA_FORMAT_RG_RGTC2; + case GL_COMPRESSED_SIGNED_RG_RGTC2: + return MESA_FORMAT_SIGNED_RG_RGTC2; + + default: + return MESA_FORMAT_NONE; + } +} + + +/** + * Given a compressed MESA_FORMAT_x value, return the corresponding + * GLenum for that format. + * This is needed for glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT) + * which must return the specific texture format used when the user might + * have originally specified a generic compressed format in their + * glTexImage2D() call. + * For non-compressed textures, we always return the user-specified + * internal format unchanged. + */ +GLenum +_mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat) +{ + switch (mesaFormat) { +#if FEATURE_texture_fxt1 + case MESA_FORMAT_RGB_FXT1: + return GL_COMPRESSED_RGB_FXT1_3DFX; + case MESA_FORMAT_RGBA_FXT1: + return GL_COMPRESSED_RGBA_FXT1_3DFX; +#endif +#if FEATURE_texture_s3tc + case MESA_FORMAT_RGB_DXT1: + return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + case MESA_FORMAT_RGBA_DXT1: + return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + case MESA_FORMAT_RGBA_DXT3: + return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + case MESA_FORMAT_RGBA_DXT5: + return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB_DXT1: + return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; + case MESA_FORMAT_SRGBA_DXT1: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + case MESA_FORMAT_SRGBA_DXT3: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + case MESA_FORMAT_SRGBA_DXT5: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; +#endif +#endif + + case MESA_FORMAT_RED_RGTC1: + return GL_COMPRESSED_RED_RGTC1; + case MESA_FORMAT_SIGNED_RED_RGTC1: + return GL_COMPRESSED_SIGNED_RED_RGTC1; + case MESA_FORMAT_RG_RGTC2: + return GL_COMPRESSED_RG_RGTC2; + case MESA_FORMAT_SIGNED_RG_RGTC2: + return GL_COMPRESSED_SIGNED_RG_RGTC2; + + default: + _mesa_problem(ctx, "Unexpected mesa texture format in" + " _mesa_compressed_format_to_glenum()"); + return 0; + } +} + + +/* + * Return the address of the pixel at (col, row, img) in a + * compressed texture image. + * \param col, row, img - image position (3D), should be a multiple of the + * format's block size. + * \param format - compressed image format + * \param width - image width (stride) in pixels + * \param image - the image address + * \return address of pixel at (row, col, img) + */ +GLubyte * +_mesa_compressed_image_address(GLint col, GLint row, GLint img, + gl_format mesaFormat, + GLsizei width, const GLubyte *image) +{ + /* XXX only 2D images implemented, not 3D */ + const GLuint blockSize = _mesa_get_format_bytes(mesaFormat); + GLuint bw, bh; + GLint offset; + + _mesa_get_format_block_size(mesaFormat, &bw, &bh); + + ASSERT(col % bw == 0); + ASSERT(row % bh == 0); + + offset = ((width + bw - 1) / bw) * (row / bh) + col / bw; + offset *= blockSize; + + return (GLubyte *) image + offset; +} diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c new file mode 100644 index 000000000..b7725f4a9 --- /dev/null +++ b/mesalib/src/mesa/main/texcompress_rgtc.c @@ -0,0 +1,1122 @@ +/* + * Copyright (C) 2011 Red Hat Inc. + * + * block compression parts are: + * Copyright (C) 2004 Roland Scheidegger 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. + * + * Author: + * Dave Airlie + */ + +/** + * \file texcompress_rgtc.c + * GL_EXT_texture_compression_rgtc support. + */ + + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "image.h" +#include "macros.h" +#include "mfeatures.h" +#include "mipmap.h" +#include "texcompress.h" +#include "texcompress_rgtc.h" +#include "texstore.h" + +#define RGTC_DEBUG 0 + +static void encode_rgtc_chan_u(GLubyte *blkaddr, GLubyte srccolors[4][4], + GLint numxpixels, GLint numypixels); +static void encode_rgtc_chan_s(GLbyte *blkaddr, GLbyte srccolors[4][4], + GLint numxpixels, GLint numypixels); + +static void extractsrc_u( GLubyte srcpixels[4][4], const GLchan *srcaddr, + GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps) +{ + GLubyte i, j; + const GLchan *curaddr; + for (j = 0; j < numypixels; j++) { + curaddr = srcaddr + j * srcRowStride * comps; + for (i = 0; i < numxpixels; i++) { + srcpixels[j][i] = *curaddr / (CHAN_MAX / 255); + curaddr += comps; + } + } +} + +static void extractsrc_s( GLbyte srcpixels[4][4], const GLfloat *srcaddr, + GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps) +{ + GLubyte i, j; + const GLfloat *curaddr; + for (j = 0; j < numypixels; j++) { + curaddr = srcaddr + j * srcRowStride * comps; + for (i = 0; i < numxpixels; i++) { + srcpixels[j][i] = FLOAT_TO_BYTE_TEX(*curaddr); + curaddr += comps; + } + } +} + + +GLboolean +_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS) +{ + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ + const GLchan *tempImage = NULL; + int i, j; + int numxpixels, numypixels; + const void *srcaddr; + GLubyte srcpixels[4][4]; + GLubyte *blkaddr; + GLint dstRowDiff; + ASSERT(dstFormat == MESA_FORMAT_RED_RGTC1); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + blkaddr = dst; + dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0; + for (j = 0; j < srcHeight; j+=4) { + if (srcHeight > j + 3) numypixels = 4; + else numypixels = srcHeight - j; + srcaddr = tempImage + j * srcWidth; + for (i = 0; i < srcWidth; i += 4) { + if (srcWidth > i + 3) numxpixels = 4; + else numxpixels = srcWidth - i; + extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1); + encode_rgtc_chan_u(blkaddr, srcpixels, numxpixels, numypixels); + srcaddr += numxpixels; + blkaddr += 8; + } + blkaddr += dstRowDiff; + } + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + +GLboolean +_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS) +{ + GLbyte *dst; + const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ + const GLfloat *tempImage = NULL; + int i, j; + int numxpixels, numypixels; + const GLfloat *srcaddr; + GLbyte srcpixels[4][4]; + GLbyte *blkaddr; + GLint dstRowDiff; + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RED_RGTC1); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + if (!tempImage) + return GL_FALSE; /* out of memory */ + + dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + blkaddr = dst; + dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0; + for (j = 0; j < srcHeight; j+=4) { + if (srcHeight > j + 3) numypixels = 4; + else numypixels = srcHeight - j; + srcaddr = tempImage + j * srcWidth; + for (i = 0; i < srcWidth; i += 4) { + if (srcWidth > i + 3) numxpixels = 4; + else numxpixels = srcWidth - i; + extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1); + encode_rgtc_chan_s(blkaddr, srcpixels, numxpixels, numypixels); + srcaddr += numxpixels; + blkaddr += 8; + } + blkaddr += dstRowDiff; + } + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + +GLboolean +_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS) +{ + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ + const GLchan *tempImage = NULL; + int i, j; + int numxpixels, numypixels; + const void *srcaddr; + GLubyte srcpixels[4][4]; + GLubyte *blkaddr; + GLint dstRowDiff; + + ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + blkaddr = dst; + dstRowDiff = dstRowStride >= (srcWidth * 8) ? dstRowStride - (((srcWidth + 7) & ~7) * 8) : 0; + for (j = 0; j < srcHeight; j+=4) { + if (srcHeight > j + 3) numypixels = 4; + else numypixels = srcHeight - j; + srcaddr = tempImage + j * srcWidth * 2; + for (i = 0; i < srcWidth; i += 4) { + if (srcWidth > i + 3) numxpixels = 4; + else numxpixels = srcWidth - i; + extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2); + encode_rgtc_chan_u(blkaddr, srcpixels, numxpixels, numypixels); + + blkaddr += 8; + extractsrc_u(srcpixels, (GLchan *)srcaddr + 1, srcWidth, numxpixels, numypixels, 2); + encode_rgtc_chan_u(blkaddr, srcpixels, numxpixels, numypixels); + + blkaddr += 8; + + srcaddr += numxpixels * 2; + } + blkaddr += dstRowDiff; + } + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + +GLboolean +_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS) +{ + GLbyte *dst; + const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ + const GLfloat *tempImage = NULL; + int i, j; + int numxpixels, numypixels; + const GLfloat *srcaddr; + GLbyte srcpixels[4][4]; + GLbyte *blkaddr; + GLint dstRowDiff; + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG_RGTC2); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + if (!tempImage) + return GL_FALSE; /* out of memory */ + + dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + blkaddr = dst; + dstRowDiff = dstRowStride >= (srcWidth * 8) ? dstRowStride - (((srcWidth + 7) & ~7) * 8) : 0; + for (j = 0; j < srcHeight; j += 4) { + if (srcHeight > j + 3) numypixels = 4; + else numypixels = srcHeight - j; + srcaddr = tempImage + j * srcWidth * 2; + for (i = 0; i < srcWidth; i += 4) { + if (srcWidth > i + 3) numxpixels = 4; + else numxpixels = srcWidth - i; + + extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2); + encode_rgtc_chan_s(blkaddr, srcpixels, numxpixels, numypixels); + blkaddr += 8; + + extractsrc_s(srcpixels, srcaddr + 1, srcWidth, numxpixels, numypixels, 2); + encode_rgtc_chan_s(blkaddr, srcpixels, numxpixels, numypixels); + blkaddr += 8; + + srcaddr += numxpixels * 2; + + } + blkaddr += dstRowDiff; + } + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + +static void _fetch_texel_rgtc_u(GLint srcRowStride, const GLubyte *pixdata, + GLint i, GLint j, GLchan *value, int comps) +{ + GLchan decode; + const GLubyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 8 * comps); + const GLubyte alpha0 = blksrc[0]; + const GLubyte alpha1 = blksrc[1]; + const GLubyte bit_pos = ((j&3) * 4 + (i&3)) * 3; + const GLubyte acodelow = blksrc[2 + bit_pos / 8]; + const GLubyte acodehigh = blksrc[3 + bit_pos / 8]; + const GLubyte code = (acodelow >> (bit_pos & 0x7) | + (acodehigh << (8 - (bit_pos & 0x7)))) & 0x7; + + if (code == 0) + decode = UBYTE_TO_CHAN( alpha0 ); + else if (code == 1) + decode = UBYTE_TO_CHAN( alpha1 ); + else if (alpha0 > alpha1) + decode = UBYTE_TO_CHAN( ((alpha0 * (8 - code) + (alpha1 * (code - 1))) / 7) ); + else if (code < 6) + decode = UBYTE_TO_CHAN( ((alpha0 * (6 - code) + (alpha1 * (code - 1))) / 5) ); + else if (code == 6) + decode = 0; + else + decode = CHAN_MAX; + + *value = decode; +} + + +static void _fetch_texel_rgtc_s(GLint srcRowStride, const GLbyte *pixdata, + GLint i, GLint j, GLbyte *value, int comps) +{ + GLbyte decode; + const GLbyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 8 * comps); + const GLbyte alpha0 = blksrc[0]; + const GLbyte alpha1 = blksrc[1]; + const GLbyte bit_pos = ((j&3) * 4 + (i&3)) * 3; + const GLbyte acodelow = blksrc[2 + bit_pos / 8]; + const GLbyte acodehigh = blksrc[3 + bit_pos / 8]; + const GLbyte code = (acodelow >> (bit_pos & 0x7) | + (acodehigh << (8 - (bit_pos & 0x7)))) & 0x7; + + if (code == 0) + decode = alpha0; + else if (code == 1) + decode = alpha1; + else if (alpha0 > alpha1) + decode = ((alpha0 * (8 - code) + (alpha1 * (code - 1))) / 7); + else if (code < 6) + decode = ((alpha0 * (6 - code) + (alpha1 * (code - 1))) / 5); + else if (code == 6) + decode = -128; + else + decode = 127; + + *value = decode; +} + +void +_mesa_fetch_texel_2d_f_red_rgtc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + GLchan red; + _fetch_texel_rgtc_u(texImage->RowStride, (GLubyte *)(texImage->Data), + i, j, &red, 1); + texel[RCOMP] = CHAN_TO_FLOAT(red); + texel[GCOMP] = 0.0; + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +void +_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + GLbyte red; + _fetch_texel_rgtc_s(texImage->RowStride, (GLbyte *)(texImage->Data), + i, j, &red, 1); + texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); + texel[GCOMP] = 0.0; + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +void +_mesa_fetch_texel_2d_f_rg_rgtc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + GLchan red, green; + _fetch_texel_rgtc_u(texImage->RowStride, (GLubyte *)(texImage->Data), + i, j, &red, 2); + _fetch_texel_rgtc_u(texImage->RowStride, (GLubyte *)(texImage->Data) + 8, + i, j, &green, 2); + texel[RCOMP] = CHAN_TO_FLOAT(red); + texel[GCOMP] = CHAN_TO_FLOAT(green); + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +void +_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + GLbyte red, green; + _fetch_texel_rgtc_s(texImage->RowStride, (GLbyte *)(texImage->Data), + i, j, &red, 2); + _fetch_texel_rgtc_s(texImage->RowStride, (GLbyte *)(texImage->Data) + 8, + i, j, &green, 2); + texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); + texel[GCOMP] = BYTE_TO_FLOAT_TEX(green); + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +static void write_rgtc_encoded_channel(GLubyte *blkaddr, + GLubyte alphabase1, + GLubyte alphabase2, + GLubyte alphaenc[16]) +{ + *blkaddr++ = alphabase1; + *blkaddr++ = alphabase2; + *blkaddr++ = alphaenc[0] | (alphaenc[1] << 3) | ((alphaenc[2] & 3) << 6); + *blkaddr++ = (alphaenc[2] >> 2) | (alphaenc[3] << 1) | (alphaenc[4] << 4) | ((alphaenc[5] & 1) << 7); + *blkaddr++ = (alphaenc[5] >> 1) | (alphaenc[6] << 2) | (alphaenc[7] << 5); + *blkaddr++ = alphaenc[8] | (alphaenc[9] << 3) | ((alphaenc[10] & 3) << 6); + *blkaddr++ = (alphaenc[10] >> 2) | (alphaenc[11] << 1) | (alphaenc[12] << 4) | ((alphaenc[13] & 1) << 7); + *blkaddr++ = (alphaenc[13] >> 1) | (alphaenc[14] << 2) | (alphaenc[15] << 5); +} + +static void encode_rgtc_chan_u(GLubyte *blkaddr, GLubyte srccolors[4][4], + GLint numxpixels, GLint numypixels) +{ + GLubyte alphabase[2], alphause[2]; + GLshort alphatest[2] = { 0 }; + GLuint alphablockerror1, alphablockerror2, alphablockerror3; + GLubyte i, j, aindex, acutValues[7]; + GLubyte alphaenc1[16], alphaenc2[16], alphaenc3[16]; + GLboolean alphaabsmin = GL_FALSE; + GLboolean alphaabsmax = GL_FALSE; + GLshort alphadist; + + /* find lowest and highest alpha value in block, alphabase[0] lowest, alphabase[1] highest */ + alphabase[0] = 0xff; alphabase[1] = 0x0; + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if (srccolors[j][i] == 0) + alphaabsmin = GL_TRUE; + else if (srccolors[j][i] == 255) + alphaabsmax = GL_TRUE; + else { + if (srccolors[j][i] > alphabase[1]) + alphabase[1] = srccolors[j][i]; + if (srccolors[j][i] < alphabase[0]) + alphabase[0] = srccolors[j][i]; + } + } + } + + + if ((alphabase[0] > alphabase[1]) && !(alphaabsmin && alphaabsmax)) { /* one color, either max or min */ + /* shortcut here since it is a very common case (and also avoids later problems) */ + /* || (alphabase[0] == alphabase[1] && !alphaabsmin && !alphaabsmax) */ + /* could also thest for alpha0 == alpha1 (and not min/max), but probably not common, so don't bother */ + + *blkaddr++ = srccolors[0][0]; + blkaddr++; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; +#if RGTC_DEBUG + fprintf(stderr, "enc0 used\n"); +#endif + return; + } + + /* find best encoding for alpha0 > alpha1 */ + /* it's possible this encoding is better even if both alphaabsmin and alphaabsmax are true */ + alphablockerror1 = 0x0; + alphablockerror2 = 0xffffffff; + alphablockerror3 = 0xffffffff; + if (alphaabsmin) alphause[0] = 0; + else alphause[0] = alphabase[0]; + if (alphaabsmax) alphause[1] = 255; + else alphause[1] = alphabase[1]; + /* calculate the 7 cut values, just the middle between 2 of the computed alpha values */ + for (aindex = 0; aindex < 7; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphause[0] * (2*aindex + 1) + alphause[1] * (14 - (2*aindex + 1))) / 14; + } + + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] > acutValues[0]) { + alphaenc1[4*j + i] = 0; + alphadist = srccolors[j][i] - alphause[1]; + } + else if (srccolors[j][i] > acutValues[1]) { + alphaenc1[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphause[1] * 6 + alphause[0] * 1) / 7; + } + else if (srccolors[j][i] > acutValues[2]) { + alphaenc1[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphause[1] * 5 + alphause[0] * 2) / 7; + } + else if (srccolors[j][i] > acutValues[3]) { + alphaenc1[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphause[1] * 4 + alphause[0] * 3) / 7; + } + else if (srccolors[j][i] > acutValues[4]) { + alphaenc1[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphause[1] * 3 + alphause[0] * 4) / 7; + } + else if (srccolors[j][i] > acutValues[5]) { + alphaenc1[4*j + i] = 6; + alphadist = srccolors[j][i] - (alphause[1] * 2 + alphause[0] * 5) / 7; + } + else if (srccolors[j][i] > acutValues[6]) { + alphaenc1[4*j + i] = 7; + alphadist = srccolors[j][i] - (alphause[1] * 1 + alphause[0] * 6) / 7; + } + else { + alphaenc1[4*j + i] = 1; + alphadist = srccolors[j][i] - alphause[0]; + } + alphablockerror1 += alphadist * alphadist; + } + } + +#if RGTC_DEBUG + for (i = 0; i < 16; i++) { + fprintf(stderr, "%d ", alphaenc1[i]); + } + fprintf(stderr, "cutVals "); + for (i = 0; i < 8; i++) { + fprintf(stderr, "%d ", acutValues[i]); + } + fprintf(stderr, "srcVals "); + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + fprintf(stderr, "%d ", srccolors[j][i]); + } + } + fprintf(stderr, "\n"); +#endif + + /* it's not very likely this encoding is better if both alphaabsmin and alphaabsmax + are false but try it anyway */ + if (alphablockerror1 >= 32) { + + /* don't bother if encoding is already very good, this condition should also imply + we have valid alphabase colors which we absolutely need (alphabase[0] <= alphabase[1]) */ + alphablockerror2 = 0; + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphabase[0] * (10 - (2*aindex + 1)) + alphabase[1] * (2*aindex + 1)) / 10; + } + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] == 0) { + alphaenc2[4*j + i] = 6; + alphadist = 0; + } + else if (srccolors[j][i] == 255) { + alphaenc2[4*j + i] = 7; + alphadist = 0; + } + else if (srccolors[j][i] <= acutValues[0]) { + alphaenc2[4*j + i] = 0; + alphadist = srccolors[j][i] - alphabase[0]; + } + else if (srccolors[j][i] <= acutValues[1]) { + alphaenc2[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphabase[0] * 4 + alphabase[1] * 1) / 5; + } + else if (srccolors[j][i] <= acutValues[2]) { + alphaenc2[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphabase[0] * 3 + alphabase[1] * 2) / 5; + } + else if (srccolors[j][i] <= acutValues[3]) { + alphaenc2[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphabase[0] * 2 + alphabase[1] * 3) / 5; + } + else if (srccolors[j][i] <= acutValues[4]) { + alphaenc2[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphabase[0] * 1 + alphabase[1] * 4) / 5; + } + else { + alphaenc2[4*j + i] = 1; + alphadist = srccolors[j][i] - alphabase[1]; + } + alphablockerror2 += alphadist * alphadist; + } + } + + + /* skip this if the error is already very small + this encoding is MUCH better on average than #2 though, but expensive! */ + if ((alphablockerror2 > 96) && (alphablockerror1 > 96)) { + GLshort blockerrlin1 = 0; + GLshort blockerrlin2 = 0; + GLubyte nralphainrangelow = 0; + GLubyte nralphainrangehigh = 0; + alphatest[0] = 0xff; + alphatest[1] = 0x0; + /* if we have large range it's likely there are values close to 0/255, try to map them to 0/255 */ + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if ((srccolors[j][i] > alphatest[1]) && (srccolors[j][i] < (255 -(alphabase[1] - alphabase[0]) / 28))) + alphatest[1] = srccolors[j][i]; + if ((srccolors[j][i] < alphatest[0]) && (srccolors[j][i] > (alphabase[1] - alphabase[0]) / 28)) + alphatest[0] = srccolors[j][i]; + } + } + /* shouldn't happen too often, don't really care about those degenerated cases */ + if (alphatest[1] <= alphatest[0]) { + alphatest[0] = 1; + alphatest[1] = 254; + } + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; + } + + /* find the "average" difference between the alpha values and the next encoded value. + This is then used to calculate new base values. + Should there be some weighting, i.e. those values closer to alphatest[x] have more weight, + since they will see more improvement, and also because the values in the middle are somewhat + likely to get no improvement at all (because the base values might move in different directions)? + OTOH it would mean the values in the middle are even less likely to get an improvement + */ + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if (srccolors[j][i] <= alphatest[0] / 2) { + } + else if (srccolors[j][i] > ((255 + alphatest[1]) / 2)) { + } + else if (srccolors[j][i] <= acutValues[0]) { + blockerrlin1 += (srccolors[j][i] - alphatest[0]); + nralphainrangelow += 1; + } + else if (srccolors[j][i] <= acutValues[1]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[2]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[3]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[4]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else { + blockerrlin2 += (srccolors[j][i] - alphatest[1]); + nralphainrangehigh += 1; + } + } + } + /* shouldn't happen often, needed to avoid div by zero */ + if (nralphainrangelow == 0) nralphainrangelow = 1; + if (nralphainrangehigh == 0) nralphainrangehigh = 1; + alphatest[0] = alphatest[0] + (blockerrlin1 / nralphainrangelow); +#if RGTC_DEBUG + fprintf(stderr, "block err lin low %d, nr %d\n", blockerrlin1, nralphainrangelow); + fprintf(stderr, "block err lin high %d, nr %d\n", blockerrlin2, nralphainrangehigh); +#endif + /* again shouldn't really happen often... */ + if (alphatest[0] < 0) { + alphatest[0] = 0; + } + alphatest[1] = alphatest[1] + (blockerrlin2 / nralphainrangehigh); + if (alphatest[1] > 255) { + alphatest[1] = 255; + } + + alphablockerror3 = 0; + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; + } + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] <= alphatest[0] / 2) { + alphaenc3[4*j + i] = 6; + alphadist = srccolors[j][i]; + } + else if (srccolors[j][i] > ((255 + alphatest[1]) / 2)) { + alphaenc3[4*j + i] = 7; + alphadist = 255 - srccolors[j][i]; + } + else if (srccolors[j][i] <= acutValues[0]) { + alphaenc3[4*j + i] = 0; + alphadist = srccolors[j][i] - alphatest[0]; + } + else if (srccolors[j][i] <= acutValues[1]) { + alphaenc3[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5; + } + else if (srccolors[j][i] <= acutValues[2]) { + alphaenc3[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5; + } + else if (srccolors[j][i] <= acutValues[3]) { + alphaenc3[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5; + } + else if (srccolors[j][i] <= acutValues[4]) { + alphaenc3[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5; + } + else { + alphaenc3[4*j + i] = 1; + alphadist = srccolors[j][i] - alphatest[1]; + } + alphablockerror3 += alphadist * alphadist; + } + } + } + } + /* write the alpha values and encoding back. */ + if ((alphablockerror1 <= alphablockerror2) && (alphablockerror1 <= alphablockerror3)) { +#if RGTC_DEBUG + if (alphablockerror1 > 96) fprintf(stderr, "enc1 used, error %d\n", alphablockerror1); +#endif + write_rgtc_encoded_channel( blkaddr, alphause[1], alphause[0], alphaenc1 ); + } + else if (alphablockerror2 <= alphablockerror3) { +#if RGTC_DEBUG + if (alphablockerror2 > 96) fprintf(stderr, "enc2 used, error %d\n", alphablockerror2); +#endif + write_rgtc_encoded_channel( blkaddr, alphabase[0], alphabase[1], alphaenc2 ); + } + else { +#if RGTC_DEBUG + fprintf(stderr, "enc3 used, error %d\n", alphablockerror3); +#endif + write_rgtc_encoded_channel( blkaddr, (GLubyte)alphatest[0], (GLubyte)alphatest[1], alphaenc3 ); + } +} + + +static void write_rgtc_encoded_channel_s(GLbyte *blkaddr, + GLbyte alphabase1, + GLbyte alphabase2, + GLbyte alphaenc[16]) +{ + *blkaddr++ = alphabase1; + *blkaddr++ = alphabase2; + *blkaddr++ = alphaenc[0] | (alphaenc[1] << 3) | ((alphaenc[2] & 3) << 6); + *blkaddr++ = (alphaenc[2] >> 2) | (alphaenc[3] << 1) | (alphaenc[4] << 4) | ((alphaenc[5] & 1) << 7); + *blkaddr++ = (alphaenc[5] >> 1) | (alphaenc[6] << 2) | (alphaenc[7] << 5); + *blkaddr++ = alphaenc[8] | (alphaenc[9] << 3) | ((alphaenc[10] & 3) << 6); + *blkaddr++ = (alphaenc[10] >> 2) | (alphaenc[11] << 1) | (alphaenc[12] << 4) | ((alphaenc[13] & 1) << 7); + *blkaddr++ = (alphaenc[13] >> 1) | (alphaenc[14] << 2) | (alphaenc[15] << 5); +} + +static void encode_rgtc_chan_s(GLbyte *blkaddr, GLbyte srccolors[4][4], + GLint numxpixels, GLint numypixels) +{ + GLbyte alphabase[2], alphause[2]; + GLshort alphatest[2] = { 0 }; + GLuint alphablockerror1, alphablockerror2, alphablockerror3; + GLbyte i, j, aindex, acutValues[7]; + GLbyte alphaenc1[16], alphaenc2[16], alphaenc3[16]; + GLboolean alphaabsmin = GL_FALSE; + GLboolean alphaabsmax = GL_FALSE; + GLshort alphadist; + + /* find lowest and highest alpha value in block, alphabase[0] lowest, alphabase[1] highest */ + alphabase[0] = 0xff; alphabase[1] = 0x0; + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if (srccolors[j][i] == 0) + alphaabsmin = GL_TRUE; + else if (srccolors[j][i] == 255) + alphaabsmax = GL_TRUE; + else { + if (srccolors[j][i] > alphabase[1]) + alphabase[1] = srccolors[j][i]; + if (srccolors[j][i] < alphabase[0]) + alphabase[0] = srccolors[j][i]; + } + } + } + + + if ((alphabase[0] > alphabase[1]) && !(alphaabsmin && alphaabsmax)) { /* one color, either max or min */ + /* shortcut here since it is a very common case (and also avoids later problems) */ + /* || (alphabase[0] == alphabase[1] && !alphaabsmin && !alphaabsmax) */ + /* could also thest for alpha0 == alpha1 (and not min/max), but probably not common, so don't bother */ + + *blkaddr++ = srccolors[0][0]; + blkaddr++; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; +#if RGTC_DEBUG + fprintf(stderr, "enc0 used\n"); +#endif + return; + } + + /* find best encoding for alpha0 > alpha1 */ + /* it's possible this encoding is better even if both alphaabsmin and alphaabsmax are true */ + alphablockerror1 = 0x0; + alphablockerror2 = 0xffffffff; + alphablockerror3 = 0xffffffff; + if (alphaabsmin) alphause[0] = 0; + else alphause[0] = alphabase[0]; + if (alphaabsmax) alphause[1] = 255; + else alphause[1] = alphabase[1]; + /* calculate the 7 cut values, just the middle between 2 of the computed alpha values */ + for (aindex = 0; aindex < 7; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphause[0] * (2*aindex + 1) + alphause[1] * (14 - (2*aindex + 1))) / 14; + } + + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] > acutValues[0]) { + alphaenc1[4*j + i] = 0; + alphadist = srccolors[j][i] - alphause[1]; + } + else if (srccolors[j][i] > acutValues[1]) { + alphaenc1[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphause[1] * 6 + alphause[0] * 1) / 7; + } + else if (srccolors[j][i] > acutValues[2]) { + alphaenc1[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphause[1] * 5 + alphause[0] * 2) / 7; + } + else if (srccolors[j][i] > acutValues[3]) { + alphaenc1[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphause[1] * 4 + alphause[0] * 3) / 7; + } + else if (srccolors[j][i] > acutValues[4]) { + alphaenc1[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphause[1] * 3 + alphause[0] * 4) / 7; + } + else if (srccolors[j][i] > acutValues[5]) { + alphaenc1[4*j + i] = 6; + alphadist = srccolors[j][i] - (alphause[1] * 2 + alphause[0] * 5) / 7; + } + else if (srccolors[j][i] > acutValues[6]) { + alphaenc1[4*j + i] = 7; + alphadist = srccolors[j][i] - (alphause[1] * 1 + alphause[0] * 6) / 7; + } + else { + alphaenc1[4*j + i] = 1; + alphadist = srccolors[j][i] - alphause[0]; + } + alphablockerror1 += alphadist * alphadist; + } + } +#if RGTC_DEBUG + for (i = 0; i < 16; i++) { + fprintf(stderr, "%d ", alphaenc1[i]); + } + fprintf(stderr, "cutVals "); + for (i = 0; i < 8; i++) { + fprintf(stderr, "%d ", acutValues[i]); + } + fprintf(stderr, "srcVals "); + for (j = 0; j < numypixels; j++) + for (i = 0; i < numxpixels; i++) { + fprintf(stderr, "%d ", srccolors[j][i]); + } + + fprintf(stderr, "\n"); +#endif + + /* it's not very likely this encoding is better if both alphaabsmin and alphaabsmax + are false but try it anyway */ + if (alphablockerror1 >= 32) { + + /* don't bother if encoding is already very good, this condition should also imply + we have valid alphabase colors which we absolutely need (alphabase[0] <= alphabase[1]) */ + alphablockerror2 = 0; + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphabase[0] * (10 - (2*aindex + 1)) + alphabase[1] * (2*aindex + 1)) / 10; + } + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] == 0) { + alphaenc2[4*j + i] = 6; + alphadist = 0; + } + else if (srccolors[j][i] == 255) { + alphaenc2[4*j + i] = 7; + alphadist = 0; + } + else if (srccolors[j][i] <= acutValues[0]) { + alphaenc2[4*j + i] = 0; + alphadist = srccolors[j][i] - alphabase[0]; + } + else if (srccolors[j][i] <= acutValues[1]) { + alphaenc2[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphabase[0] * 4 + alphabase[1] * 1) / 5; + } + else if (srccolors[j][i] <= acutValues[2]) { + alphaenc2[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphabase[0] * 3 + alphabase[1] * 2) / 5; + } + else if (srccolors[j][i] <= acutValues[3]) { + alphaenc2[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphabase[0] * 2 + alphabase[1] * 3) / 5; + } + else if (srccolors[j][i] <= acutValues[4]) { + alphaenc2[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphabase[0] * 1 + alphabase[1] * 4) / 5; + } + else { + alphaenc2[4*j + i] = 1; + alphadist = srccolors[j][i] - alphabase[1]; + } + alphablockerror2 += alphadist * alphadist; + } + } + + + /* skip this if the error is already very small + this encoding is MUCH better on average than #2 though, but expensive! */ + if ((alphablockerror2 > 96) && (alphablockerror1 > 96)) { + GLshort blockerrlin1 = 0; + GLshort blockerrlin2 = 0; + GLubyte nralphainrangelow = 0; + GLubyte nralphainrangehigh = 0; + alphatest[0] = 0xff; + alphatest[1] = 0x0; + /* if we have large range it's likely there are values close to 0/255, try to map them to 0/255 */ + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if ((srccolors[j][i] > alphatest[1]) && (srccolors[j][i] < (255 -(alphabase[1] - alphabase[0]) / 28))) + alphatest[1] = srccolors[j][i]; + if ((srccolors[j][i] < alphatest[0]) && (srccolors[j][i] > (alphabase[1] - alphabase[0]) / 28)) + alphatest[0] = srccolors[j][i]; + } + } + /* shouldn't happen too often, don't really care about those degenerated cases */ + if (alphatest[1] <= alphatest[0]) { + alphatest[0] = 1; + alphatest[1] = 254; + } + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; + } + + /* find the "average" difference between the alpha values and the next encoded value. + This is then used to calculate new base values. + Should there be some weighting, i.e. those values closer to alphatest[x] have more weight, + since they will see more improvement, and also because the values in the middle are somewhat + likely to get no improvement at all (because the base values might move in different directions)? + OTOH it would mean the values in the middle are even less likely to get an improvement + */ + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if (srccolors[j][i] <= alphatest[0] / 2) { + } + else if (srccolors[j][i] > ((255 + alphatest[1]) / 2)) { + } + else if (srccolors[j][i] <= acutValues[0]) { + blockerrlin1 += (srccolors[j][i] - alphatest[0]); + nralphainrangelow += 1; + } + else if (srccolors[j][i] <= acutValues[1]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[2]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[3]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[4]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else { + blockerrlin2 += (srccolors[j][i] - alphatest[1]); + nralphainrangehigh += 1; + } + } + } + /* shouldn't happen often, needed to avoid div by zero */ + if (nralphainrangelow == 0) nralphainrangelow = 1; + if (nralphainrangehigh == 0) nralphainrangehigh = 1; + alphatest[0] = alphatest[0] + (blockerrlin1 / nralphainrangelow); +#if RGTC_DEBUG + fprintf(stderr, "block err lin low %d, nr %d\n", blockerrlin1, nralphainrangelow); + fprintf(stderr, "block err lin high %d, nr %d\n", blockerrlin2, nralphainrangehigh); +#endif + /* again shouldn't really happen often... */ + if (alphatest[0] < 0) { + alphatest[0] = 0; + } + alphatest[1] = alphatest[1] + (blockerrlin2 / nralphainrangehigh); + if (alphatest[1] > 255) { + alphatest[1] = 255; + } + + alphablockerror3 = 0; + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; + } + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] <= alphatest[0] / 2) { + alphaenc3[4*j + i] = 6; + alphadist = srccolors[j][i]; + } + else if (srccolors[j][i] > ((255 + alphatest[1]) / 2)) { + alphaenc3[4*j + i] = 7; + alphadist = 255 - srccolors[j][i]; + } + else if (srccolors[j][i] <= acutValues[0]) { + alphaenc3[4*j + i] = 0; + alphadist = srccolors[j][i] - alphatest[0]; + } + else if (srccolors[j][i] <= acutValues[1]) { + alphaenc3[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5; + } + else if (srccolors[j][i] <= acutValues[2]) { + alphaenc3[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5; + } + else if (srccolors[j][i] <= acutValues[3]) { + alphaenc3[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5; + } + else if (srccolors[j][i] <= acutValues[4]) { + alphaenc3[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5; + } + else { + alphaenc3[4*j + i] = 1; + alphadist = srccolors[j][i] - alphatest[1]; + } + alphablockerror3 += alphadist * alphadist; + } + } + } + } + /* write the alpha values and encoding back. */ + if ((alphablockerror1 <= alphablockerror2) && (alphablockerror1 <= alphablockerror3)) { +#if RGTC_DEBUG + if (alphablockerror1 > 96) fprintf(stderr, "enc1 used, error %d\n", alphablockerror1); +#endif + write_rgtc_encoded_channel_s( blkaddr, alphause[1], alphause[0], alphaenc1 ); + } + else if (alphablockerror2 <= alphablockerror3) { +#if RGTC_DEBUG + if (alphablockerror2 > 96) fprintf(stderr, "enc2 used, error %d\n", alphablockerror2); +#endif + write_rgtc_encoded_channel_s( blkaddr, alphabase[0], alphabase[1], alphaenc2 ); + } + else { +#if RGTC_DEBUG + fprintf(stderr, "enc3 used, error %d\n", alphablockerror3); +#endif + write_rgtc_encoded_channel_s( blkaddr, (GLubyte)alphatest[0], (GLubyte)alphatest[1], alphaenc3 ); + } +} diff --git a/mesalib/src/mesa/main/texcompress_rgtc.h b/mesalib/src/mesa/main/texcompress_rgtc.h new file mode 100644 index 000000000..424edc458 --- /dev/null +++ b/mesalib/src/mesa/main/texcompress_rgtc.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2011 Red Hat Inc. + * + * 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. + */ + +#ifndef TEXCOMPRESS_RGTC_H +#define TEXCOMPRESS_RGTC_H + +#include "glheader.h" +#include "mfeatures.h" +#include "texstore.h" + +struct gl_texture_image; + +extern GLboolean +_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS); + +extern void +_mesa_fetch_texel_2d_f_red_rgtc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_rg_rgtc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); +#endif diff --git a/mesalib/src/mesa/main/texfetch.c b/mesalib/src/mesa/main/texfetch.c index 1e7ea9480..550597e1c 100644 --- a/mesalib/src/mesa/main/texfetch.c +++ b/mesalib/src/mesa/main/texfetch.c @@ -1,893 +1,922 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.7
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (c) 2009 VMware, Inc.
- *
- * 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
- * BRIAN PAUL 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.
- */
-
-
-/**
- * \file texfetch.c
- *
- * Texel fetch/store functions
- *
- * \author Gareth Hughes
- */
-
-
-#include "colormac.h"
-#include "macros.h"
-#include "texcompress.h"
-#include "texcompress_fxt1.h"
-#include "texcompress_s3tc.h"
-#include "texfetch.h"
-#include "teximage.h"
-
-
-/**
- * Convert an 8-bit sRGB value from non-linear space to a
- * linear RGB value in [0, 1].
- * Implemented with a 256-entry lookup table.
- */
-static INLINE GLfloat
-nonlinear_to_linear(GLubyte cs8)
-{
- static GLfloat table[256];
- static GLboolean tableReady = GL_FALSE;
- if (!tableReady) {
- /* compute lookup table now */
- GLuint i;
- for (i = 0; i < 256; i++) {
- const GLfloat cs = UBYTE_TO_FLOAT(i);
- if (cs <= 0.04045) {
- table[i] = cs / 12.92f;
- }
- else {
- table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4);
- }
- }
- tableReady = GL_TRUE;
- }
- return table[cs8];
-}
-
-
-
-/* Texel fetch routines for all supported formats
- */
-#define DIM 1
-#include "texfetch_tmp.h"
-
-#define DIM 2
-#include "texfetch_tmp.h"
-
-#define DIM 3
-#include "texfetch_tmp.h"
-
-/**
- * Null texel fetch function.
- *
- * Have to have this so the FetchTexel function pointer is never NULL.
- */
-static void fetch_null_texelf( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- (void) texImage; (void) i; (void) j; (void) k;
- texel[RCOMP] = 0.0;
- texel[GCOMP] = 0.0;
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 0.0;
- _mesa_warning(NULL, "fetch_null_texelf() called!");
-}
-
-static void store_null_texel(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- (void) texImage;
- (void) i;
- (void) j;
- (void) k;
- (void) texel;
- /* no-op */
-}
-
-
-
-/**
- * Table to map MESA_FORMAT_ to texel fetch/store funcs.
- * XXX this is somewhat temporary.
- */
-static struct {
- gl_format Name;
- FetchTexelFuncF Fetch1D;
- FetchTexelFuncF Fetch2D;
- FetchTexelFuncF Fetch3D;
- StoreTexelFunc StoreTexel;
-}
-texfetch_funcs[MESA_FORMAT_COUNT] =
-{
- {
- MESA_FORMAT_NONE,
- fetch_null_texelf,
- fetch_null_texelf,
- fetch_null_texelf,
- store_null_texel
- },
-
- {
- MESA_FORMAT_RGBA8888,
- fetch_texel_1d_f_rgba8888,
- fetch_texel_2d_f_rgba8888,
- fetch_texel_3d_f_rgba8888,
- store_texel_rgba8888
- },
- {
- MESA_FORMAT_RGBA8888_REV,
- fetch_texel_1d_f_rgba8888_rev,
- fetch_texel_2d_f_rgba8888_rev,
- fetch_texel_3d_f_rgba8888_rev,
- store_texel_rgba8888_rev
- },
- {
- MESA_FORMAT_ARGB8888,
- fetch_texel_1d_f_argb8888,
- fetch_texel_2d_f_argb8888,
- fetch_texel_3d_f_argb8888,
- store_texel_argb8888
- },
- {
- MESA_FORMAT_ARGB8888_REV,
- fetch_texel_1d_f_argb8888_rev,
- fetch_texel_2d_f_argb8888_rev,
- fetch_texel_3d_f_argb8888_rev,
- store_texel_argb8888_rev
- },
- {
- MESA_FORMAT_XRGB8888,
- fetch_texel_1d_f_xrgb8888,
- fetch_texel_2d_f_xrgb8888,
- fetch_texel_3d_f_xrgb8888,
- store_texel_xrgb8888
- },
- {
- MESA_FORMAT_XRGB8888_REV,
- fetch_texel_1d_f_xrgb8888_rev,
- fetch_texel_2d_f_xrgb8888_rev,
- fetch_texel_3d_f_xrgb8888_rev,
- store_texel_xrgb8888_rev,
- },
- {
- MESA_FORMAT_RGB888,
- fetch_texel_1d_f_rgb888,
- fetch_texel_2d_f_rgb888,
- fetch_texel_3d_f_rgb888,
- store_texel_rgb888
- },
- {
- MESA_FORMAT_BGR888,
- fetch_texel_1d_f_bgr888,
- fetch_texel_2d_f_bgr888,
- fetch_texel_3d_f_bgr888,
- store_texel_bgr888
- },
- {
- MESA_FORMAT_RGB565,
- fetch_texel_1d_f_rgb565,
- fetch_texel_2d_f_rgb565,
- fetch_texel_3d_f_rgb565,
- store_texel_rgb565
- },
- {
- MESA_FORMAT_RGB565_REV,
- fetch_texel_1d_f_rgb565_rev,
- fetch_texel_2d_f_rgb565_rev,
- fetch_texel_3d_f_rgb565_rev,
- store_texel_rgb565_rev
- },
- {
- MESA_FORMAT_ARGB4444,
- fetch_texel_1d_f_argb4444,
- fetch_texel_2d_f_argb4444,
- fetch_texel_3d_f_argb4444,
- store_texel_argb4444
- },
- {
- MESA_FORMAT_ARGB4444_REV,
- fetch_texel_1d_f_argb4444_rev,
- fetch_texel_2d_f_argb4444_rev,
- fetch_texel_3d_f_argb4444_rev,
- store_texel_argb4444_rev
- },
- {
- MESA_FORMAT_RGBA5551,
- fetch_texel_1d_f_rgba5551,
- fetch_texel_2d_f_rgba5551,
- fetch_texel_3d_f_rgba5551,
- store_texel_rgba5551
- },
- {
- MESA_FORMAT_ARGB1555,
- fetch_texel_1d_f_argb1555,
- fetch_texel_2d_f_argb1555,
- fetch_texel_3d_f_argb1555,
- store_texel_argb1555
- },
- {
- MESA_FORMAT_ARGB1555_REV,
- fetch_texel_1d_f_argb1555_rev,
- fetch_texel_2d_f_argb1555_rev,
- fetch_texel_3d_f_argb1555_rev,
- store_texel_argb1555_rev
- },
- {
- MESA_FORMAT_AL44,
- fetch_texel_1d_f_al44,
- fetch_texel_2d_f_al44,
- fetch_texel_3d_f_al44,
- store_texel_al44
- },
- {
- MESA_FORMAT_AL88,
- fetch_texel_1d_f_al88,
- fetch_texel_2d_f_al88,
- fetch_texel_3d_f_al88,
- store_texel_al88
- },
- {
- MESA_FORMAT_AL88_REV,
- fetch_texel_1d_f_al88_rev,
- fetch_texel_2d_f_al88_rev,
- fetch_texel_3d_f_al88_rev,
- store_texel_al88_rev
- },
- {
- MESA_FORMAT_AL1616,
- fetch_texel_1d_f_al1616,
- fetch_texel_2d_f_al1616,
- fetch_texel_3d_f_al1616,
- store_texel_al1616
- },
- {
- MESA_FORMAT_AL1616_REV,
- fetch_texel_1d_f_al1616_rev,
- fetch_texel_2d_f_al1616_rev,
- fetch_texel_3d_f_al1616_rev,
- store_texel_al1616_rev
- },
- {
- MESA_FORMAT_RGB332,
- fetch_texel_1d_f_rgb332,
- fetch_texel_2d_f_rgb332,
- fetch_texel_3d_f_rgb332,
- store_texel_rgb332
- },
- {
- MESA_FORMAT_A8,
- fetch_texel_1d_f_a8,
- fetch_texel_2d_f_a8,
- fetch_texel_3d_f_a8,
- store_texel_a8
- },
- {
- MESA_FORMAT_A16,
- fetch_texel_1d_f_a16,
- fetch_texel_2d_f_a16,
- fetch_texel_3d_f_a16,
- store_texel_a16
- },
- {
- MESA_FORMAT_L8,
- fetch_texel_1d_f_l8,
- fetch_texel_2d_f_l8,
- fetch_texel_3d_f_l8,
- store_texel_l8
- },
- {
- MESA_FORMAT_L16,
- fetch_texel_1d_f_l16,
- fetch_texel_2d_f_l16,
- fetch_texel_3d_f_l16,
- store_texel_l16
- },
- {
- MESA_FORMAT_I8,
- fetch_texel_1d_f_i8,
- fetch_texel_2d_f_i8,
- fetch_texel_3d_f_i8,
- store_texel_i8
- },
- {
- MESA_FORMAT_I16,
- fetch_texel_1d_f_i16,
- fetch_texel_2d_f_i16,
- fetch_texel_3d_f_i16,
- store_texel_i16
- },
- {
- MESA_FORMAT_CI8,
- fetch_texel_1d_f_ci8,
- fetch_texel_2d_f_ci8,
- fetch_texel_3d_f_ci8,
- store_texel_ci8
- },
- {
- MESA_FORMAT_YCBCR,
- fetch_texel_1d_f_ycbcr,
- fetch_texel_2d_f_ycbcr,
- fetch_texel_3d_f_ycbcr,
- store_texel_ycbcr
- },
- {
- MESA_FORMAT_YCBCR_REV,
- fetch_texel_1d_f_ycbcr_rev,
- fetch_texel_2d_f_ycbcr_rev,
- fetch_texel_3d_f_ycbcr_rev,
- store_texel_ycbcr_rev
- },
- {
- MESA_FORMAT_R8,
- fetch_texel_1d_f_r8,
- fetch_texel_2d_f_r8,
- fetch_texel_3d_f_r8,
- store_texel_r8,
- },
- {
- MESA_FORMAT_RG88,
- fetch_texel_1d_f_rg88,
- fetch_texel_2d_f_rg88,
- fetch_texel_3d_f_rg88,
- store_texel_rg88,
- },
- {
- MESA_FORMAT_RG88_REV,
- fetch_texel_1d_f_rg88_rev,
- fetch_texel_2d_f_rg88_rev,
- fetch_texel_3d_f_rg88_rev,
- store_texel_rg88_rev,
- },
- {
- MESA_FORMAT_R16,
- fetch_texel_1d_f_r16,
- fetch_texel_2d_f_r16,
- fetch_texel_3d_f_r16,
- store_texel_r16,
- },
- {
- MESA_FORMAT_RG1616,
- fetch_texel_1d_f_rg1616,
- fetch_texel_2d_f_rg1616,
- fetch_texel_3d_f_rg1616,
- store_texel_rg1616,
- },
- {
- MESA_FORMAT_RG1616_REV,
- fetch_texel_1d_f_rg1616_rev,
- fetch_texel_2d_f_rg1616_rev,
- fetch_texel_3d_f_rg1616_rev,
- store_texel_rg1616_rev,
- },
- {
- MESA_FORMAT_ARGB2101010,
- fetch_texel_1d_f_argb2101010,
- fetch_texel_2d_f_argb2101010,
- fetch_texel_3d_f_argb2101010,
- store_texel_argb2101010
- },
- {
- MESA_FORMAT_Z24_S8,
- fetch_texel_1d_f_z24_s8,
- fetch_texel_2d_f_z24_s8,
- fetch_texel_3d_f_z24_s8,
- store_texel_z24_s8
- },
- {
- MESA_FORMAT_S8_Z24,
- fetch_texel_1d_f_s8_z24,
- fetch_texel_2d_f_s8_z24,
- fetch_texel_3d_f_s8_z24,
- store_texel_s8_z24
- },
- {
- MESA_FORMAT_Z16,
- fetch_texel_1d_f_z16,
- fetch_texel_2d_f_z16,
- fetch_texel_3d_f_z16,
- store_texel_z16
- },
- {
- MESA_FORMAT_X8_Z24,
- fetch_texel_1d_f_s8_z24,
- fetch_texel_2d_f_s8_z24,
- fetch_texel_3d_f_s8_z24,
- store_texel_s8_z24
- },
- {
- MESA_FORMAT_Z24_X8,
- fetch_texel_1d_f_z24_s8,
- fetch_texel_2d_f_z24_s8,
- fetch_texel_3d_f_z24_s8,
- store_texel_z24_s8
- },
- {
- MESA_FORMAT_Z32,
- fetch_texel_1d_f_z32,
- fetch_texel_2d_f_z32,
- fetch_texel_3d_f_z32,
- store_texel_z32
- },
- {
- MESA_FORMAT_S8,
- NULL,
- NULL,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGB8,
- fetch_texel_1d_srgb8,
- fetch_texel_2d_srgb8,
- fetch_texel_3d_srgb8,
- store_texel_srgb8
- },
- {
- MESA_FORMAT_SRGBA8,
- fetch_texel_1d_srgba8,
- fetch_texel_2d_srgba8,
- fetch_texel_3d_srgba8,
- store_texel_srgba8
- },
- {
- MESA_FORMAT_SARGB8,
- fetch_texel_1d_sargb8,
- fetch_texel_2d_sargb8,
- fetch_texel_3d_sargb8,
- store_texel_sargb8
- },
- {
- MESA_FORMAT_SL8,
- fetch_texel_1d_sl8,
- fetch_texel_2d_sl8,
- fetch_texel_3d_sl8,
- store_texel_sl8
- },
- {
- MESA_FORMAT_SLA8,
- fetch_texel_1d_sla8,
- fetch_texel_2d_sla8,
- fetch_texel_3d_sla8,
- store_texel_sla8
- },
- {
- MESA_FORMAT_SRGB_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_srgb_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGBA_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGBA_DXT3,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt3,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGBA_DXT5,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt5,
- NULL,
- NULL
- },
-
- {
- MESA_FORMAT_RGB_FXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgb_fxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_FXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_fxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGB_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgb_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_DXT3,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt3,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_DXT5,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt5,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_FLOAT32,
- fetch_texel_1d_f_rgba_f32,
- fetch_texel_2d_f_rgba_f32,
- fetch_texel_3d_f_rgba_f32,
- store_texel_rgba_f32
- },
- {
- MESA_FORMAT_RGBA_FLOAT16,
- fetch_texel_1d_f_rgba_f16,
- fetch_texel_2d_f_rgba_f16,
- fetch_texel_3d_f_rgba_f16,
- store_texel_rgba_f16
- },
- {
- MESA_FORMAT_RGB_FLOAT32,
- fetch_texel_1d_f_rgb_f32,
- fetch_texel_2d_f_rgb_f32,
- fetch_texel_3d_f_rgb_f32,
- store_texel_rgb_f32
- },
- {
- MESA_FORMAT_RGB_FLOAT16,
- fetch_texel_1d_f_rgb_f16,
- fetch_texel_2d_f_rgb_f16,
- fetch_texel_3d_f_rgb_f16,
- store_texel_rgb_f16
- },
- {
- MESA_FORMAT_ALPHA_FLOAT32,
- fetch_texel_1d_f_alpha_f32,
- fetch_texel_2d_f_alpha_f32,
- fetch_texel_3d_f_alpha_f32,
- store_texel_alpha_f32
- },
- {
- MESA_FORMAT_ALPHA_FLOAT16,
- fetch_texel_1d_f_alpha_f16,
- fetch_texel_2d_f_alpha_f16,
- fetch_texel_3d_f_alpha_f16,
- store_texel_alpha_f16
- },
- {
- MESA_FORMAT_LUMINANCE_FLOAT32,
- fetch_texel_1d_f_luminance_f32,
- fetch_texel_2d_f_luminance_f32,
- fetch_texel_3d_f_luminance_f32,
- store_texel_luminance_f32
- },
- {
- MESA_FORMAT_LUMINANCE_FLOAT16,
- fetch_texel_1d_f_luminance_f16,
- fetch_texel_2d_f_luminance_f16,
- fetch_texel_3d_f_luminance_f16,
- store_texel_luminance_f16
- },
- {
- MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
- fetch_texel_1d_f_luminance_alpha_f32,
- fetch_texel_2d_f_luminance_alpha_f32,
- fetch_texel_3d_f_luminance_alpha_f32,
- store_texel_luminance_alpha_f32
- },
- {
- MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
- fetch_texel_1d_f_luminance_alpha_f16,
- fetch_texel_2d_f_luminance_alpha_f16,
- fetch_texel_3d_f_luminance_alpha_f16,
- store_texel_luminance_alpha_f16
- },
- {
- MESA_FORMAT_INTENSITY_FLOAT32,
- fetch_texel_1d_f_intensity_f32,
- fetch_texel_2d_f_intensity_f32,
- fetch_texel_3d_f_intensity_f32,
- store_texel_intensity_f32
- },
- {
- MESA_FORMAT_INTENSITY_FLOAT16,
- fetch_texel_1d_f_intensity_f16,
- fetch_texel_2d_f_intensity_f16,
- fetch_texel_3d_f_intensity_f16,
- store_texel_intensity_f16
- },
-
- /* non-normalized, signed int */
- {
- MESA_FORMAT_RGBA_INT8,
- fetch_texel_1d_rgba_int8,
- fetch_texel_2d_rgba_int8,
- fetch_texel_3d_rgba_int8,
- store_texel_rgba_int8
- },
- {
- MESA_FORMAT_RGBA_INT16,
- fetch_texel_1d_rgba_int16,
- fetch_texel_2d_rgba_int16,
- fetch_texel_3d_rgba_int16,
- store_texel_rgba_int16
- },
- {
- MESA_FORMAT_RGBA_INT32,
- fetch_texel_1d_rgba_int32,
- fetch_texel_2d_rgba_int32,
- fetch_texel_3d_rgba_int32,
- store_texel_rgba_int32
- },
-
- /* non-normalized, unsigned int */
- {
- MESA_FORMAT_RGBA_UINT8,
- fetch_texel_1d_rgba_uint8,
- fetch_texel_2d_rgba_uint8,
- fetch_texel_3d_rgba_uint8,
- store_texel_rgba_uint8
- },
- {
- MESA_FORMAT_RGBA_UINT16,
- fetch_texel_1d_rgba_uint16,
- fetch_texel_2d_rgba_uint16,
- fetch_texel_3d_rgba_uint16,
- store_texel_rgba_uint16
- },
- {
- MESA_FORMAT_RGBA_UINT32,
- fetch_texel_1d_rgba_uint32,
- fetch_texel_2d_rgba_uint32,
- fetch_texel_3d_rgba_uint32,
- store_texel_rgba_uint32
- },
-
- /* dudv */
- {
- MESA_FORMAT_DUDV8,
- fetch_texel_1d_dudv8,
- fetch_texel_2d_dudv8,
- fetch_texel_3d_dudv8,
- NULL
- },
-
- /* signed, normalized */
- {
- MESA_FORMAT_SIGNED_R8,
- fetch_texel_1d_signed_r8,
- fetch_texel_2d_signed_r8,
- fetch_texel_3d_signed_r8,
- store_texel_signed_r8
- },
- {
- MESA_FORMAT_SIGNED_RG88,
- fetch_texel_1d_signed_rg88,
- fetch_texel_2d_signed_rg88,
- fetch_texel_3d_signed_rg88,
- store_texel_signed_rg88
- },
- {
- MESA_FORMAT_SIGNED_RGBX8888,
- fetch_texel_1d_signed_rgbx8888,
- fetch_texel_2d_signed_rgbx8888,
- fetch_texel_3d_signed_rgbx8888,
- store_texel_signed_rgbx8888
- },
- {
- MESA_FORMAT_SIGNED_RGBA8888,
- fetch_texel_1d_signed_rgba8888,
- fetch_texel_2d_signed_rgba8888,
- fetch_texel_3d_signed_rgba8888,
- store_texel_signed_rgba8888
- },
- {
- MESA_FORMAT_SIGNED_RGBA8888_REV,
- fetch_texel_1d_signed_rgba8888_rev,
- fetch_texel_2d_signed_rgba8888_rev,
- fetch_texel_3d_signed_rgba8888_rev,
- store_texel_signed_rgba8888_rev
- },
- {
- MESA_FORMAT_SIGNED_R_16,
- fetch_texel_1d_signed_r_16,
- fetch_texel_2d_signed_r_16,
- fetch_texel_3d_signed_r_16,
- store_texel_signed_r_16
- },
- {
- MESA_FORMAT_SIGNED_RG_16,
- fetch_texel_1d_signed_rg_16,
- fetch_texel_2d_signed_rg_16,
- fetch_texel_3d_signed_rg_16,
- store_texel_signed_rg_16
- },
- {
- MESA_FORMAT_SIGNED_RGB_16,
- fetch_texel_1d_signed_rgb_16,
- fetch_texel_2d_signed_rgb_16,
- fetch_texel_3d_signed_rgb_16,
- store_texel_signed_rgb_16
- },
- {
- MESA_FORMAT_SIGNED_RGBA_16,
- fetch_texel_1d_signed_rgba_16,
- fetch_texel_2d_signed_rgba_16,
- fetch_texel_3d_signed_rgba_16,
- store_texel_signed_rgba_16
- },
- {
- MESA_FORMAT_RGBA_16,
- fetch_texel_1d_rgba_16,
- fetch_texel_2d_rgba_16,
- fetch_texel_3d_rgba_16,
- store_texel_rgba_16
- }
-};
-
-
-FetchTexelFuncF
-_mesa_get_texel_fetch_func(gl_format format, GLuint dims)
-{
-#ifdef DEBUG
- /* check that the table entries are sorted by format name */
- gl_format fmt;
- for (fmt = 0; fmt < MESA_FORMAT_COUNT; fmt++) {
- assert(texfetch_funcs[fmt].Name == fmt);
- }
-#endif
-
- assert(Elements(texfetch_funcs) == MESA_FORMAT_COUNT);
- assert(format < MESA_FORMAT_COUNT);
-
- switch (dims) {
- case 1:
- return texfetch_funcs[format].Fetch1D;
- case 2:
- return texfetch_funcs[format].Fetch2D;
- case 3:
- return texfetch_funcs[format].Fetch3D;
- default:
- assert(0 && "bad dims in _mesa_get_texel_fetch_func");
- return NULL;
- }
-}
-
-
-StoreTexelFunc
-_mesa_get_texel_store_func(gl_format format)
-{
- assert(format < MESA_FORMAT_COUNT);
- return texfetch_funcs[format].StoreTexel;
-}
-
-
-/**
- * Adaptor for fetching a GLchan texel from a float-valued texture.
- */
-static void
-fetch_texel_float_to_chan(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLchan *texelOut)
-{
- GLfloat temp[4];
- GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
-
- ASSERT(texImage->FetchTexelf);
- texImage->FetchTexelf(texImage, i, j, k, temp);
- if (baseFormat == GL_DEPTH_COMPONENT ||
- baseFormat == GL_DEPTH_STENCIL_EXT) {
- /* just one channel */
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
- }
- else {
- /* four channels */
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]);
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]);
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]);
- }
-}
-
-
-#if 0
-/**
- * Adaptor for fetching a float texel from a GLchan-valued texture.
- */
-static void
-fetch_texel_chan_to_float(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texelOut)
-{
- GLchan temp[4];
- GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
-
- ASSERT(texImage->FetchTexelc);
- texImage->FetchTexelc(texImage, i, j, k, temp);
- if (baseFormat == GL_DEPTH_COMPONENT ||
- baseFormat == GL_DEPTH_STENCIL_EXT) {
- /* just one channel */
- texelOut[0] = CHAN_TO_FLOAT(temp[0]);
- }
- else {
- /* four channels */
- texelOut[0] = CHAN_TO_FLOAT(temp[0]);
- texelOut[1] = CHAN_TO_FLOAT(temp[1]);
- texelOut[2] = CHAN_TO_FLOAT(temp[2]);
- texelOut[3] = CHAN_TO_FLOAT(temp[3]);
- }
-}
-#endif
-
-
-/**
- * Initialize the texture image's FetchTexelc and FetchTexelf methods.
- */
-void
-_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
-{
- gl_format format = texImage->TexFormat;
-
- ASSERT(dims == 1 || dims == 2 || dims == 3);
-
- if (texImage->TexObject->sRGBDecode == GL_SKIP_DECODE_EXT &&
- _mesa_get_format_color_encoding(format) == GL_SRGB) {
- format = _mesa_get_srgb_format_linear(format);
- }
-
- texImage->FetchTexelf = _mesa_get_texel_fetch_func(format, dims);
-
- texImage->FetchTexelc = fetch_texel_float_to_chan;
-
- ASSERT(texImage->FetchTexelc);
- ASSERT(texImage->FetchTexelf);
-}
-
-void
-_mesa_update_fetch_functions(struct gl_texture_object *texObj)
-{
- GLuint face, i;
- GLuint dims;
-
- dims = _mesa_get_texture_dimensions(texObj->Target);
-
- for (face = 0; face < 6; face++) {
- for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
- if (texObj->Image[face][i]) {
- _mesa_set_fetch_functions(texObj->Image[face][i], dims);
- }
- }
- }
-}
+/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2009 VMware, Inc. + * + * 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 + * BRIAN PAUL 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. + */ + + +/** + * \file texfetch.c + * + * Texel fetch/store functions + * + * \author Gareth Hughes + */ + + +#include "colormac.h" +#include "macros.h" +#include "texcompress.h" +#include "texcompress_fxt1.h" +#include "texcompress_s3tc.h" +#include "texcompress_rgtc.h" +#include "texfetch.h" +#include "teximage.h" + + +/** + * Convert an 8-bit sRGB value from non-linear space to a + * linear RGB value in [0, 1]. + * Implemented with a 256-entry lookup table. + */ +static INLINE GLfloat +nonlinear_to_linear(GLubyte cs8) +{ + static GLfloat table[256]; + static GLboolean tableReady = GL_FALSE; + if (!tableReady) { + /* compute lookup table now */ + GLuint i; + for (i = 0; i < 256; i++) { + const GLfloat cs = UBYTE_TO_FLOAT(i); + if (cs <= 0.04045) { + table[i] = cs / 12.92f; + } + else { + table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); + } + } + tableReady = GL_TRUE; + } + return table[cs8]; +} + + + +/* Texel fetch routines for all supported formats + */ +#define DIM 1 +#include "texfetch_tmp.h" + +#define DIM 2 +#include "texfetch_tmp.h" + +#define DIM 3 +#include "texfetch_tmp.h" + +/** + * Null texel fetch function. + * + * Have to have this so the FetchTexel function pointer is never NULL. + */ +static void fetch_null_texelf( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + (void) texImage; (void) i; (void) j; (void) k; + texel[RCOMP] = 0.0; + texel[GCOMP] = 0.0; + texel[BCOMP] = 0.0; + texel[ACOMP] = 0.0; + _mesa_warning(NULL, "fetch_null_texelf() called!"); +} + +static void store_null_texel(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + (void) texImage; + (void) i; + (void) j; + (void) k; + (void) texel; + /* no-op */ +} + + + +/** + * Table to map MESA_FORMAT_ to texel fetch/store funcs. + * XXX this is somewhat temporary. + */ +static struct { + gl_format Name; + FetchTexelFuncF Fetch1D; + FetchTexelFuncF Fetch2D; + FetchTexelFuncF Fetch3D; + StoreTexelFunc StoreTexel; +} +texfetch_funcs[MESA_FORMAT_COUNT] = +{ + { + MESA_FORMAT_NONE, + fetch_null_texelf, + fetch_null_texelf, + fetch_null_texelf, + store_null_texel + }, + + { + MESA_FORMAT_RGBA8888, + fetch_texel_1d_f_rgba8888, + fetch_texel_2d_f_rgba8888, + fetch_texel_3d_f_rgba8888, + store_texel_rgba8888 + }, + { + MESA_FORMAT_RGBA8888_REV, + fetch_texel_1d_f_rgba8888_rev, + fetch_texel_2d_f_rgba8888_rev, + fetch_texel_3d_f_rgba8888_rev, + store_texel_rgba8888_rev + }, + { + MESA_FORMAT_ARGB8888, + fetch_texel_1d_f_argb8888, + fetch_texel_2d_f_argb8888, + fetch_texel_3d_f_argb8888, + store_texel_argb8888 + }, + { + MESA_FORMAT_ARGB8888_REV, + fetch_texel_1d_f_argb8888_rev, + fetch_texel_2d_f_argb8888_rev, + fetch_texel_3d_f_argb8888_rev, + store_texel_argb8888_rev + }, + { + MESA_FORMAT_XRGB8888, + fetch_texel_1d_f_xrgb8888, + fetch_texel_2d_f_xrgb8888, + fetch_texel_3d_f_xrgb8888, + store_texel_xrgb8888 + }, + { + MESA_FORMAT_XRGB8888_REV, + fetch_texel_1d_f_xrgb8888_rev, + fetch_texel_2d_f_xrgb8888_rev, + fetch_texel_3d_f_xrgb8888_rev, + store_texel_xrgb8888_rev, + }, + { + MESA_FORMAT_RGB888, + fetch_texel_1d_f_rgb888, + fetch_texel_2d_f_rgb888, + fetch_texel_3d_f_rgb888, + store_texel_rgb888 + }, + { + MESA_FORMAT_BGR888, + fetch_texel_1d_f_bgr888, + fetch_texel_2d_f_bgr888, + fetch_texel_3d_f_bgr888, + store_texel_bgr888 + }, + { + MESA_FORMAT_RGB565, + fetch_texel_1d_f_rgb565, + fetch_texel_2d_f_rgb565, + fetch_texel_3d_f_rgb565, + store_texel_rgb565 + }, + { + MESA_FORMAT_RGB565_REV, + fetch_texel_1d_f_rgb565_rev, + fetch_texel_2d_f_rgb565_rev, + fetch_texel_3d_f_rgb565_rev, + store_texel_rgb565_rev + }, + { + MESA_FORMAT_ARGB4444, + fetch_texel_1d_f_argb4444, + fetch_texel_2d_f_argb4444, + fetch_texel_3d_f_argb4444, + store_texel_argb4444 + }, + { + MESA_FORMAT_ARGB4444_REV, + fetch_texel_1d_f_argb4444_rev, + fetch_texel_2d_f_argb4444_rev, + fetch_texel_3d_f_argb4444_rev, + store_texel_argb4444_rev + }, + { + MESA_FORMAT_RGBA5551, + fetch_texel_1d_f_rgba5551, + fetch_texel_2d_f_rgba5551, + fetch_texel_3d_f_rgba5551, + store_texel_rgba5551 + }, + { + MESA_FORMAT_ARGB1555, + fetch_texel_1d_f_argb1555, + fetch_texel_2d_f_argb1555, + fetch_texel_3d_f_argb1555, + store_texel_argb1555 + }, + { + MESA_FORMAT_ARGB1555_REV, + fetch_texel_1d_f_argb1555_rev, + fetch_texel_2d_f_argb1555_rev, + fetch_texel_3d_f_argb1555_rev, + store_texel_argb1555_rev + }, + { + MESA_FORMAT_AL44, + fetch_texel_1d_f_al44, + fetch_texel_2d_f_al44, + fetch_texel_3d_f_al44, + store_texel_al44 + }, + { + MESA_FORMAT_AL88, + fetch_texel_1d_f_al88, + fetch_texel_2d_f_al88, + fetch_texel_3d_f_al88, + store_texel_al88 + }, + { + MESA_FORMAT_AL88_REV, + fetch_texel_1d_f_al88_rev, + fetch_texel_2d_f_al88_rev, + fetch_texel_3d_f_al88_rev, + store_texel_al88_rev + }, + { + MESA_FORMAT_AL1616, + fetch_texel_1d_f_al1616, + fetch_texel_2d_f_al1616, + fetch_texel_3d_f_al1616, + store_texel_al1616 + }, + { + MESA_FORMAT_AL1616_REV, + fetch_texel_1d_f_al1616_rev, + fetch_texel_2d_f_al1616_rev, + fetch_texel_3d_f_al1616_rev, + store_texel_al1616_rev + }, + { + MESA_FORMAT_RGB332, + fetch_texel_1d_f_rgb332, + fetch_texel_2d_f_rgb332, + fetch_texel_3d_f_rgb332, + store_texel_rgb332 + }, + { + MESA_FORMAT_A8, + fetch_texel_1d_f_a8, + fetch_texel_2d_f_a8, + fetch_texel_3d_f_a8, + store_texel_a8 + }, + { + MESA_FORMAT_A16, + fetch_texel_1d_f_a16, + fetch_texel_2d_f_a16, + fetch_texel_3d_f_a16, + store_texel_a16 + }, + { + MESA_FORMAT_L8, + fetch_texel_1d_f_l8, + fetch_texel_2d_f_l8, + fetch_texel_3d_f_l8, + store_texel_l8 + }, + { + MESA_FORMAT_L16, + fetch_texel_1d_f_l16, + fetch_texel_2d_f_l16, + fetch_texel_3d_f_l16, + store_texel_l16 + }, + { + MESA_FORMAT_I8, + fetch_texel_1d_f_i8, + fetch_texel_2d_f_i8, + fetch_texel_3d_f_i8, + store_texel_i8 + }, + { + MESA_FORMAT_I16, + fetch_texel_1d_f_i16, + fetch_texel_2d_f_i16, + fetch_texel_3d_f_i16, + store_texel_i16 + }, + { + MESA_FORMAT_CI8, + fetch_texel_1d_f_ci8, + fetch_texel_2d_f_ci8, + fetch_texel_3d_f_ci8, + store_texel_ci8 + }, + { + MESA_FORMAT_YCBCR, + fetch_texel_1d_f_ycbcr, + fetch_texel_2d_f_ycbcr, + fetch_texel_3d_f_ycbcr, + store_texel_ycbcr + }, + { + MESA_FORMAT_YCBCR_REV, + fetch_texel_1d_f_ycbcr_rev, + fetch_texel_2d_f_ycbcr_rev, + fetch_texel_3d_f_ycbcr_rev, + store_texel_ycbcr_rev + }, + { + MESA_FORMAT_R8, + fetch_texel_1d_f_r8, + fetch_texel_2d_f_r8, + fetch_texel_3d_f_r8, + store_texel_r8, + }, + { + MESA_FORMAT_RG88, + fetch_texel_1d_f_rg88, + fetch_texel_2d_f_rg88, + fetch_texel_3d_f_rg88, + store_texel_rg88, + }, + { + MESA_FORMAT_RG88_REV, + fetch_texel_1d_f_rg88_rev, + fetch_texel_2d_f_rg88_rev, + fetch_texel_3d_f_rg88_rev, + store_texel_rg88_rev, + }, + { + MESA_FORMAT_R16, + fetch_texel_1d_f_r16, + fetch_texel_2d_f_r16, + fetch_texel_3d_f_r16, + store_texel_r16, + }, + { + MESA_FORMAT_RG1616, + fetch_texel_1d_f_rg1616, + fetch_texel_2d_f_rg1616, + fetch_texel_3d_f_rg1616, + store_texel_rg1616, + }, + { + MESA_FORMAT_RG1616_REV, + fetch_texel_1d_f_rg1616_rev, + fetch_texel_2d_f_rg1616_rev, + fetch_texel_3d_f_rg1616_rev, + store_texel_rg1616_rev, + }, + { + MESA_FORMAT_ARGB2101010, + fetch_texel_1d_f_argb2101010, + fetch_texel_2d_f_argb2101010, + fetch_texel_3d_f_argb2101010, + store_texel_argb2101010 + }, + { + MESA_FORMAT_Z24_S8, + fetch_texel_1d_f_z24_s8, + fetch_texel_2d_f_z24_s8, + fetch_texel_3d_f_z24_s8, + store_texel_z24_s8 + }, + { + MESA_FORMAT_S8_Z24, + fetch_texel_1d_f_s8_z24, + fetch_texel_2d_f_s8_z24, + fetch_texel_3d_f_s8_z24, + store_texel_s8_z24 + }, + { + MESA_FORMAT_Z16, + fetch_texel_1d_f_z16, + fetch_texel_2d_f_z16, + fetch_texel_3d_f_z16, + store_texel_z16 + }, + { + MESA_FORMAT_X8_Z24, + fetch_texel_1d_f_s8_z24, + fetch_texel_2d_f_s8_z24, + fetch_texel_3d_f_s8_z24, + store_texel_s8_z24 + }, + { + MESA_FORMAT_Z24_X8, + fetch_texel_1d_f_z24_s8, + fetch_texel_2d_f_z24_s8, + fetch_texel_3d_f_z24_s8, + store_texel_z24_s8 + }, + { + MESA_FORMAT_Z32, + fetch_texel_1d_f_z32, + fetch_texel_2d_f_z32, + fetch_texel_3d_f_z32, + store_texel_z32 + }, + { + MESA_FORMAT_S8, + NULL, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_SRGB8, + fetch_texel_1d_srgb8, + fetch_texel_2d_srgb8, + fetch_texel_3d_srgb8, + store_texel_srgb8 + }, + { + MESA_FORMAT_SRGBA8, + fetch_texel_1d_srgba8, + fetch_texel_2d_srgba8, + fetch_texel_3d_srgba8, + store_texel_srgba8 + }, + { + MESA_FORMAT_SARGB8, + fetch_texel_1d_sargb8, + fetch_texel_2d_sargb8, + fetch_texel_3d_sargb8, + store_texel_sargb8 + }, + { + MESA_FORMAT_SL8, + fetch_texel_1d_sl8, + fetch_texel_2d_sl8, + fetch_texel_3d_sl8, + store_texel_sl8 + }, + { + MESA_FORMAT_SLA8, + fetch_texel_1d_sla8, + fetch_texel_2d_sla8, + fetch_texel_3d_sla8, + store_texel_sla8 + }, + { + MESA_FORMAT_SRGB_DXT1, + NULL, + _mesa_fetch_texel_2d_f_srgb_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT1, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT3, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt3, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT5, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt5, + NULL, + NULL + }, + + { + MESA_FORMAT_RGB_FXT1, + NULL, + _mesa_fetch_texel_2d_f_rgb_fxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_FXT1, + NULL, + _mesa_fetch_texel_2d_f_rgba_fxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGB_DXT1, + NULL, + _mesa_fetch_texel_2d_f_rgb_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT1, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT3, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt3, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT5, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt5, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_FLOAT32, + fetch_texel_1d_f_rgba_f32, + fetch_texel_2d_f_rgba_f32, + fetch_texel_3d_f_rgba_f32, + store_texel_rgba_f32 + }, + { + MESA_FORMAT_RGBA_FLOAT16, + fetch_texel_1d_f_rgba_f16, + fetch_texel_2d_f_rgba_f16, + fetch_texel_3d_f_rgba_f16, + store_texel_rgba_f16 + }, + { + MESA_FORMAT_RGB_FLOAT32, + fetch_texel_1d_f_rgb_f32, + fetch_texel_2d_f_rgb_f32, + fetch_texel_3d_f_rgb_f32, + store_texel_rgb_f32 + }, + { + MESA_FORMAT_RGB_FLOAT16, + fetch_texel_1d_f_rgb_f16, + fetch_texel_2d_f_rgb_f16, + fetch_texel_3d_f_rgb_f16, + store_texel_rgb_f16 + }, + { + MESA_FORMAT_ALPHA_FLOAT32, + fetch_texel_1d_f_alpha_f32, + fetch_texel_2d_f_alpha_f32, + fetch_texel_3d_f_alpha_f32, + store_texel_alpha_f32 + }, + { + MESA_FORMAT_ALPHA_FLOAT16, + fetch_texel_1d_f_alpha_f16, + fetch_texel_2d_f_alpha_f16, + fetch_texel_3d_f_alpha_f16, + store_texel_alpha_f16 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT32, + fetch_texel_1d_f_luminance_f32, + fetch_texel_2d_f_luminance_f32, + fetch_texel_3d_f_luminance_f32, + store_texel_luminance_f32 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT16, + fetch_texel_1d_f_luminance_f16, + fetch_texel_2d_f_luminance_f16, + fetch_texel_3d_f_luminance_f16, + store_texel_luminance_f16 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + fetch_texel_1d_f_luminance_alpha_f32, + fetch_texel_2d_f_luminance_alpha_f32, + fetch_texel_3d_f_luminance_alpha_f32, + store_texel_luminance_alpha_f32 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + fetch_texel_1d_f_luminance_alpha_f16, + fetch_texel_2d_f_luminance_alpha_f16, + fetch_texel_3d_f_luminance_alpha_f16, + store_texel_luminance_alpha_f16 + }, + { + MESA_FORMAT_INTENSITY_FLOAT32, + fetch_texel_1d_f_intensity_f32, + fetch_texel_2d_f_intensity_f32, + fetch_texel_3d_f_intensity_f32, + store_texel_intensity_f32 + }, + { + MESA_FORMAT_INTENSITY_FLOAT16, + fetch_texel_1d_f_intensity_f16, + fetch_texel_2d_f_intensity_f16, + fetch_texel_3d_f_intensity_f16, + store_texel_intensity_f16 + }, + + /* non-normalized, signed int */ + { + MESA_FORMAT_RGBA_INT8, + fetch_texel_1d_rgba_int8, + fetch_texel_2d_rgba_int8, + fetch_texel_3d_rgba_int8, + store_texel_rgba_int8 + }, + { + MESA_FORMAT_RGBA_INT16, + fetch_texel_1d_rgba_int16, + fetch_texel_2d_rgba_int16, + fetch_texel_3d_rgba_int16, + store_texel_rgba_int16 + }, + { + MESA_FORMAT_RGBA_INT32, + fetch_texel_1d_rgba_int32, + fetch_texel_2d_rgba_int32, + fetch_texel_3d_rgba_int32, + store_texel_rgba_int32 + }, + + /* non-normalized, unsigned int */ + { + MESA_FORMAT_RGBA_UINT8, + fetch_texel_1d_rgba_uint8, + fetch_texel_2d_rgba_uint8, + fetch_texel_3d_rgba_uint8, + store_texel_rgba_uint8 + }, + { + MESA_FORMAT_RGBA_UINT16, + fetch_texel_1d_rgba_uint16, + fetch_texel_2d_rgba_uint16, + fetch_texel_3d_rgba_uint16, + store_texel_rgba_uint16 + }, + { + MESA_FORMAT_RGBA_UINT32, + fetch_texel_1d_rgba_uint32, + fetch_texel_2d_rgba_uint32, + fetch_texel_3d_rgba_uint32, + store_texel_rgba_uint32 + }, + + /* dudv */ + { + MESA_FORMAT_DUDV8, + fetch_texel_1d_dudv8, + fetch_texel_2d_dudv8, + fetch_texel_3d_dudv8, + NULL + }, + + /* signed, normalized */ + { + MESA_FORMAT_SIGNED_R8, + fetch_texel_1d_signed_r8, + fetch_texel_2d_signed_r8, + fetch_texel_3d_signed_r8, + store_texel_signed_r8 + }, + { + MESA_FORMAT_SIGNED_RG88, + fetch_texel_1d_signed_rg88, + fetch_texel_2d_signed_rg88, + fetch_texel_3d_signed_rg88, + store_texel_signed_rg88 + }, + { + MESA_FORMAT_SIGNED_RGBX8888, + fetch_texel_1d_signed_rgbx8888, + fetch_texel_2d_signed_rgbx8888, + fetch_texel_3d_signed_rgbx8888, + store_texel_signed_rgbx8888 + }, + { + MESA_FORMAT_SIGNED_RGBA8888, + fetch_texel_1d_signed_rgba8888, + fetch_texel_2d_signed_rgba8888, + fetch_texel_3d_signed_rgba8888, + store_texel_signed_rgba8888 + }, + { + MESA_FORMAT_SIGNED_RGBA8888_REV, + fetch_texel_1d_signed_rgba8888_rev, + fetch_texel_2d_signed_rgba8888_rev, + fetch_texel_3d_signed_rgba8888_rev, + store_texel_signed_rgba8888_rev + }, + { + MESA_FORMAT_SIGNED_R_16, + fetch_texel_1d_signed_r_16, + fetch_texel_2d_signed_r_16, + fetch_texel_3d_signed_r_16, + store_texel_signed_r_16 + }, + { + MESA_FORMAT_SIGNED_RG_16, + fetch_texel_1d_signed_rg_16, + fetch_texel_2d_signed_rg_16, + fetch_texel_3d_signed_rg_16, + store_texel_signed_rg_16 + }, + { + MESA_FORMAT_SIGNED_RGB_16, + fetch_texel_1d_signed_rgb_16, + fetch_texel_2d_signed_rgb_16, + fetch_texel_3d_signed_rgb_16, + store_texel_signed_rgb_16 + }, + { + MESA_FORMAT_SIGNED_RGBA_16, + fetch_texel_1d_signed_rgba_16, + fetch_texel_2d_signed_rgba_16, + fetch_texel_3d_signed_rgba_16, + store_texel_signed_rgba_16 + }, + { + MESA_FORMAT_RGBA_16, + fetch_texel_1d_rgba_16, + fetch_texel_2d_rgba_16, + fetch_texel_3d_rgba_16, + store_texel_rgba_16 + }, + { + MESA_FORMAT_RED_RGTC1, + NULL, + _mesa_fetch_texel_2d_f_red_rgtc1, + NULL, + NULL + }, + { + MESA_FORMAT_SIGNED_RED_RGTC1, + NULL, + _mesa_fetch_texel_2d_f_signed_red_rgtc1, + NULL, + NULL + }, + { + MESA_FORMAT_RG_RGTC2, + NULL, + _mesa_fetch_texel_2d_f_rg_rgtc2, + NULL, + NULL + }, + { + MESA_FORMAT_SIGNED_RG_RGTC2, + NULL, + _mesa_fetch_texel_2d_f_signed_rg_rgtc2, + NULL, + NULL + }, +}; + + +FetchTexelFuncF +_mesa_get_texel_fetch_func(gl_format format, GLuint dims) +{ +#ifdef DEBUG + /* check that the table entries are sorted by format name */ + gl_format fmt; + for (fmt = 0; fmt < MESA_FORMAT_COUNT; fmt++) { + assert(texfetch_funcs[fmt].Name == fmt); + } +#endif + + assert(Elements(texfetch_funcs) == MESA_FORMAT_COUNT); + assert(format < MESA_FORMAT_COUNT); + + switch (dims) { + case 1: + return texfetch_funcs[format].Fetch1D; + case 2: + return texfetch_funcs[format].Fetch2D; + case 3: + return texfetch_funcs[format].Fetch3D; + default: + assert(0 && "bad dims in _mesa_get_texel_fetch_func"); + return NULL; + } +} + + +StoreTexelFunc +_mesa_get_texel_store_func(gl_format format) +{ + assert(format < MESA_FORMAT_COUNT); + return texfetch_funcs[format].StoreTexel; +} + + +/** + * Adaptor for fetching a GLchan texel from a float-valued texture. + */ +static void +fetch_texel_float_to_chan(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texelOut) +{ + GLfloat temp[4]; + GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat); + + ASSERT(texImage->FetchTexelf); + texImage->FetchTexelf(texImage, i, j, k, temp); + if (baseFormat == GL_DEPTH_COMPONENT || + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* just one channel */ + UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]); + } + else { + /* four channels */ + UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]); + UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]); + UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]); + UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]); + } +} + + +#if 0 +/** + * Adaptor for fetching a float texel from a GLchan-valued texture. + */ +static void +fetch_texel_chan_to_float(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texelOut) +{ + GLchan temp[4]; + GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat); + + ASSERT(texImage->FetchTexelc); + texImage->FetchTexelc(texImage, i, j, k, temp); + if (baseFormat == GL_DEPTH_COMPONENT || + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* just one channel */ + texelOut[0] = CHAN_TO_FLOAT(temp[0]); + } + else { + /* four channels */ + texelOut[0] = CHAN_TO_FLOAT(temp[0]); + texelOut[1] = CHAN_TO_FLOAT(temp[1]); + texelOut[2] = CHAN_TO_FLOAT(temp[2]); + texelOut[3] = CHAN_TO_FLOAT(temp[3]); + } +} +#endif + + +/** + * Initialize the texture image's FetchTexelc and FetchTexelf methods. + */ +void +_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims) +{ + gl_format format = texImage->TexFormat; + + ASSERT(dims == 1 || dims == 2 || dims == 3); + + if (texImage->TexObject->sRGBDecode == GL_SKIP_DECODE_EXT && + _mesa_get_format_color_encoding(format) == GL_SRGB) { + format = _mesa_get_srgb_format_linear(format); + } + + texImage->FetchTexelf = _mesa_get_texel_fetch_func(format, dims); + + texImage->FetchTexelc = fetch_texel_float_to_chan; + + ASSERT(texImage->FetchTexelc); + ASSERT(texImage->FetchTexelf); +} + +void +_mesa_update_fetch_functions(struct gl_texture_object *texObj) +{ + GLuint face, i; + GLuint dims; + + dims = _mesa_get_texture_dimensions(texObj->Target); + + for (face = 0; face < 6; face++) { + for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { + if (texObj->Image[face][i]) { + _mesa_set_fetch_functions(texObj->Image[face][i], dims); + } + } + } +} diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c index 2542cea85..72025cf82 100644 --- a/mesalib/src/mesa/main/texformat.c +++ b/mesalib/src/mesa/main/texformat.c @@ -602,6 +602,25 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, } } + if (ctx->Extensions.ARB_texture_compression_rgtc) { + switch (internalFormat) { + case GL_COMPRESSED_RED_RGTC1: + RETURN_IF_SUPPORTED(MESA_FORMAT_RED_RGTC1); + break; + case GL_COMPRESSED_SIGNED_RED_RGTC1: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RED_RGTC1); + break; + case GL_COMPRESSED_RG_RGTC2: + RETURN_IF_SUPPORTED(MESA_FORMAT_RG_RGTC2); + break; + case GL_COMPRESSED_SIGNED_RG_RGTC2: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RG_RGTC2); + break; + default: + ; /* fallthrough */ + } + } + _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()"); return MESA_FORMAT_NONE; } diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index 1947d32e6..8a3e5f779 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -1,4783 +1,4789 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.5
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (c) 2008-2009 VMware, Inc.
- *
- * 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
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * Authors:
- * Brian Paul
- */
-
-/**
- * The GL texture image functions in teximage.c basically just do
- * error checking and data structure allocation. They in turn call
- * device driver functions which actually copy/convert/store the user's
- * texture image data.
- *
- * However, most device drivers will be able to use the fallback functions
- * in this file. That is, most drivers will have the following bit of
- * code:
- * ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- * ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- * ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- * etc...
- *
- * Texture image processing is actually kind of complicated. We have to do:
- * Format/type conversions
- * pixel unpacking
- * pixel transfer (scale, bais, lookup, etc)
- *
- * These functions can handle most everything, including processing full
- * images and sub-images.
- */
-
-
-#include "glheader.h"
-#include "bufferobj.h"
-#include "colormac.h"
-#include "image.h"
-#include "macros.h"
-#include "mipmap.h"
-#include "mfeatures.h"
-#include "mtypes.h"
-#include "pack.h"
-#include "imports.h"
-#include "pack.h"
-#include "texcompress.h"
-#include "texcompress_fxt1.h"
-#include "texcompress_s3tc.h"
-#include "teximage.h"
-#include "texstore.h"
-#include "enums.h"
-
-
-enum {
- ZERO = 4,
- ONE = 5
-};
-
-
-/**
- * Texture image storage function.
- */
-typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS);
-
-
-/**
- * Return GL_TRUE if the given image format is one that be converted
- * to another format by swizzling.
- */
-static GLboolean
-can_swizzle(GLenum logicalBaseFormat)
-{
- switch (logicalBaseFormat) {
- case GL_RGBA:
- case GL_RGB:
- case GL_LUMINANCE_ALPHA:
- case GL_INTENSITY:
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_BGR:
- case GL_BGRA:
- case GL_ABGR_EXT:
- case GL_RG:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-
-enum {
- IDX_LUMINANCE = 0,
- IDX_ALPHA,
- IDX_INTENSITY,
- IDX_LUMINANCE_ALPHA,
- IDX_RGB,
- IDX_RGBA,
- IDX_RED,
- IDX_GREEN,
- IDX_BLUE,
- IDX_BGR,
- IDX_BGRA,
- IDX_ABGR,
- IDX_RG,
- MAX_IDX
-};
-
-#define MAP1(x) MAP4(x, ZERO, ZERO, ZERO)
-#define MAP2(x,y) MAP4(x, y, ZERO, ZERO)
-#define MAP3(x,y,z) MAP4(x, y, z, ZERO)
-#define MAP4(x,y,z,w) { x, y, z, w, ZERO, ONE }
-
-
-static const struct {
- GLubyte format_idx;
- GLubyte to_rgba[6];
- GLubyte from_rgba[6];
-} mappings[MAX_IDX] =
-{
- {
- IDX_LUMINANCE,
- MAP4(0,0,0,ONE),
- MAP1(0)
- },
-
- {
- IDX_ALPHA,
- MAP4(ZERO, ZERO, ZERO, 0),
- MAP1(3)
- },
-
- {
- IDX_INTENSITY,
- MAP4(0, 0, 0, 0),
- MAP1(0),
- },
-
- {
- IDX_LUMINANCE_ALPHA,
- MAP4(0,0,0,1),
- MAP2(0,3)
- },
-
- {
- IDX_RGB,
- MAP4(0,1,2,ONE),
- MAP3(0,1,2)
- },
-
- {
- IDX_RGBA,
- MAP4(0,1,2,3),
- MAP4(0,1,2,3),
- },
-
- {
- IDX_RED,
- MAP4(0, ZERO, ZERO, ONE),
- MAP1(0),
- },
-
- {
- IDX_GREEN,
- MAP4(ZERO, 0, ZERO, ONE),
- MAP1(1),
- },
-
- {
- IDX_BLUE,
- MAP4(ZERO, ZERO, 0, ONE),
- MAP1(2),
- },
-
- {
- IDX_BGR,
- MAP4(2,1,0,ONE),
- MAP3(2,1,0)
- },
-
- {
- IDX_BGRA,
- MAP4(2,1,0,3),
- MAP4(2,1,0,3)
- },
-
- {
- IDX_ABGR,
- MAP4(3,2,1,0),
- MAP4(3,2,1,0)
- },
-
- {
- IDX_RG,
- MAP4(0, 1, ZERO, ONE),
- MAP2(0, 1)
- },
-};
-
-
-
-/**
- * Convert a GL image format enum to an IDX_* value (see above).
- */
-static int
-get_map_idx(GLenum value)
-{
- switch (value) {
- case GL_LUMINANCE: return IDX_LUMINANCE;
- case GL_ALPHA: return IDX_ALPHA;
- case GL_INTENSITY: return IDX_INTENSITY;
- case GL_LUMINANCE_ALPHA: return IDX_LUMINANCE_ALPHA;
- case GL_RGB: return IDX_RGB;
- case GL_RGBA: return IDX_RGBA;
- case GL_RED: return IDX_RED;
- case GL_GREEN: return IDX_GREEN;
- case GL_BLUE: return IDX_BLUE;
- case GL_BGR: return IDX_BGR;
- case GL_BGRA: return IDX_BGRA;
- case GL_ABGR_EXT: return IDX_ABGR;
- case GL_RG: return IDX_RG;
- default:
- _mesa_problem(NULL, "Unexpected inFormat");
- return 0;
- }
-}
-
-
-/**
- * When promoting texture formats (see below) we need to compute the
- * mapping of dest components back to source components.
- * This function does that.
- * \param inFormat the incoming format of the texture
- * \param outFormat the final texture format
- * \return map[6] a full 6-component map
- */
-static void
-compute_component_mapping(GLenum inFormat, GLenum outFormat,
- GLubyte *map)
-{
- const int inFmt = get_map_idx(inFormat);
- const int outFmt = get_map_idx(outFormat);
- const GLubyte *in2rgba = mappings[inFmt].to_rgba;
- const GLubyte *rgba2out = mappings[outFmt].from_rgba;
- int i;
-
- for (i = 0; i < 4; i++)
- map[i] = in2rgba[rgba2out[i]];
-
- map[ZERO] = ZERO;
- map[ONE] = ONE;
-
-#if 0
- printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n",
- inFormat, _mesa_lookup_enum_by_nr(inFormat),
- outFormat, _mesa_lookup_enum_by_nr(outFormat),
- map[0],
- map[1],
- map[2],
- map[3],
- map[4],
- map[5]);
-#endif
-}
-
-
-/**
- * Make a temporary (color) texture image with GLfloat components.
- * Apply all needed pixel unpacking and pixel transfer operations.
- * Note that there are both logicalBaseFormat and textureBaseFormat parameters.
- * Suppose the user specifies GL_LUMINANCE as the internal texture format
- * but the graphics hardware doesn't support luminance textures. So, we might
- * use an RGB hardware format instead.
- * If logicalBaseFormat != textureBaseFormat we have some extra work to do.
- *
- * \param ctx the rendering context
- * \param dims image dimensions: 1, 2 or 3
- * \param logicalBaseFormat basic texture derived from the user's
- * internal texture format value
- * \param textureBaseFormat the actual basic format of the texture
- * \param srcWidth source image width
- * \param srcHeight source image height
- * \param srcDepth source image depth
- * \param srcFormat source image format
- * \param srcType source image type
- * \param srcAddr source image address
- * \param srcPacking source image pixel packing
- * \return resulting image with format = textureBaseFormat and type = GLfloat.
- */
-static GLfloat *
-make_temp_float_image(struct gl_context *ctx, GLuint dims,
- GLenum logicalBaseFormat,
- GLenum textureBaseFormat,
- GLint srcWidth, GLint srcHeight, GLint srcDepth,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcAddr,
- const struct gl_pixelstore_attrib *srcPacking,
- GLbitfield transferOps)
-{
- GLfloat *tempImage;
- const GLint components = _mesa_components_in_format(logicalBaseFormat);
- const GLint srcStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- GLfloat *dst;
- GLint img, row;
-
- ASSERT(dims >= 1 && dims <= 3);
-
- ASSERT(logicalBaseFormat == GL_RGBA ||
- logicalBaseFormat == GL_RGB ||
- logicalBaseFormat == GL_RG ||
- logicalBaseFormat == GL_RED ||
- logicalBaseFormat == GL_LUMINANCE_ALPHA ||
- logicalBaseFormat == GL_LUMINANCE ||
- logicalBaseFormat == GL_ALPHA ||
- logicalBaseFormat == GL_INTENSITY ||
- logicalBaseFormat == GL_COLOR_INDEX ||
- logicalBaseFormat == GL_DEPTH_COMPONENT);
-
- ASSERT(textureBaseFormat == GL_RGBA ||
- textureBaseFormat == GL_RGB ||
- textureBaseFormat == GL_RG ||
- textureBaseFormat == GL_RED ||
- textureBaseFormat == GL_LUMINANCE_ALPHA ||
- textureBaseFormat == GL_LUMINANCE ||
- textureBaseFormat == GL_ALPHA ||
- textureBaseFormat == GL_INTENSITY ||
- textureBaseFormat == GL_COLOR_INDEX ||
- textureBaseFormat == GL_DEPTH_COMPONENT);
-
- tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth
- * components * sizeof(GLfloat));
- if (!tempImage)
- return NULL;
-
- dst = tempImage;
- for (img = 0; img < srcDepth; img++) {
- const GLubyte *src
- = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
- srcWidth, srcHeight,
- srcFormat, srcType,
- img, 0, 0);
- for (row = 0; row < srcHeight; row++) {
- _mesa_unpack_color_span_float(ctx, srcWidth, logicalBaseFormat,
- dst, srcFormat, srcType, src,
- srcPacking, transferOps);
- dst += srcWidth * components;
- src += srcStride;
- }
- }
-
- if (logicalBaseFormat != textureBaseFormat) {
- /* more work */
- GLint texComponents = _mesa_components_in_format(textureBaseFormat);
- GLint logComponents = _mesa_components_in_format(logicalBaseFormat);
- GLfloat *newImage;
- GLint i, n;
- GLubyte map[6];
-
- /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */
- ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA ||
- textureBaseFormat == GL_LUMINANCE_ALPHA);
-
- /* The actual texture format should have at least as many components
- * as the logical texture format.
- */
- ASSERT(texComponents >= logComponents);
-
- newImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth
- * texComponents * sizeof(GLfloat));
- if (!newImage) {
- free(tempImage);
- return NULL;
- }
-
- compute_component_mapping(logicalBaseFormat, textureBaseFormat, map);
-
- n = srcWidth * srcHeight * srcDepth;
- for (i = 0; i < n; i++) {
- GLint k;
- for (k = 0; k < texComponents; k++) {
- GLint j = map[k];
- if (j == ZERO)
- newImage[i * texComponents + k] = 0.0F;
- else if (j == ONE)
- newImage[i * texComponents + k] = 1.0F;
- else
- newImage[i * texComponents + k] = tempImage[i * logComponents + j];
- }
- }
-
- free(tempImage);
- tempImage = newImage;
- }
-
- return tempImage;
-}
-
-
-/**
- * Make temporary image with uint pixel values. Used for unsigned
- * integer-valued textures.
- */
-static GLuint *
-make_temp_uint_image(struct gl_context *ctx, GLuint dims,
- GLenum logicalBaseFormat,
- GLenum textureBaseFormat,
- GLint srcWidth, GLint srcHeight, GLint srcDepth,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcAddr,
- const struct gl_pixelstore_attrib *srcPacking)
-{
- GLuint *tempImage;
- const GLint components = _mesa_components_in_format(logicalBaseFormat);
- const GLint srcStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- GLuint *dst;
- GLint img, row;
-
- ASSERT(dims >= 1 && dims <= 3);
-
- ASSERT(logicalBaseFormat == GL_RGBA ||
- logicalBaseFormat == GL_RGB ||
- logicalBaseFormat == GL_RG ||
- logicalBaseFormat == GL_RED ||
- logicalBaseFormat == GL_LUMINANCE_ALPHA ||
- logicalBaseFormat == GL_LUMINANCE ||
- logicalBaseFormat == GL_INTENSITY ||
- logicalBaseFormat == GL_ALPHA);
-
- ASSERT(textureBaseFormat == GL_RGBA ||
- textureBaseFormat == GL_RGB ||
- textureBaseFormat == GL_RG ||
- textureBaseFormat == GL_RED ||
- textureBaseFormat == GL_LUMINANCE_ALPHA ||
- textureBaseFormat == GL_LUMINANCE ||
- textureBaseFormat == GL_ALPHA);
-
- tempImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth
- * components * sizeof(GLuint));
- if (!tempImage)
- return NULL;
-
- dst = tempImage;
- for (img = 0; img < srcDepth; img++) {
- const GLubyte *src
- = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
- srcWidth, srcHeight,
- srcFormat, srcType,
- img, 0, 0);
- for (row = 0; row < srcHeight; row++) {
- _mesa_unpack_color_span_uint(ctx, srcWidth, logicalBaseFormat,
- dst, srcFormat, srcType, src,
- srcPacking);
- dst += srcWidth * components;
- src += srcStride;
- }
- }
-
- if (logicalBaseFormat != textureBaseFormat) {
- /* more work */
- GLint texComponents = _mesa_components_in_format(textureBaseFormat);
- GLint logComponents = _mesa_components_in_format(logicalBaseFormat);
- GLuint *newImage;
- GLint i, n;
- GLubyte map[6];
-
- /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */
- ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA ||
- textureBaseFormat == GL_LUMINANCE_ALPHA);
-
- /* The actual texture format should have at least as many components
- * as the logical texture format.
- */
- ASSERT(texComponents >= logComponents);
-
- newImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth
- * texComponents * sizeof(GLuint));
- if (!newImage) {
- free(tempImage);
- return NULL;
- }
-
- compute_component_mapping(logicalBaseFormat, textureBaseFormat, map);
-
- n = srcWidth * srcHeight * srcDepth;
- for (i = 0; i < n; i++) {
- GLint k;
- for (k = 0; k < texComponents; k++) {
- GLint j = map[k];
- if (j == ZERO)
- newImage[i * texComponents + k] = 0.0F;
- else if (j == ONE)
- newImage[i * texComponents + k] = 1.0F;
- else
- newImage[i * texComponents + k] = tempImage[i * logComponents + j];
- }
- }
-
- free(tempImage);
- tempImage = newImage;
- }
-
- return tempImage;
-}
-
-
-
-/**
- * Make a temporary (color) texture image with GLchan components.
- * Apply all needed pixel unpacking and pixel transfer operations.
- * Note that there are both logicalBaseFormat and textureBaseFormat parameters.
- * Suppose the user specifies GL_LUMINANCE as the internal texture format
- * but the graphics hardware doesn't support luminance textures. So, we might
- * use an RGB hardware format instead.
- * If logicalBaseFormat != textureBaseFormat we have some extra work to do.
- *
- * \param ctx the rendering context
- * \param dims image dimensions: 1, 2 or 3
- * \param logicalBaseFormat basic texture derived from the user's
- * internal texture format value
- * \param textureBaseFormat the actual basic format of the texture
- * \param srcWidth source image width
- * \param srcHeight source image height
- * \param srcDepth source image depth
- * \param srcFormat source image format
- * \param srcType source image type
- * \param srcAddr source image address
- * \param srcPacking source image pixel packing
- * \return resulting image with format = textureBaseFormat and type = GLchan.
- */
-GLchan *
-_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims,
- GLenum logicalBaseFormat,
- GLenum textureBaseFormat,
- GLint srcWidth, GLint srcHeight, GLint srcDepth,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcAddr,
- const struct gl_pixelstore_attrib *srcPacking)
-{
- GLuint transferOps = ctx->_ImageTransferState;
- const GLint components = _mesa_components_in_format(logicalBaseFormat);
- GLint img, row;
- GLchan *tempImage, *dst;
-
- ASSERT(dims >= 1 && dims <= 3);
-
- ASSERT(logicalBaseFormat == GL_RGBA ||
- logicalBaseFormat == GL_RGB ||
- logicalBaseFormat == GL_RG ||
- logicalBaseFormat == GL_RED ||
- logicalBaseFormat == GL_LUMINANCE_ALPHA ||
- logicalBaseFormat == GL_LUMINANCE ||
- logicalBaseFormat == GL_ALPHA ||
- logicalBaseFormat == GL_INTENSITY);
-
- ASSERT(textureBaseFormat == GL_RGBA ||
- textureBaseFormat == GL_RGB ||
- textureBaseFormat == GL_RG ||
- textureBaseFormat == GL_RED ||
- textureBaseFormat == GL_LUMINANCE_ALPHA ||
- textureBaseFormat == GL_LUMINANCE ||
- textureBaseFormat == GL_ALPHA ||
- textureBaseFormat == GL_INTENSITY);
-
- /* unpack and transfer the source image */
- tempImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth
- * components * sizeof(GLchan));
- if (!tempImage) {
- return NULL;
- }
-
- dst = tempImage;
- for (img = 0; img < srcDepth; img++) {
- const GLint srcStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- const GLubyte *src =
- (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
- srcWidth, srcHeight,
- srcFormat, srcType,
- img, 0, 0);
- for (row = 0; row < srcHeight; row++) {
- _mesa_unpack_color_span_chan(ctx, srcWidth, logicalBaseFormat, dst,
- srcFormat, srcType, src, srcPacking,
- transferOps);
- dst += srcWidth * components;
- src += srcStride;
- }
- }
-
- if (logicalBaseFormat != textureBaseFormat) {
- /* one more conversion step */
- GLint texComponents = _mesa_components_in_format(textureBaseFormat);
- GLint logComponents = _mesa_components_in_format(logicalBaseFormat);
- GLchan *newImage;
- GLint i, n;
- GLubyte map[6];
-
- /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */
- ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA ||
- textureBaseFormat == GL_LUMINANCE_ALPHA);
-
- /* The actual texture format should have at least as many components
- * as the logical texture format.
- */
- ASSERT(texComponents >= logComponents);
-
- newImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth
- * texComponents * sizeof(GLchan));
- if (!newImage) {
- free(tempImage);
- return NULL;
- }
-
- compute_component_mapping(logicalBaseFormat, textureBaseFormat, map);
-
- n = srcWidth * srcHeight * srcDepth;
- for (i = 0; i < n; i++) {
- GLint k;
- for (k = 0; k < texComponents; k++) {
- GLint j = map[k];
- if (j == ZERO)
- newImage[i * texComponents + k] = 0;
- else if (j == ONE)
- newImage[i * texComponents + k] = CHAN_MAX;
- else
- newImage[i * texComponents + k] = tempImage[i * logComponents + j];
- }
- }
-
- free(tempImage);
- tempImage = newImage;
- }
-
- return tempImage;
-}
-
-
-/**
- * Copy GLubyte pixels from <src> to <dst> with swizzling.
- * \param dst destination pixels
- * \param dstComponents number of color components in destination pixels
- * \param src source pixels
- * \param srcComponents number of color components in source pixels
- * \param map the swizzle mapping. map[X] says where to find the X component
- * in the source image's pixels. For example, if the source image
- * is GL_BGRA and X = red, map[0] yields 2.
- * \param count number of pixels to copy/swizzle.
- */
-static void
-swizzle_copy(GLubyte *dst, GLuint dstComponents, const GLubyte *src,
- GLuint srcComponents, const GLubyte *map, GLuint count)
-{
-#define SWZ_CPY(dst, src, count, dstComps, srcComps) \
- do { \
- GLuint i; \
- for (i = 0; i < count; i++) { \
- GLuint j; \
- if (srcComps == 4) { \
- COPY_4UBV(tmp, src); \
- } \
- else { \
- for (j = 0; j < srcComps; j++) { \
- tmp[j] = src[j]; \
- } \
- } \
- src += srcComps; \
- for (j = 0; j < dstComps; j++) { \
- dst[j] = tmp[map[j]]; \
- } \
- dst += dstComps; \
- } \
- } while (0)
-
- GLubyte tmp[6];
-
- tmp[ZERO] = 0x0;
- tmp[ONE] = 0xff;
-
- ASSERT(srcComponents <= 4);
- ASSERT(dstComponents <= 4);
-
- switch (dstComponents) {
- case 4:
- switch (srcComponents) {
- case 4:
- SWZ_CPY(dst, src, count, 4, 4);
- break;
- case 3:
- SWZ_CPY(dst, src, count, 4, 3);
- break;
- case 2:
- SWZ_CPY(dst, src, count, 4, 2);
- break;
- case 1:
- SWZ_CPY(dst, src, count, 4, 1);
- break;
- default:
- ;
- }
- break;
- case 3:
- switch (srcComponents) {
- case 4:
- SWZ_CPY(dst, src, count, 3, 4);
- break;
- case 3:
- SWZ_CPY(dst, src, count, 3, 3);
- break;
- case 2:
- SWZ_CPY(dst, src, count, 3, 2);
- break;
- case 1:
- SWZ_CPY(dst, src, count, 3, 1);
- break;
- default:
- ;
- }
- break;
- case 2:
- switch (srcComponents) {
- case 4:
- SWZ_CPY(dst, src, count, 2, 4);
- break;
- case 3:
- SWZ_CPY(dst, src, count, 2, 3);
- break;
- case 2:
- SWZ_CPY(dst, src, count, 2, 2);
- break;
- case 1:
- SWZ_CPY(dst, src, count, 2, 1);
- break;
- default:
- ;
- }
- break;
- case 1:
- switch (srcComponents) {
- case 4:
- SWZ_CPY(dst, src, count, 1, 4);
- break;
- case 3:
- SWZ_CPY(dst, src, count, 1, 3);
- break;
- case 2:
- SWZ_CPY(dst, src, count, 1, 2);
- break;
- case 1:
- SWZ_CPY(dst, src, count, 1, 1);
- break;
- default:
- ;
- }
- break;
- default:
- ;
- }
-#undef SWZ_CPY
-}
-
-
-
-static const GLubyte map_identity[6] = { 0, 1, 2, 3, ZERO, ONE };
-static const GLubyte map_3210[6] = { 3, 2, 1, 0, ZERO, ONE };
-
-
-/**
- * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a
- * mapping array depending on endianness.
- */
-static const GLubyte *
-type_mapping( GLenum srcType )
-{
- switch (srcType) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- return map_identity;
- case GL_UNSIGNED_INT_8_8_8_8:
- return _mesa_little_endian() ? map_3210 : map_identity;
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- return _mesa_little_endian() ? map_identity : map_3210;
- default:
- return NULL;
- }
-}
-
-
-/**
- * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a
- * mapping array depending on pixelstore byte swapping state.
- */
-static const GLubyte *
-byteswap_mapping( GLboolean swapBytes,
- GLenum srcType )
-{
- if (!swapBytes)
- return map_identity;
-
- switch (srcType) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- return map_identity;
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- return map_3210;
- default:
- return NULL;
- }
-}
-
-
-
-/**
- * Transfer a GLubyte texture image with component swizzling.
- */
-static void
-_mesa_swizzle_ubyte_image(struct gl_context *ctx,
- GLuint dimensions,
- GLenum srcFormat,
- GLenum srcType,
-
- GLenum baseInternalFormat,
-
- const GLubyte *rgba2dst,
- GLuint dstComponents,
-
- GLvoid *dstAddr,
- GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
- GLint dstRowStride,
- const GLuint *dstImageOffsets,
-
- GLint srcWidth, GLint srcHeight, GLint srcDepth,
- const GLvoid *srcAddr,
- const struct gl_pixelstore_attrib *srcPacking )
-{
- GLint srcComponents = _mesa_components_in_format(srcFormat);
- const GLubyte *srctype2ubyte, *swap;
- GLubyte map[4], src2base[6], base2rgba[6];
- GLint i;
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth,
- srcFormat, GL_UNSIGNED_BYTE);
- const GLint srcImageStride
- = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat,
- GL_UNSIGNED_BYTE);
- const GLubyte *srcImage
- = (const GLubyte *) _mesa_image_address(dimensions, srcPacking, srcAddr,
- srcWidth, srcHeight, srcFormat,
- GL_UNSIGNED_BYTE, 0, 0, 0);
-
- (void) ctx;
-
- /* Translate from src->baseInternal->GL_RGBA->dst. This will
- * correctly deal with RGBA->RGB->RGBA conversions where the final
- * A value must be 0xff regardless of the incoming alpha values.
- */
- compute_component_mapping(srcFormat, baseInternalFormat, src2base);
- compute_component_mapping(baseInternalFormat, GL_RGBA, base2rgba);
- swap = byteswap_mapping(srcPacking->SwapBytes, srcType);
- srctype2ubyte = type_mapping(srcType);
-
-
- for (i = 0; i < 4; i++)
- map[i] = srctype2ubyte[swap[src2base[base2rgba[rgba2dst[i]]]]];
-
-/* printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */
-
- if (srcComponents == dstComponents &&
- srcRowStride == dstRowStride &&
- srcRowStride == srcWidth * srcComponents &&
- dimensions < 3) {
- /* 1 and 2D images only */
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstYoffset * dstRowStride
- + dstXoffset * dstComponents;
- swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map,
- srcWidth * srcHeight);
- }
- else {
- GLint img, row;
- for (img = 0; img < srcDepth; img++) {
- const GLubyte *srcRow = srcImage;
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * dstComponents
- + dstYoffset * dstRowStride
- + dstXoffset * dstComponents;
- for (row = 0; row < srcHeight; row++) {
- swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth);
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- srcImage += srcImageStride;
- }
- }
-}
-
-
-/**
- * Teximage storage routine for when a simple memcpy will do.
- * No pixel transfer operations or special texel encodings allowed.
- * 1D, 2D and 3D images supported.
- */
-static void
-memcpy_texture(struct gl_context *ctx,
- GLuint dimensions,
- gl_format dstFormat,
- GLvoid *dstAddr,
- GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
- GLint dstRowStride,
- const GLuint *dstImageOffsets,
- GLint srcWidth, GLint srcHeight, GLint srcDepth,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcAddr,
- const struct gl_pixelstore_attrib *srcPacking)
-{
- const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
- srcFormat, srcType);
- const GLint srcImageStride = _mesa_image_image_stride(srcPacking,
- srcWidth, srcHeight, srcFormat, srcType);
- const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions,
- srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLint bytesPerRow = srcWidth * texelBytes;
-
-#if 0
- /* XXX update/re-enable for dstImageOffsets array */
- const GLint bytesPerImage = srcHeight * bytesPerRow;
- const GLint bytesPerTexture = srcDepth * bytesPerImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
-
- if (dstRowStride == srcRowStride &&
- dstRowStride == bytesPerRow &&
- ((dstImageStride == srcImageStride &&
- dstImageStride == bytesPerImage) ||
- (srcDepth == 1))) {
- /* one big memcpy */
- ctx->Driver.TextureMemCpy(dstImage, srcImage, bytesPerTexture);
- }
- else
- {
- GLint img, row;
- for (img = 0; img < srcDepth; img++) {
- const GLubyte *srcRow = srcImage;
- GLubyte *dstRow = dstImage;
- for (row = 0; row < srcHeight; row++) {
- ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow);
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- srcImage += srcImageStride;
- dstImage += dstImageStride;
- }
- }
-#endif
-
- GLint img, row;
- for (img = 0; img < srcDepth; img++) {
- const GLubyte *srcRow = srcImage;
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow);
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- srcImage += srcImageStride;
- }
-}
-
-
-
-/**
- * Store a 32-bit integer depth component texture image.
- */
-static GLboolean
-_mesa_texstore_z32(TEXSTORE_PARAMS)
-{
- const GLuint depthScale = 0xffffffff;
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- (void) dims;
- ASSERT(dstFormat == MESA_FORMAT_Z32);
- ASSERT(texelBytes == sizeof(GLuint));
-
- if (ctx->Pixel.DepthScale == 1.0f &&
- ctx->Pixel.DepthBias == 0.0f &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == GL_DEPTH_COMPONENT &&
- srcFormat == GL_DEPTH_COMPONENT &&
- srcType == GL_UNSIGNED_INT) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- GLint img, row;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- const GLvoid *src = _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
- _mesa_unpack_depth_span(ctx, srcWidth,
- GL_UNSIGNED_INT, (GLuint *) dstRow,
- depthScale, srcType, src, srcPacking);
- dstRow += dstRowStride;
- }
- }
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store a 24-bit integer depth component texture image.
- */
-static GLboolean
-_mesa_texstore_x8_z24(TEXSTORE_PARAMS)
-{
- const GLuint depthScale = 0xffffff;
- const GLuint texelBytes = 4;
-
- (void) dims;
- ASSERT(dstFormat == MESA_FORMAT_X8_Z24);
-
- {
- /* general path */
- GLint img, row;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- const GLvoid *src = _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
- _mesa_unpack_depth_span(ctx, srcWidth,
- GL_UNSIGNED_INT, (GLuint *) dstRow,
- depthScale, srcType, src, srcPacking);
- dstRow += dstRowStride;
- }
- }
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store a 24-bit integer depth component texture image.
- */
-static GLboolean
-_mesa_texstore_z24_x8(TEXSTORE_PARAMS)
-{
- const GLuint depthScale = 0xffffff;
- const GLuint texelBytes = 4;
-
- (void) dims;
- ASSERT(dstFormat == MESA_FORMAT_Z24_X8);
-
- {
- /* general path */
- GLint img, row;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- const GLvoid *src = _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
- GLuint *dst = (GLuint *) dstRow;
- GLint i;
- _mesa_unpack_depth_span(ctx, srcWidth,
- GL_UNSIGNED_INT, dst,
- depthScale, srcType, src, srcPacking);
- for (i = 0; i < srcWidth; i++)
- dst[i] <<= 8;
- dstRow += dstRowStride;
- }
- }
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store a 16-bit integer depth component texture image.
- */
-static GLboolean
-_mesa_texstore_z16(TEXSTORE_PARAMS)
-{
- const GLuint depthScale = 0xffff;
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- (void) dims;
- ASSERT(dstFormat == MESA_FORMAT_Z16);
- ASSERT(texelBytes == sizeof(GLushort));
-
- if (ctx->Pixel.DepthScale == 1.0f &&
- ctx->Pixel.DepthBias == 0.0f &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == GL_DEPTH_COMPONENT &&
- srcFormat == GL_DEPTH_COMPONENT &&
- srcType == GL_UNSIGNED_SHORT) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- GLint img, row;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- const GLvoid *src = _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
- GLushort *dst16 = (GLushort *) dstRow;
- _mesa_unpack_depth_span(ctx, srcWidth,
- GL_UNSIGNED_SHORT, dst16, depthScale,
- srcType, src, srcPacking);
- dstRow += dstRowStride;
- }
- }
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store an rgb565 or rgb565_rev texture image.
- */
-static GLboolean
-_mesa_texstore_rgb565(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGB565 ||
- dstFormat == MESA_FORMAT_RGB565_REV);
- ASSERT(texelBytes == 2);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_RGB565 &&
- baseInternalFormat == GL_RGB &&
- srcFormat == GL_RGB &&
- srcType == GL_UNSIGNED_SHORT_5_6_5) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == GL_RGB &&
- srcFormat == GL_RGB &&
- srcType == GL_UNSIGNED_BYTE &&
- dims == 2) {
- /* do optimized tex store */
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- GLubyte *dst = (GLubyte *) dstAddr
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- GLint row, col;
- for (row = 0; row < srcHeight; row++) {
- const GLubyte *srcUB = (const GLubyte *) src;
- GLushort *dstUS = (GLushort *) dst;
- /* check for byteswapped format */
- if (dstFormat == MESA_FORMAT_RGB565) {
- for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] );
- srcUB += 3;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_565_REV( srcUB[0], srcUB[1], srcUB[2] );
- srcUB += 3;
- }
- }
- dst += dstRowStride;
- src += srcRowStride;
- }
- }
- else {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- /* check for byteswapped format */
- if (dstFormat == MESA_FORMAT_RGB565) {
- for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
- src += 3;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_565_REV( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
- src += 3;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store a texture in MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV.
- */
-static GLboolean
-_mesa_texstore_rgba8888(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA8888 ||
- dstFormat == MESA_FORMAT_RGBA8888_REV);
- ASSERT(texelBytes == 4);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_RGBA8888 &&
- baseInternalFormat == GL_RGBA &&
- ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
- (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian))) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_RGBA8888_REV &&
- baseInternalFormat == GL_RGBA &&
- ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
- (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian))) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- (srcType == GL_UNSIGNED_BYTE ||
- srcType == GL_UNSIGNED_INT_8_8_8_8 ||
- srcType == GL_UNSIGNED_INT_8_8_8_8_REV) &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
-
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- if ((littleEndian && dstFormat == MESA_FORMAT_RGBA8888) ||
- (!littleEndian && dstFormat == MESA_FORMAT_RGBA8888_REV)) {
- dstmap[3] = 0;
- dstmap[2] = 1;
- dstmap[1] = 2;
- dstmap[0] = 3;
- }
- else {
- dstmap[3] = 3;
- dstmap[2] = 2;
- dstmap[1] = 1;
- dstmap[0] = 0;
- }
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 4,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- if (dstFormat == MESA_FORMAT_RGBA8888) {
- for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]),
- CHAN_TO_UBYTE(src[ACOMP]) );
- src += 4;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]),
- CHAN_TO_UBYTE(src[ACOMP]) );
- src += 4;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_argb8888(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = GL_RGBA;
-
- ASSERT(dstFormat == MESA_FORMAT_ARGB8888 ||
- dstFormat == MESA_FORMAT_ARGB8888_REV ||
- dstFormat == MESA_FORMAT_XRGB8888 ||
- dstFormat == MESA_FORMAT_XRGB8888_REV );
- ASSERT(texelBytes == 4);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- (dstFormat == MESA_FORMAT_ARGB8888 ||
- dstFormat == MESA_FORMAT_XRGB8888) &&
- baseInternalFormat == GL_RGBA &&
- srcFormat == GL_BGRA &&
- ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
- srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
- /* simple memcpy path (little endian) */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- (dstFormat == MESA_FORMAT_ARGB8888_REV ||
- dstFormat == MESA_FORMAT_XRGB8888_REV) &&
- baseInternalFormat == GL_RGBA &&
- srcFormat == GL_BGRA &&
- ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
- srcType == GL_UNSIGNED_INT_8_8_8_8)) {
- /* simple memcpy path (big endian) */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- (dstFormat == MESA_FORMAT_ARGB8888 ||
- dstFormat == MESA_FORMAT_XRGB8888) &&
- srcFormat == GL_RGB &&
- (baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB) &&
- srcType == GL_UNSIGNED_BYTE) {
- int img, row, col;
- for (img = 0; img < srcDepth; img++) {
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLuint *d4 = (GLuint *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- d4[col] = PACK_COLOR_8888(0xff,
- srcRow[col * 3 + RCOMP],
- srcRow[col * 3 + GCOMP],
- srcRow[col * 3 + BCOMP]);
- }
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- }
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_ARGB8888 &&
- srcFormat == GL_RGBA &&
- baseInternalFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_BYTE) {
- /* same as above case, but src data has alpha too */
- GLint img, row, col;
- /* For some reason, streaming copies to write-combined regions
- * are extremely sensitive to the characteristics of how the
- * source data is retrieved. By reordering the source reads to
- * be in-order, the speed of this operation increases by half.
- * Strangely the same isn't required for the RGB path, above.
- */
- for (img = 0; img < srcDepth; img++) {
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLuint *d4 = (GLuint *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- d4[col] = PACK_COLOR_8888(srcRow[col * 4 + ACOMP],
- srcRow[col * 4 + RCOMP],
- srcRow[col * 4 + GCOMP],
- srcRow[col * 4 + BCOMP]);
- }
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- }
- }
- else if (!ctx->_ImageTransferState &&
- (srcType == GL_UNSIGNED_BYTE ||
- srcType == GL_UNSIGNED_INT_8_8_8_8 ||
- srcType == GL_UNSIGNED_INT_8_8_8_8_REV) &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
-
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) ||
- (littleEndian && dstFormat == MESA_FORMAT_XRGB8888) ||
- (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) ||
- (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV)) {
- dstmap[3] = 3; /* alpha */
- dstmap[2] = 0; /* red */
- dstmap[1] = 1; /* green */
- dstmap[0] = 2; /* blue */
- }
- else {
- assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) ||
- (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888) ||
- (littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV) ||
- (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888));
- dstmap[3] = 2;
- dstmap[2] = 1;
- dstmap[1] = 0;
- dstmap[0] = 3;
- }
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 4,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- if (dstFormat == MESA_FORMAT_ARGB8888) {
- for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
- src += 4;
- }
- }
- else if (dstFormat == MESA_FORMAT_XRGB8888) {
- for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888( 0xff,
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
- src += 4;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
- src += 4;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_rgb888(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGB888);
- ASSERT(texelBytes == 3);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == GL_RGB &&
- srcFormat == GL_BGR &&
- srcType == GL_UNSIGNED_BYTE &&
- littleEndian) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- srcFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_BYTE) {
- /* extract RGB from RGBA */
- GLint img, row, col;
- for (img = 0; img < srcDepth; img++) {
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP];
- dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP];
- dstRow[col * 3 + 2] = srcRow[col * 4 + RCOMP];
- }
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- }
- }
- else if (!ctx->_ImageTransferState &&
- srcType == GL_UNSIGNED_BYTE &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
-
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- dstmap[0] = 2;
- dstmap[1] = 1;
- dstmap[2] = 0;
- dstmap[3] = ONE; /* ? */
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 3,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src = (const GLchan *) tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
-#if 0
- if (littleEndian) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]);
- dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
- dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]);
- srcUB += 3;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = srcUB[BCOMP];
- dstRow[col * 3 + 1] = srcUB[GCOMP];
- dstRow[col * 3 + 2] = srcUB[RCOMP];
- srcUB += 3;
- }
- }
-#else
- for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[BCOMP]);
- dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
- dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[RCOMP]);
- src += 3;
- }
-#endif
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_bgr888(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_BGR888);
- ASSERT(texelBytes == 3);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == GL_RGB &&
- srcFormat == GL_RGB &&
- srcType == GL_UNSIGNED_BYTE &&
- littleEndian) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- srcFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_BYTE) {
- /* extract BGR from RGBA */
- int img, row, col;
- for (img = 0; img < srcDepth; img++) {
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP];
- dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP];
- dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP];
- }
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- }
- }
- else if (!ctx->_ImageTransferState &&
- srcType == GL_UNSIGNED_BYTE &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
-
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- dstmap[0] = 0;
- dstmap[1] = 1;
- dstmap[2] = 2;
- dstmap[3] = ONE; /* ? */
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 3,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src = (const GLchan *) tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]);
- dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
- dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]);
- src += 3;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_argb4444(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_ARGB4444 ||
- dstFormat == MESA_FORMAT_ARGB4444_REV);
- ASSERT(texelBytes == 2);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_ARGB4444 &&
- baseInternalFormat == GL_RGBA &&
- srcFormat == GL_BGRA &&
- srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- if (dstFormat == MESA_FORMAT_ARGB4444) {
- for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
- src += 4;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_4444_REV( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
- src += 4;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-static GLboolean
-_mesa_texstore_rgba5551(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA5551);
- ASSERT(texelBytes == 2);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_RGBA5551 &&
- baseInternalFormat == GL_RGBA &&
- srcFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_SHORT_5_5_5_1) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src =tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_5551( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]),
- CHAN_TO_UBYTE(src[ACOMP]) );
- src += 4;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-static GLboolean
-_mesa_texstore_argb1555(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_ARGB1555 ||
- dstFormat == MESA_FORMAT_ARGB1555_REV);
- ASSERT(texelBytes == 2);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_ARGB1555 &&
- baseInternalFormat == GL_RGBA &&
- srcFormat == GL_BGRA &&
- srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src =tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- if (dstFormat == MESA_FORMAT_ARGB1555) {
- for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_1555( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
- src += 4;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_1555_REV( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
- src += 4;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_argb2101010(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_ARGB2101010);
- ASSERT(texelBytes == 4);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_ARGB2101010 &&
- srcFormat == GL_BGRA &&
- srcType == GL_UNSIGNED_INT_2_10_10_10_REV &&
- baseInternalFormat == GL_RGBA) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- if (baseInternalFormat == GL_RGBA) {
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLushort a,r,g,b;
-
- UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
- dstUI[col] = PACK_COLOR_2101010_US(a, r, g, b);
- src += 4;
- }
- dstRow += dstRowStride;
- }
- } else if (baseInternalFormat == GL_RGB) {
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLushort r,g,b;
-
- UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
- dstUI[col] = PACK_COLOR_2101010_US(0xffff, r, g, b);
- src += 4;
- }
- dstRow += dstRowStride;
- }
- } else {
- ASSERT(0);
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Do texstore for 2-channel, 4-bit/channel, unsigned normalized formats.
- */
-static GLboolean
-_mesa_texstore_unorm44(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_AL44);
- ASSERT(texelBytes == 1);
-
- {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLubyte *dstUS = (GLubyte *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance, src[1] is alpha */
- dstUS[col] = PACK_COLOR_44( CHAN_TO_UBYTE(src[1]),
- CHAN_TO_UBYTE(src[0]) );
- src += 2;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Do texstore for 2-channel, 8-bit/channel, unsigned normalized formats.
- */
-static GLboolean
-_mesa_texstore_unorm88(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_AL88 ||
- dstFormat == MESA_FORMAT_AL88_REV ||
- dstFormat == MESA_FORMAT_RG88 ||
- dstFormat == MESA_FORMAT_RG88_REV);
- ASSERT(texelBytes == 2);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- (dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_RG88) &&
- baseInternalFormat == srcFormat &&
- srcType == GL_UNSIGNED_BYTE &&
- littleEndian) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- littleEndian &&
- srcType == GL_UNSIGNED_BYTE &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- if (dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_AL88_REV) {
- if ((littleEndian && dstFormat == MESA_FORMAT_AL88) ||
- (!littleEndian && dstFormat == MESA_FORMAT_AL88_REV)) {
- dstmap[0] = 0;
- dstmap[1] = 3;
- }
- else {
- dstmap[0] = 3;
- dstmap[1] = 0;
- }
- }
- else {
- if ((littleEndian && dstFormat == MESA_FORMAT_RG88) ||
- (!littleEndian && dstFormat == MESA_FORMAT_RG88_REV)) {
- dstmap[0] = 0;
- dstmap[1] = 1;
- }
- else {
- dstmap[0] = 1;
- dstmap[1] = 0;
- }
- }
- dstmap[2] = ZERO; /* ? */
- dstmap[3] = ONE; /* ? */
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 2,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- if (dstFormat == MESA_FORMAT_AL88 ||
- dstFormat == MESA_FORMAT_RG88) {
- for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance, src[1] is alpha */
- dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[1]),
- CHAN_TO_UBYTE(src[0]) );
- src += 2;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance, src[1] is alpha */
- dstUS[col] = PACK_COLOR_88_REV( CHAN_TO_UBYTE(src[1]),
- CHAN_TO_UBYTE(src[0]) );
- src += 2;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Do texstore for 2-channel, 16-bit/channel, unsigned normalized formats.
- */
-static GLboolean
-_mesa_texstore_unorm1616(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_AL1616 ||
- dstFormat == MESA_FORMAT_AL1616_REV ||
- dstFormat == MESA_FORMAT_RG1616 ||
- dstFormat == MESA_FORMAT_RG1616_REV);
- ASSERT(texelBytes == 4);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- (dstFormat == MESA_FORMAT_AL1616 || dstFormat == MESA_FORMAT_RG1616) &&
- baseInternalFormat == srcFormat &&
- srcType == GL_UNSIGNED_SHORT &&
- littleEndian) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- if (dstFormat == MESA_FORMAT_AL1616 ||
- dstFormat == MESA_FORMAT_RG1616) {
- for (col = 0; col < srcWidth; col++) {
- GLushort l, a;
-
- UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
- UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
- dstUI[col] = PACK_COLOR_1616(a, l);
- src += 2;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- GLushort l, a;
-
- UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
- UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
- dstUI[col] = PACK_COLOR_1616_REV(a, l);
- src += 2;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* Texstore for R16, A16, L16, I16. */
-static GLboolean
-_mesa_texstore_unorm16(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_R16 ||
- dstFormat == MESA_FORMAT_A16 ||
- dstFormat == MESA_FORMAT_L16 ||
- dstFormat == MESA_FORMAT_I16);
- ASSERT(texelBytes == 2);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == srcFormat &&
- srcType == GL_UNSIGNED_SHORT &&
- littleEndian) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLushort r;
-
- UNCLAMPED_FLOAT_TO_USHORT(r, src[0]);
- dstUS[col] = r;
- src += 1;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_rgba_16(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_16);
- ASSERT(texelBytes == 8);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == GL_RGBA &&
- srcFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_SHORT) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLushort r, g, b, a;
-
- UNCLAMPED_FLOAT_TO_USHORT(r, src[0]);
- UNCLAMPED_FLOAT_TO_USHORT(g, src[1]);
- UNCLAMPED_FLOAT_TO_USHORT(b, src[2]);
- UNCLAMPED_FLOAT_TO_USHORT(a, src[3]);
- dstUS[col*4+0] = r;
- dstUS[col*4+1] = g;
- dstUS[col*4+2] = b;
- dstUS[col*4+3] = a;
- src += 4;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_SIGNED_R_16 ||
- dstFormat == MESA_FORMAT_SIGNED_RG_16 ||
- dstFormat == MESA_FORMAT_SIGNED_RGB_16 ||
- dstFormat == MESA_FORMAT_SIGNED_RGBA_16);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == GL_RGBA &&
- dstFormat == MESA_FORMAT_SIGNED_RGBA_16 &&
- srcFormat == GL_RGBA &&
- srcType == GL_SHORT) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- const GLuint comps = _mesa_get_format_bytes(dstFormat) / 2;
- GLint img, row, col;
-
- if (!tempImage)
- return GL_FALSE;
-
- /* Note: tempImage is always float[4] / RGBA. We convert to 1, 2,
- * 3 or 4 components/pixel here.
- */
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLshort *dstRowS = (GLshort *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLuint c;
- for (c = 0; c < comps; c++) {
- GLshort p;
- UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 4 + c]);
- dstRowS[col * comps + c] = p;
- }
- }
- dstRow += dstRowStride;
- src += 4 * srcWidth;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_rgb332(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGB332);
- ASSERT(texelBytes == 1);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == GL_RGB &&
- srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col] = PACK_COLOR_332( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
- src += 3;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8.
- */
-static GLboolean
-_mesa_texstore_a8(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_A8 ||
- dstFormat == MESA_FORMAT_L8 ||
- dstFormat == MESA_FORMAT_I8 ||
- dstFormat == MESA_FORMAT_R8);
- ASSERT(texelBytes == 1);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == srcFormat &&
- srcType == GL_UNSIGNED_BYTE) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- srcType == GL_UNSIGNED_BYTE &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- if (dstFormat == MESA_FORMAT_A8) {
- dstmap[0] = 3;
- }
- else {
- dstmap[0] = 0;
- }
- dstmap[1] = ZERO; /* ? */
- dstmap[2] = ZERO; /* ? */
- dstmap[3] = ONE; /* ? */
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 1,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- /* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLchan *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col] = CHAN_TO_UBYTE(src[col]);
- }
- dstRow += dstRowStride;
- src += srcWidth;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-
-static GLboolean
-_mesa_texstore_ci8(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
-
- (void) dims; (void) baseInternalFormat;
- ASSERT(dstFormat == MESA_FORMAT_CI8);
- ASSERT(texelBytes == 1);
- ASSERT(baseInternalFormat == GL_COLOR_INDEX);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- srcFormat == GL_COLOR_INDEX &&
- srcType == GL_UNSIGNED_BYTE) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- GLint img, row;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- const GLvoid *src = _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
- _mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow,
- srcType, src, srcPacking,
- ctx->_ImageTransferState);
- dstRow += dstRowStride;
- }
- }
- }
- return GL_TRUE;
-}
-
-
-/**
- * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV.
- */
-static GLboolean
-_mesa_texstore_ycbcr(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
-
- (void) ctx; (void) dims; (void) baseInternalFormat;
-
- ASSERT((dstFormat == MESA_FORMAT_YCBCR) ||
- (dstFormat == MESA_FORMAT_YCBCR_REV));
- ASSERT(texelBytes == 2);
- ASSERT(ctx->Extensions.MESA_ycbcr_texture);
- ASSERT(srcFormat == GL_YCBCR_MESA);
- ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) ||
- (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA));
- ASSERT(baseInternalFormat == GL_YCBCR_MESA);
-
- /* always just memcpy since no pixel transfer ops apply */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
-
- /* Check if we need byte swapping */
- /* XXX the logic here _might_ be wrong */
- if (srcPacking->SwapBytes ^
- (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^
- (dstFormat == MESA_FORMAT_YCBCR_REV) ^
- !littleEndian) {
- GLint img, row;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- _mesa_swap2((GLushort *) dstRow, srcWidth);
- dstRow += dstRowStride;
- }
- }
- }
- return GL_TRUE;
-}
-
-static GLboolean
-_mesa_texstore_dudv8(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_DUDV8);
- ASSERT(texelBytes == 2);
- ASSERT(ctx->Extensions.ATI_envmap_bumpmap);
- ASSERT((srcFormat == GL_DU8DV8_ATI) ||
- (srcFormat == GL_DUDV_ATI));
- ASSERT(baseInternalFormat == GL_DUDV_ATI);
-
- if (!srcPacking->SwapBytes && srcType == GL_BYTE &&
- littleEndian) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (srcType == GL_BYTE) {
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- if (littleEndian) {
- dstmap[0] = 0;
- dstmap[1] = 3;
- }
- else {
- dstmap[0] = 3;
- dstmap[1] = 0;
- }
- dstmap[2] = ZERO; /* ? */
- dstmap[3] = ONE; /* ? */
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- GL_LUMINANCE_ALPHA, /* hack */
- GL_UNSIGNED_BYTE, /* hack */
- GL_LUMINANCE_ALPHA, /* hack */
- dstmap, 2,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- /* general path - note this is defined for 2d textures only */
- const GLint components = _mesa_components_in_format(baseInternalFormat);
- const GLint srcStride = _mesa_image_row_stride(srcPacking, srcWidth,
- srcFormat, srcType);
- GLbyte *tempImage, *dst, *src;
- GLint row;
-
- tempImage = (GLbyte *) malloc(srcWidth * srcHeight * srcDepth
- * components * sizeof(GLbyte));
- if (!tempImage)
- return GL_FALSE;
-
- src = (GLbyte *) _mesa_image_address(dims, srcPacking, srcAddr,
- srcWidth, srcHeight,
- srcFormat, srcType,
- 0, 0, 0);
-
- dst = tempImage;
- for (row = 0; row < srcHeight; row++) {
- _mesa_unpack_dudv_span_byte(ctx, srcWidth, baseInternalFormat,
- dst, srcFormat, srcType, src,
- srcPacking, 0);
- dst += srcWidth * components;
- src += srcStride;
- }
-
- src = tempImage;
- dst = (GLbyte *) dstAddr
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- memcpy(dst, src, srcWidth * texelBytes);
- dst += dstRowStride;
- src += srcWidth * texelBytes;
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store a texture in MESA_FORMAT_SIGNED_R8 format.
- */
-static GLboolean
-_mesa_texstore_signed_r8(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_SIGNED_R8);
- ASSERT(texelBytes == 1);
-
- /* XXX look at adding optimized paths */
- {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *srcRow = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLubyte *dstB = (GLubyte *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- dstB[col] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]);
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store a texture in MESA_FORMAT_SIGNED_RG88 format.
- */
-static GLboolean
-_mesa_texstore_signed_rg88(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG88);
- ASSERT(texelBytes == 1);
-
- /* XXX look at adding optimized paths */
- {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *srcRow = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_88(FLOAT_TO_BYTE_TEX(srcRow[RCOMP]),
- FLOAT_TO_BYTE_TEX(srcRow[GCOMP]));
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store a texture in MESA_FORMAT_SIGNED_RGBX8888.
- */
-static GLboolean
-_mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBX8888);
- ASSERT(texelBytes == 4);
-
- {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *srcRow = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]),
- FLOAT_TO_BYTE_TEX(srcRow[GCOMP]),
- FLOAT_TO_BYTE_TEX(srcRow[BCOMP]),
- 0xff );
- srcRow += 4;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-
-/**
- * Store a texture in MESA_FORMAT_SIGNED_RGBA8888 or
- * MESA_FORMAT_SIGNED_RGBA8888_REV
- */
-static GLboolean
-_mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBA8888 ||
- dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV);
- ASSERT(texelBytes == 4);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_SIGNED_RGBA8888 &&
- baseInternalFormat == GL_RGBA &&
- ((srcFormat == GL_RGBA && srcType == GL_BYTE && !littleEndian) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && littleEndian))) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV &&
- baseInternalFormat == GL_RGBA &&
- ((srcFormat == GL_RGBA && srcType == GL_BYTE && littleEndian) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- (srcType == GL_BYTE) &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
-
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- if ((littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888) ||
- (!littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV)) {
- dstmap[3] = 0;
- dstmap[2] = 1;
- dstmap[1] = 2;
- dstmap[0] = 3;
- }
- else {
- dstmap[3] = 3;
- dstmap[2] = 2;
- dstmap[1] = 1;
- dstmap[0] = 0;
- }
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 4,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *srcRow = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- if (dstFormat == MESA_FORMAT_SIGNED_RGBA8888) {
- for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]),
- FLOAT_TO_BYTE_TEX(srcRow[GCOMP]),
- FLOAT_TO_BYTE_TEX(srcRow[BCOMP]),
- FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) );
- srcRow += 4;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888_REV( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]),
- FLOAT_TO_BYTE_TEX(srcRow[GCOMP]),
- FLOAT_TO_BYTE_TEX(srcRow[BCOMP]),
- FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) );
- srcRow += 4;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store a combined depth/stencil texture image.
- */
-static GLboolean
-_mesa_texstore_z24_s8(TEXSTORE_PARAMS)
-{
- const GLuint depthScale = 0xffffff;
- const GLint srcRowStride
- = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
- / sizeof(GLuint);
- GLint img, row;
-
- ASSERT(dstFormat == MESA_FORMAT_Z24_S8);
- ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT);
- ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT);
-
- if (srcFormat != GL_DEPTH_COMPONENT && ctx->Pixel.DepthScale == 1.0f &&
- ctx->Pixel.DepthBias == 0.0f &&
- !srcPacking->SwapBytes) {
- /* simple path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (srcFormat == GL_DEPTH_COMPONENT) {
- /* In case we only upload depth we need to preserve the stencil */
- for (img = 0; img < srcDepth; img++) {
- GLuint *dstRow = (GLuint *) dstAddr
- + dstImageOffsets[dstZoffset + img]
- + dstYoffset * dstRowStride / sizeof(GLuint)
- + dstXoffset;
- const GLuint *src
- = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
- srcWidth, srcHeight,
- srcFormat, srcType,
- img, 0, 0);
- for (row = 0; row < srcHeight; row++) {
- GLuint depth[MAX_WIDTH];
- GLubyte stencil[MAX_WIDTH];
- GLint i;
- GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE;
-
- if (srcFormat == GL_DEPTH_COMPONENT) { /* preserve stencil */
- keepstencil = GL_TRUE;
- }
- else if (srcFormat == GL_STENCIL_INDEX) { /* preserve depth */
- keepdepth = GL_TRUE;
- }
-
- if (keepdepth == GL_FALSE)
- /* the 24 depth bits will be in the low position: */
- _mesa_unpack_depth_span(ctx, srcWidth,
- GL_UNSIGNED_INT, /* dst type */
- keepstencil ? depth : dstRow, /* dst addr */
- depthScale,
- srcType, src, srcPacking);
-
- if (keepstencil == GL_FALSE)
- /* get the 8-bit stencil values */
- _mesa_unpack_stencil_span(ctx, srcWidth,
- GL_UNSIGNED_BYTE, /* dst type */
- stencil, /* dst addr */
- srcType, src, srcPacking,
- ctx->_ImageTransferState);
-
- for (i = 0; i < srcWidth; i++) {
- if (keepstencil)
- dstRow[i] = depth[i] << 8 | (dstRow[i] & 0x000000FF);
- else
- dstRow[i] = (dstRow[i] & 0xFFFFFF00) | (stencil[i] & 0xFF);
- }
-
- src += srcRowStride;
- dstRow += dstRowStride / sizeof(GLuint);
- }
- }
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store a combined depth/stencil texture image.
- */
-static GLboolean
-_mesa_texstore_s8_z24(TEXSTORE_PARAMS)
-{
- const GLuint depthScale = 0xffffff;
- const GLint srcRowStride
- = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
- / sizeof(GLuint);
- GLint img, row;
-
- ASSERT(dstFormat == MESA_FORMAT_S8_Z24);
- ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT ||
- srcFormat == GL_DEPTH_COMPONENT ||
- srcFormat == GL_STENCIL_INDEX);
- ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT ||
- srcType == GL_UNSIGNED_INT_24_8_EXT);
-
- for (img = 0; img < srcDepth; img++) {
- GLuint *dstRow = (GLuint *) dstAddr
- + dstImageOffsets[dstZoffset + img]
- + dstYoffset * dstRowStride / sizeof(GLuint)
- + dstXoffset;
- const GLuint *src
- = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
- srcWidth, srcHeight,
- srcFormat, srcType,
- img, 0, 0);
- for (row = 0; row < srcHeight; row++) {
- GLuint depth[MAX_WIDTH];
- GLubyte stencil[MAX_WIDTH];
- GLint i;
- GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE;
-
- if (srcFormat == GL_DEPTH_COMPONENT) { /* preserve stencil */
- keepstencil = GL_TRUE;
- }
- else if (srcFormat == GL_STENCIL_INDEX) { /* preserve depth */
- keepdepth = GL_TRUE;
- }
-
- if (keepdepth == GL_FALSE)
- /* the 24 depth bits will be in the low position: */
- _mesa_unpack_depth_span(ctx, srcWidth,
- GL_UNSIGNED_INT, /* dst type */
- keepstencil ? depth : dstRow, /* dst addr */
- depthScale,
- srcType, src, srcPacking);
-
- if (keepstencil == GL_FALSE)
- /* get the 8-bit stencil values */
- _mesa_unpack_stencil_span(ctx, srcWidth,
- GL_UNSIGNED_BYTE, /* dst type */
- stencil, /* dst addr */
- srcType, src, srcPacking,
- ctx->_ImageTransferState);
-
- /* merge stencil values into depth values */
- for (i = 0; i < srcWidth; i++) {
- if (keepstencil)
- dstRow[i] = depth[i] | (dstRow[i] & 0xFF000000);
- else
- dstRow[i] = (dstRow[i] & 0xFFFFFF) | (stencil[i] << 24);
-
- }
- src += srcRowStride;
- dstRow += dstRowStride / sizeof(GLuint);
- }
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store simple 8-bit/value stencil texture data.
- */
-static GLboolean
-_mesa_texstore_s8(TEXSTORE_PARAMS)
-{
- ASSERT(dstFormat == MESA_FORMAT_S8);
- ASSERT(srcFormat == GL_STENCIL_INDEX);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == srcFormat &&
- srcType == GL_UNSIGNED_BYTE) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- const GLint srcRowStride
- = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
- / sizeof(GLuint);
- GLint img, row;
-
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img]
- + dstYoffset * dstRowStride / sizeof(GLuint)
- + dstXoffset;
- const GLuint *src
- = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
- srcWidth, srcHeight,
- srcFormat, srcType,
- img, 0, 0);
- for (row = 0; row < srcHeight; row++) {
- GLubyte stencil[MAX_WIDTH];
- GLint i;
-
- /* get the 8-bit stencil values */
- _mesa_unpack_stencil_span(ctx, srcWidth,
- GL_UNSIGNED_BYTE, /* dst type */
- stencil, /* dst addr */
- srcType, src, srcPacking,
- ctx->_ImageTransferState);
- /* merge stencil values into depth values */
- for (i = 0; i < srcWidth; i++)
- dstRow[i] = stencil[i];
-
- src += srcRowStride;
- dstRow += dstRowStride / sizeof(GLubyte);
- }
- }
-
- }
-
- return GL_TRUE;
-}
-
-
-/**
- * Store an image in any of the formats:
- * _mesa_texformat_rgba_float32
- * _mesa_texformat_rgb_float32
- * _mesa_texformat_alpha_float32
- * _mesa_texformat_luminance_float32
- * _mesa_texformat_luminance_alpha_float32
- * _mesa_texformat_intensity_float32
- */
-static GLboolean
-_mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- const GLint components = _mesa_components_in_format(baseFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT32 ||
- dstFormat == MESA_FORMAT_RGB_FLOAT32 ||
- dstFormat == MESA_FORMAT_ALPHA_FLOAT32 ||
- dstFormat == MESA_FORMAT_LUMINANCE_FLOAT32 ||
- dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32 ||
- dstFormat == MESA_FORMAT_INTENSITY_FLOAT32);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLfloat));
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == srcFormat &&
- srcType == GL_FLOAT) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *srcRow = tempImage;
- GLint bytesPerRow;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- bytesPerRow = srcWidth * components * sizeof(GLfloat);
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- memcpy(dstRow, srcRow, bytesPerRow);
- dstRow += dstRowStride;
- srcRow += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-
-/**
- * As above, but store 16-bit floats.
- */
-static GLboolean
-_mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- const GLint components = _mesa_components_in_format(baseFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT16 ||
- dstFormat == MESA_FORMAT_RGB_FLOAT16 ||
- dstFormat == MESA_FORMAT_ALPHA_FLOAT16 ||
- dstFormat == MESA_FORMAT_LUMINANCE_FLOAT16 ||
- dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16 ||
- dstFormat == MESA_FORMAT_INTENSITY_FLOAT16);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLhalfARB));
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- baseInternalFormat == srcFormat &&
- srcType == GL_HALF_FLOAT_ARB) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLhalfARB *dstTexel = (GLhalfARB *) dstRow;
- GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = _mesa_float_to_half(src[i]);
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, signed int8 */
-static GLboolean
-_mesa_texstore_rgba_int8(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- const GLint components = _mesa_components_in_format(baseFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_INT8);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLbyte));
-
- /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
- * to integer formats.
- */
- if (!srcPacking->SwapBytes &&
- baseInternalFormat == srcFormat &&
- srcType == GL_BYTE) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking, 0x0);
- const GLfloat *src = tempImage;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLbyte *dstTexel = (GLbyte *) dstRow;
- GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLbyte) src[i];
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, signed int16 */
-static GLboolean
-_mesa_texstore_rgba_int16(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- const GLint components = _mesa_components_in_format(baseFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_INT16);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLshort));
-
- /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
- * to integer formats.
- */
- if (!srcPacking->SwapBytes &&
- baseInternalFormat == srcFormat &&
- srcType == GL_SHORT) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking, 0x0);
- const GLfloat *src = tempImage;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLshort *dstTexel = (GLshort *) dstRow;
- GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLint) src[i];
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, signed int32 */
-static GLboolean
-_mesa_texstore_rgba_int32(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- const GLint components = _mesa_components_in_format(baseFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_INT32);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLint));
-
- /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
- * to integer formats.
- */
- if (!srcPacking->SwapBytes &&
- baseInternalFormat == srcFormat &&
- srcType == GL_INT) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLfloat *tempImage = make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking, 0x0);
- const GLfloat *src = tempImage;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLint *dstTexel = (GLint *) dstRow;
- GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLint) src[i];
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, unsigned int8 */
-static GLboolean
-_mesa_texstore_rgba_uint8(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- const GLint components = _mesa_components_in_format(baseFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT8);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLubyte));
-
- /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
- * to integer formats.
- */
- if (!srcPacking->SwapBytes &&
- baseInternalFormat == srcFormat &&
- srcType == GL_UNSIGNED_BYTE) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLuint *tempImage =
- make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- const GLuint *src = tempImage;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLubyte *dstTexel = (GLubyte *) dstRow;
- GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLubyte) CLAMP(src[i], 0, 0xff);
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, unsigned int16 */
-static GLboolean
-_mesa_texstore_rgba_uint16(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- const GLint components = _mesa_components_in_format(baseFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT16);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLushort));
-
- /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
- * to integer formats.
- */
- if (!srcPacking->SwapBytes &&
- baseInternalFormat == srcFormat &&
- srcType == GL_UNSIGNED_SHORT) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLuint *tempImage =
- make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- const GLuint *src = tempImage;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstTexel = (GLushort *) dstRow;
- GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLushort) CLAMP(src[i], 0, 0xffff);
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, unsigned int32 */
-static GLboolean
-_mesa_texstore_rgba_uint32(TEXSTORE_PARAMS)
-{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- const GLint components = _mesa_components_in_format(baseFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT32);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLuint));
-
- /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
- * to integer formats.
- */
- if (!srcPacking->SwapBytes &&
- baseInternalFormat == srcFormat &&
- srcType == GL_UNSIGNED_INT) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else {
- /* general path */
- const GLuint *tempImage =
- make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- const GLuint *src = tempImage;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstTexel = (GLuint *) dstRow;
- GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = src[i];
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-
-
-#if FEATURE_EXT_texture_sRGB
-static GLboolean
-_mesa_texstore_srgb8(TEXSTORE_PARAMS)
-{
- gl_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_SRGB8);
-
- /* reuse normal rgb texstore code */
- newDstFormat = MESA_FORMAT_RGB888;
-
- k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat,
- newDstFormat, dstAddr,
- dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-
-static GLboolean
-_mesa_texstore_srgba8(TEXSTORE_PARAMS)
-{
- gl_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_SRGBA8);
-
- /* reuse normal rgba texstore code */
- newDstFormat = MESA_FORMAT_RGBA8888;
- k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat,
- newDstFormat, dstAddr,
- dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-
-static GLboolean
-_mesa_texstore_sargb8(TEXSTORE_PARAMS)
-{
- gl_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_SARGB8);
-
- /* reuse normal rgba texstore code */
- newDstFormat = MESA_FORMAT_ARGB8888;
-
- k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat,
- newDstFormat, dstAddr,
- dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-
-static GLboolean
-_mesa_texstore_sl8(TEXSTORE_PARAMS)
-{
- gl_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_SL8);
-
- newDstFormat = MESA_FORMAT_L8;
-
- /* _mesa_textore_a8 handles luminance8 too */
- k = _mesa_texstore_a8(ctx, dims, baseInternalFormat,
- newDstFormat, dstAddr,
- dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-
-static GLboolean
-_mesa_texstore_sla8(TEXSTORE_PARAMS)
-{
- gl_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_SLA8);
-
- /* reuse normal luminance/alpha texstore code */
- newDstFormat = MESA_FORMAT_AL88;
-
- k = _mesa_texstore_unorm88(ctx, dims, baseInternalFormat,
- newDstFormat, dstAddr,
- dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-#else
-
-/* these are used only in texstore_funcs[] below */
-#define _mesa_texstore_srgb8 NULL
-#define _mesa_texstore_srgba8 NULL
-#define _mesa_texstore_sargb8 NULL
-#define _mesa_texstore_sl8 NULL
-#define _mesa_texstore_sla8 NULL
-
-#endif /* FEATURE_EXT_texture_sRGB */
-
-
-
-
-/**
- * Table mapping MESA_FORMAT_* to _mesa_texstore_*()
- * XXX this is somewhat temporary.
- */
-static const struct {
- gl_format Name;
- StoreTexImageFunc Store;
-}
-texstore_funcs[MESA_FORMAT_COUNT] =
-{
- { MESA_FORMAT_NONE, NULL },
- { MESA_FORMAT_RGBA8888, _mesa_texstore_rgba8888 },
- { MESA_FORMAT_RGBA8888_REV, _mesa_texstore_rgba8888 },
- { MESA_FORMAT_ARGB8888, _mesa_texstore_argb8888 },
- { MESA_FORMAT_ARGB8888_REV, _mesa_texstore_argb8888 },
- { MESA_FORMAT_XRGB8888, _mesa_texstore_argb8888 },
- { MESA_FORMAT_XRGB8888_REV, _mesa_texstore_argb8888 },
- { MESA_FORMAT_RGB888, _mesa_texstore_rgb888 },
- { MESA_FORMAT_BGR888, _mesa_texstore_bgr888 },
- { MESA_FORMAT_RGB565, _mesa_texstore_rgb565 },
- { MESA_FORMAT_RGB565_REV, _mesa_texstore_rgb565 },
- { MESA_FORMAT_ARGB4444, _mesa_texstore_argb4444 },
- { MESA_FORMAT_ARGB4444_REV, _mesa_texstore_argb4444 },
- { MESA_FORMAT_RGBA5551, _mesa_texstore_rgba5551 },
- { MESA_FORMAT_ARGB1555, _mesa_texstore_argb1555 },
- { MESA_FORMAT_ARGB1555_REV, _mesa_texstore_argb1555 },
- { MESA_FORMAT_AL44, _mesa_texstore_unorm44 },
- { MESA_FORMAT_AL88, _mesa_texstore_unorm88 },
- { MESA_FORMAT_AL88_REV, _mesa_texstore_unorm88 },
- { MESA_FORMAT_AL1616, _mesa_texstore_unorm1616 },
- { MESA_FORMAT_AL1616_REV, _mesa_texstore_unorm1616 },
- { MESA_FORMAT_RGB332, _mesa_texstore_rgb332 },
- { MESA_FORMAT_A8, _mesa_texstore_a8 },
- { MESA_FORMAT_A16, _mesa_texstore_unorm16 },
- { MESA_FORMAT_L8, _mesa_texstore_a8 },
- { MESA_FORMAT_L16, _mesa_texstore_unorm16 },
- { MESA_FORMAT_I8, _mesa_texstore_a8 },
- { MESA_FORMAT_I16, _mesa_texstore_unorm16 },
- { MESA_FORMAT_CI8, _mesa_texstore_ci8 },
- { MESA_FORMAT_YCBCR, _mesa_texstore_ycbcr },
- { MESA_FORMAT_YCBCR_REV, _mesa_texstore_ycbcr },
- { MESA_FORMAT_R8, _mesa_texstore_a8 },
- { MESA_FORMAT_RG88, _mesa_texstore_unorm88 },
- { MESA_FORMAT_RG88_REV, _mesa_texstore_unorm88 },
- { MESA_FORMAT_R16, _mesa_texstore_unorm16 },
- { MESA_FORMAT_RG1616, _mesa_texstore_unorm1616 },
- { MESA_FORMAT_RG1616_REV, _mesa_texstore_unorm1616 },
- { MESA_FORMAT_ARGB2101010, _mesa_texstore_argb2101010 },
- { MESA_FORMAT_Z24_S8, _mesa_texstore_z24_s8 },
- { MESA_FORMAT_S8_Z24, _mesa_texstore_s8_z24 },
- { MESA_FORMAT_Z16, _mesa_texstore_z16 },
- { MESA_FORMAT_X8_Z24, _mesa_texstore_x8_z24 },
- { MESA_FORMAT_Z24_X8, _mesa_texstore_z24_x8 },
- { MESA_FORMAT_Z32, _mesa_texstore_z32 },
- { MESA_FORMAT_S8, _mesa_texstore_s8 },
- { MESA_FORMAT_SRGB8, _mesa_texstore_srgb8 },
- { MESA_FORMAT_SRGBA8, _mesa_texstore_srgba8 },
- { MESA_FORMAT_SARGB8, _mesa_texstore_sargb8 },
- { MESA_FORMAT_SL8, _mesa_texstore_sl8 },
- { MESA_FORMAT_SLA8, _mesa_texstore_sla8 },
- { MESA_FORMAT_SRGB_DXT1, _mesa_texstore_rgb_dxt1 },
- { MESA_FORMAT_SRGBA_DXT1, _mesa_texstore_rgba_dxt1 },
- { MESA_FORMAT_SRGBA_DXT3, _mesa_texstore_rgba_dxt3 },
- { MESA_FORMAT_SRGBA_DXT5, _mesa_texstore_rgba_dxt5 },
- { MESA_FORMAT_RGB_FXT1, _mesa_texstore_rgb_fxt1 },
- { MESA_FORMAT_RGBA_FXT1, _mesa_texstore_rgba_fxt1 },
- { MESA_FORMAT_RGB_DXT1, _mesa_texstore_rgb_dxt1 },
- { MESA_FORMAT_RGBA_DXT1, _mesa_texstore_rgba_dxt1 },
- { MESA_FORMAT_RGBA_DXT3, _mesa_texstore_rgba_dxt3 },
- { MESA_FORMAT_RGBA_DXT5, _mesa_texstore_rgba_dxt5 },
- { MESA_FORMAT_RGBA_FLOAT32, _mesa_texstore_rgba_float32 },
- { MESA_FORMAT_RGBA_FLOAT16, _mesa_texstore_rgba_float16 },
- { MESA_FORMAT_RGB_FLOAT32, _mesa_texstore_rgba_float32 },
- { MESA_FORMAT_RGB_FLOAT16, _mesa_texstore_rgba_float16 },
- { MESA_FORMAT_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 },
- { MESA_FORMAT_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 },
- { MESA_FORMAT_LUMINANCE_FLOAT32, _mesa_texstore_rgba_float32 },
- { MESA_FORMAT_LUMINANCE_FLOAT16, _mesa_texstore_rgba_float16 },
- { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 },
- { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 },
- { MESA_FORMAT_INTENSITY_FLOAT32, _mesa_texstore_rgba_float32 },
- { MESA_FORMAT_INTENSITY_FLOAT16, _mesa_texstore_rgba_float16 },
-
- { MESA_FORMAT_RGBA_INT8, _mesa_texstore_rgba_int8 },
- { MESA_FORMAT_RGBA_INT16, _mesa_texstore_rgba_int16 },
- { MESA_FORMAT_RGBA_INT32, _mesa_texstore_rgba_int32 },
- { MESA_FORMAT_RGBA_UINT8, _mesa_texstore_rgba_uint8 },
- { MESA_FORMAT_RGBA_UINT16, _mesa_texstore_rgba_uint16 },
- { MESA_FORMAT_RGBA_UINT32, _mesa_texstore_rgba_uint32 },
-
- { MESA_FORMAT_DUDV8, _mesa_texstore_dudv8 },
-
- { MESA_FORMAT_SIGNED_R8, _mesa_texstore_signed_r8 },
- { MESA_FORMAT_SIGNED_RG88, _mesa_texstore_signed_rg88 },
- { MESA_FORMAT_SIGNED_RGBX8888, _mesa_texstore_signed_rgbx8888 },
-
- { MESA_FORMAT_SIGNED_RGBA8888, _mesa_texstore_signed_rgba8888 },
- { MESA_FORMAT_SIGNED_RGBA8888_REV, _mesa_texstore_signed_rgba8888 },
-
- { MESA_FORMAT_SIGNED_R_16, _mesa_texstore_signed_rgba_16 },
- { MESA_FORMAT_SIGNED_RG_16, _mesa_texstore_signed_rgba_16 },
- { MESA_FORMAT_SIGNED_RGB_16, _mesa_texstore_signed_rgba_16 },
- { MESA_FORMAT_SIGNED_RGBA_16, _mesa_texstore_signed_rgba_16 },
- { MESA_FORMAT_RGBA_16, _mesa_texstore_rgba_16 }
-};
-
-
-static GLboolean
-_mesa_texstore_null(TEXSTORE_PARAMS)
-{
- (void) ctx; (void) dims;
- (void) baseInternalFormat;
- (void) dstFormat;
- (void) dstAddr;
- (void) dstXoffset; (void) dstYoffset; (void) dstZoffset;
- (void) dstRowStride; (void) dstImageOffsets;
- (void) srcWidth; (void) srcHeight; (void) srcDepth;
- (void) srcFormat; (void) srcType;
- (void) srcAddr;
- (void) srcPacking;
-
- /* should never happen */
- _mesa_problem(NULL, "_mesa_texstore_null() is called");
- return GL_FALSE;
-}
-
-
-/**
- * Return the StoreTexImageFunc pointer to store an image in the given format.
- */
-static StoreTexImageFunc
-_mesa_get_texstore_func(gl_format format)
-{
-#ifdef DEBUG
- GLuint i;
- for (i = 0; i < MESA_FORMAT_COUNT; i++) {
- ASSERT(texstore_funcs[i].Name == i);
- }
-#endif
- ASSERT(texstore_funcs[format].Name == format);
-
- if (texstore_funcs[format].Store)
- return texstore_funcs[format].Store;
- else
- return _mesa_texstore_null;
-}
-
-
-/**
- * Store user data into texture memory.
- * Called via glTex[Sub]Image1/2/3D()
- */
-GLboolean
-_mesa_texstore(TEXSTORE_PARAMS)
-{
- StoreTexImageFunc storeImage;
- GLboolean success;
-
- storeImage = _mesa_get_texstore_func(dstFormat);
-
- success = storeImage(ctx, dims, baseInternalFormat,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- return success;
-}
-
-
-/**
- * Check if an unpack PBO is active prior to fetching a texture image.
- * If so, do bounds checking and map the buffer into main memory.
- * Any errors detected will be recorded.
- * The caller _must_ call _mesa_unmap_teximage_pbo() too!
- */
-const GLvoid *
-_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *unpack,
- const char *funcName)
-{
- GLubyte *buf;
-
- if (!_mesa_is_bufferobj(unpack->BufferObj)) {
- /* no PBO */
- return pixels;
- }
- if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
- format, type, pixels)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)");
- return NULL;
- }
-
- buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
- GL_READ_ONLY_ARB, unpack->BufferObj);
- if (!buf) {
- _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped)");
- return NULL;
- }
-
- return ADD_POINTERS(buf, pixels);
-}
-
-
-/**
- * Check if an unpack PBO is active prior to fetching a compressed texture
- * image.
- * If so, do bounds checking and map the buffer into main memory.
- * Any errors detected will be recorded.
- * The caller _must_ call _mesa_unmap_teximage_pbo() too!
- */
-const GLvoid *
-_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx,
- GLsizei imageSize, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- const char *funcName)
-{
- GLubyte *buf;
-
- if (!_mesa_is_bufferobj(packing->BufferObj)) {
- /* not using a PBO - return pointer unchanged */
- return pixels;
- }
- if ((const GLubyte *) pixels + imageSize >
- ((const GLubyte *) 0) + packing->BufferObj->Size) {
- /* out of bounds read! */
- _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)");
- return NULL;
- }
-
- buf = (GLubyte*) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
- GL_READ_ONLY_ARB, packing->BufferObj);
- if (!buf) {
- _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped");
- return NULL;
- }
-
- return ADD_POINTERS(buf, pixels);
-}
-
-
-/**
- * This function must be called after either of the validate_pbo_*_teximage()
- * functions. It unmaps the PBO buffer if it was mapped earlier.
- */
-void
-_mesa_unmap_teximage_pbo(struct gl_context *ctx,
- const struct gl_pixelstore_attrib *unpack)
-{
- if (_mesa_is_bufferobj(unpack->BufferObj)) {
- ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
- unpack->BufferObj);
- }
-}
-
-
-/** Return texture size in bytes */
-static GLuint
-texture_size(const struct gl_texture_image *texImage)
-{
- GLuint sz = _mesa_format_image_size(texImage->TexFormat, texImage->Width,
- texImage->Height, texImage->Depth);
- return sz;
-}
-
-
-/** Return row stride in bytes */
-static GLuint
-texture_row_stride(const struct gl_texture_image *texImage)
-{
- GLuint stride = _mesa_format_row_stride(texImage->TexFormat,
- texImage->Width);
- return stride;
-}
-
-
-
-/**
- * This is the software fallback for Driver.TexImage1D()
- * and Driver.CopyTexImage1D().
- * \sa _mesa_store_teximage2d()
- */
-void
-_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint border,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- GLuint sizeInBytes;
- (void) border;
-
- /* allocate memory */
- sizeInBytes = texture_size(texImage);
- texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
- if (!texImage->Data) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
- return;
- }
-
- pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type,
- pixels, packing, "glTexImage1D");
- if (!pixels) {
- /* Note: we check for a NULL image pointer here, _after_ we allocated
- * memory for the texture. That's what the GL spec calls for.
- */
- return;
- }
- else {
- const GLint dstRowStride = 0;
- GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- texImage->ImageOffsets,
- width, 1, 1,
- format, type, pixels, packing);
- if (!success) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
- }
- }
-
- _mesa_unmap_teximage_pbo(ctx, packing);
-}
-
-
-/**
- * This is the software fallback for Driver.TexImage2D()
- * and Driver.CopyTexImage2D().
- *
- * This function is oriented toward storing images in main memory, rather
- * than VRAM. Device driver's can easily plug in their own replacement.
- */
-void
-_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint border,
- GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- GLuint sizeInBytes;
- (void) border;
-
- /* allocate memory */
- sizeInBytes = texture_size(texImage);
- texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
- if (!texImage->Data) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
- return;
- }
-
- pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
- pixels, packing, "glTexImage2D");
- if (!pixels) {
- /* Note: we check for a NULL image pointer here, _after_ we allocated
- * memory for the texture. That's what the GL spec calls for.
- */
- return;
- }
- else {
- GLint dstRowStride = texture_row_stride(texImage);
- GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- texImage->ImageOffsets,
- width, height, 1,
- format, type, pixels, packing);
- if (!success) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
- }
- }
-
- _mesa_unmap_teximage_pbo(ctx, packing);
-}
-
-
-
-/**
- * This is the software fallback for Driver.TexImage3D()
- * and Driver.CopyTexImage3D().
- * \sa _mesa_store_teximage2d()
- */
-void
-_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint depth, GLint border,
- GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- GLuint sizeInBytes;
- (void) border;
-
- /* allocate memory */
- sizeInBytes = texture_size(texImage);
- texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
- if (!texImage->Data) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
- return;
- }
-
- pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format,
- type, pixels, packing, "glTexImage3D");
- if (!pixels) {
- /* Note: we check for a NULL image pointer here, _after_ we allocated
- * memory for the texture. That's what the GL spec calls for.
- */
- return;
- }
- else {
- GLint dstRowStride = texture_row_stride(texImage);
- GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- texImage->ImageOffsets,
- width, height, depth,
- format, type, pixels, packing);
- if (!success) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
- }
- }
-
- _mesa_unmap_teximage_pbo(ctx, packing);
-}
-
-
-
-
-/*
- * This is the software fallback for Driver.TexSubImage1D()
- * and Driver.CopyTexSubImage1D().
- */
-void
-_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint width,
- GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- /* get pointer to src pixels (may be in a pbo which we'll map here) */
- pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type,
- pixels, packing, "glTexSubImage1D");
- if (!pixels)
- return;
-
- {
- const GLint dstRowStride = 0;
- GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- xoffset, 0, 0, /* offsets */
- dstRowStride,
- texImage->ImageOffsets,
- width, 1, 1,
- format, type, pixels, packing);
- if (!success) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
- }
- }
-
- _mesa_unmap_teximage_pbo(ctx, packing);
-}
-
-
-
-/**
- * This is the software fallback for Driver.TexSubImage2D()
- * and Driver.CopyTexSubImage2D().
- */
-void
-_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint width, GLint height,
- GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- /* get pointer to src pixels (may be in a pbo which we'll map here) */
- pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
- pixels, packing, "glTexSubImage2D");
- if (!pixels)
- return;
-
- {
- GLint dstRowStride = texture_row_stride(texImage);
- GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- xoffset, yoffset, 0,
- dstRowStride,
- texImage->ImageOffsets,
- width, height, 1,
- format, type, pixels, packing);
- if (!success) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
- }
- }
-
- _mesa_unmap_teximage_pbo(ctx, packing);
-}
-
-
-/*
- * This is the software fallback for Driver.TexSubImage3D().
- * and Driver.CopyTexSubImage3D().
- */
-void
-_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLint width, GLint height, GLint depth,
- GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- /* get pointer to src pixels (may be in a pbo which we'll map here) */
- pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format,
- type, pixels, packing,
- "glTexSubImage3D");
- if (!pixels)
- return;
-
- {
- GLint dstRowStride = texture_row_stride(texImage);
- GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- xoffset, yoffset, zoffset,
- dstRowStride,
- texImage->ImageOffsets,
- width, height, depth,
- format, type, pixels, packing);
- if (!success) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
- }
- }
-
- _mesa_unmap_teximage_pbo(ctx, packing);
-}
-
-
-/*
- * Fallback for Driver.CompressedTexImage1D()
- */
-void
-_mesa_store_compressed_teximage1d(struct gl_context *ctx,
- GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- /* this space intentionally left blank */
- (void) ctx;
- (void) target; (void) level;
- (void) internalFormat;
- (void) width; (void) border;
- (void) imageSize; (void) data;
- (void) texObj;
- (void) texImage;
-}
-
-
-
-/**
- * Fallback for Driver.CompressedTexImage2D()
- */
-void
-_mesa_store_compressed_teximage2d(struct gl_context *ctx,
- GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- (void) width; (void) height; (void) border;
-
- /* This is pretty simple, basically just do a memcpy without worrying
- * about the usual image unpacking or image transfer operations.
- */
- ASSERT(texObj);
- ASSERT(texImage);
- ASSERT(texImage->Width > 0);
- ASSERT(texImage->Height > 0);
- ASSERT(texImage->Depth == 1);
- ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */
-
- /* allocate storage */
- texImage->Data = _mesa_alloc_texmemory(imageSize);
- if (!texImage->Data) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
- return;
- }
-
- data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data,
- &ctx->Unpack,
- "glCompressedTexImage2D");
- if (!data)
- return;
-
- /* copy the data */
- memcpy(texImage->Data, data, imageSize);
-
- _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
-}
-
-
-
-/*
- * Fallback for Driver.CompressedTexImage3D()
- */
-void
-_mesa_store_compressed_teximage3d(struct gl_context *ctx,
- GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint depth,
- GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- /* this space intentionally left blank */
- (void) ctx;
- (void) target; (void) level;
- (void) internalFormat;
- (void) width; (void) height; (void) depth;
- (void) border;
- (void) imageSize; (void) data;
- (void) texObj;
- (void) texImage;
-}
-
-
-
-/**
- * Fallback for Driver.CompressedTexSubImage1D()
- */
-void
-_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target,
- GLint level,
- GLint xoffset, GLsizei width,
- GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- /* there are no compressed 1D texture formats yet */
- (void) ctx;
- (void) target; (void) level;
- (void) xoffset; (void) width;
- (void) format;
- (void) imageSize; (void) data;
- (void) texObj;
- (void) texImage;
-}
-
-
-/**
- * Fallback for Driver.CompressedTexSubImage2D()
- */
-void
-_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target,
- GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- GLint bytesPerRow, destRowStride, srcRowStride;
- GLint i, rows;
- GLubyte *dest;
- const GLubyte *src;
- const gl_format texFormat = texImage->TexFormat;
- const GLint destWidth = texImage->Width;
- GLuint bw, bh;
-
- _mesa_get_format_block_size(texFormat, &bw, &bh);
-
- (void) level;
- (void) format;
-
- /* these should have been caught sooner */
- ASSERT((width % bw) == 0 || width == 2 || width == 1);
- ASSERT((height % bh) == 0 || height == 2 || height == 1);
- ASSERT((xoffset % bw) == 0);
- ASSERT((yoffset % bh) == 0);
-
- /* get pointer to src pixels (may be in a pbo which we'll map here) */
- data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data,
- &ctx->Unpack,
- "glCompressedTexSubImage2D");
- if (!data)
- return;
-
- srcRowStride = _mesa_format_row_stride(texFormat, width);
- src = (const GLubyte *) data;
-
- destRowStride = _mesa_format_row_stride(texFormat, destWidth);
- dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
- texFormat, destWidth,
- (GLubyte *) texImage->Data);
-
- bytesPerRow = srcRowStride; /* bytes per row of blocks */
- rows = height / bh; /* rows in blocks */
-
- /* copy rows of blocks */
- for (i = 0; i < rows; i++) {
- memcpy(dest, src, bytesPerRow);
- dest += destRowStride;
- src += srcRowStride;
- }
-
- _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
-}
-
-
-/**
- * Fallback for Driver.CompressedTexSubImage3D()
- */
-void
-_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target,
- GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- /* there are no compressed 3D texture formats yet */
- (void) ctx;
- (void) target; (void) level;
- (void) xoffset; (void) yoffset; (void) zoffset;
- (void) width; (void) height; (void) depth;
- (void) format;
- (void) imageSize; (void) data;
- (void) texObj;
- (void) texImage;
-}
+/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * 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 + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Brian Paul + */ + +/** + * The GL texture image functions in teximage.c basically just do + * error checking and data structure allocation. They in turn call + * device driver functions which actually copy/convert/store the user's + * texture image data. + * + * However, most device drivers will be able to use the fallback functions + * in this file. That is, most drivers will have the following bit of + * code: + * ctx->Driver.TexImage1D = _mesa_store_teximage1d; + * ctx->Driver.TexImage2D = _mesa_store_teximage2d; + * ctx->Driver.TexImage3D = _mesa_store_teximage3d; + * etc... + * + * Texture image processing is actually kind of complicated. We have to do: + * Format/type conversions + * pixel unpacking + * pixel transfer (scale, bais, lookup, etc) + * + * These functions can handle most everything, including processing full + * images and sub-images. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "colormac.h" +#include "image.h" +#include "macros.h" +#include "mipmap.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "pack.h" +#include "imports.h" +#include "pack.h" +#include "texcompress.h" +#include "texcompress_fxt1.h" +#include "texcompress_rgtc.h" +#include "texcompress_s3tc.h" +#include "teximage.h" +#include "texstore.h" +#include "enums.h" + + +enum { + ZERO = 4, + ONE = 5 +}; + + +/** + * Texture image storage function. + */ +typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS); + + +/** + * Return GL_TRUE if the given image format is one that be converted + * to another format by swizzling. + */ +static GLboolean +can_swizzle(GLenum logicalBaseFormat) +{ + switch (logicalBaseFormat) { + case GL_RGBA: + case GL_RGB: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_BGR: + case GL_BGRA: + case GL_ABGR_EXT: + case GL_RG: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + + +enum { + IDX_LUMINANCE = 0, + IDX_ALPHA, + IDX_INTENSITY, + IDX_LUMINANCE_ALPHA, + IDX_RGB, + IDX_RGBA, + IDX_RED, + IDX_GREEN, + IDX_BLUE, + IDX_BGR, + IDX_BGRA, + IDX_ABGR, + IDX_RG, + MAX_IDX +}; + +#define MAP1(x) MAP4(x, ZERO, ZERO, ZERO) +#define MAP2(x,y) MAP4(x, y, ZERO, ZERO) +#define MAP3(x,y,z) MAP4(x, y, z, ZERO) +#define MAP4(x,y,z,w) { x, y, z, w, ZERO, ONE } + + +static const struct { + GLubyte format_idx; + GLubyte to_rgba[6]; + GLubyte from_rgba[6]; +} mappings[MAX_IDX] = +{ + { + IDX_LUMINANCE, + MAP4(0,0,0,ONE), + MAP1(0) + }, + + { + IDX_ALPHA, + MAP4(ZERO, ZERO, ZERO, 0), + MAP1(3) + }, + + { + IDX_INTENSITY, + MAP4(0, 0, 0, 0), + MAP1(0), + }, + + { + IDX_LUMINANCE_ALPHA, + MAP4(0,0,0,1), + MAP2(0,3) + }, + + { + IDX_RGB, + MAP4(0,1,2,ONE), + MAP3(0,1,2) + }, + + { + IDX_RGBA, + MAP4(0,1,2,3), + MAP4(0,1,2,3), + }, + + { + IDX_RED, + MAP4(0, ZERO, ZERO, ONE), + MAP1(0), + }, + + { + IDX_GREEN, + MAP4(ZERO, 0, ZERO, ONE), + MAP1(1), + }, + + { + IDX_BLUE, + MAP4(ZERO, ZERO, 0, ONE), + MAP1(2), + }, + + { + IDX_BGR, + MAP4(2,1,0,ONE), + MAP3(2,1,0) + }, + + { + IDX_BGRA, + MAP4(2,1,0,3), + MAP4(2,1,0,3) + }, + + { + IDX_ABGR, + MAP4(3,2,1,0), + MAP4(3,2,1,0) + }, + + { + IDX_RG, + MAP4(0, 1, ZERO, ONE), + MAP2(0, 1) + }, +}; + + + +/** + * Convert a GL image format enum to an IDX_* value (see above). + */ +static int +get_map_idx(GLenum value) +{ + switch (value) { + case GL_LUMINANCE: return IDX_LUMINANCE; + case GL_ALPHA: return IDX_ALPHA; + case GL_INTENSITY: return IDX_INTENSITY; + case GL_LUMINANCE_ALPHA: return IDX_LUMINANCE_ALPHA; + case GL_RGB: return IDX_RGB; + case GL_RGBA: return IDX_RGBA; + case GL_RED: return IDX_RED; + case GL_GREEN: return IDX_GREEN; + case GL_BLUE: return IDX_BLUE; + case GL_BGR: return IDX_BGR; + case GL_BGRA: return IDX_BGRA; + case GL_ABGR_EXT: return IDX_ABGR; + case GL_RG: return IDX_RG; + default: + _mesa_problem(NULL, "Unexpected inFormat"); + return 0; + } +} + + +/** + * When promoting texture formats (see below) we need to compute the + * mapping of dest components back to source components. + * This function does that. + * \param inFormat the incoming format of the texture + * \param outFormat the final texture format + * \return map[6] a full 6-component map + */ +static void +compute_component_mapping(GLenum inFormat, GLenum outFormat, + GLubyte *map) +{ + const int inFmt = get_map_idx(inFormat); + const int outFmt = get_map_idx(outFormat); + const GLubyte *in2rgba = mappings[inFmt].to_rgba; + const GLubyte *rgba2out = mappings[outFmt].from_rgba; + int i; + + for (i = 0; i < 4; i++) + map[i] = in2rgba[rgba2out[i]]; + + map[ZERO] = ZERO; + map[ONE] = ONE; + +#if 0 + printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n", + inFormat, _mesa_lookup_enum_by_nr(inFormat), + outFormat, _mesa_lookup_enum_by_nr(outFormat), + map[0], + map[1], + map[2], + map[3], + map[4], + map[5]); +#endif +} + + +/** + * Make a temporary (color) texture image with GLfloat components. + * Apply all needed pixel unpacking and pixel transfer operations. + * Note that there are both logicalBaseFormat and textureBaseFormat parameters. + * Suppose the user specifies GL_LUMINANCE as the internal texture format + * but the graphics hardware doesn't support luminance textures. So, we might + * use an RGB hardware format instead. + * If logicalBaseFormat != textureBaseFormat we have some extra work to do. + * + * \param ctx the rendering context + * \param dims image dimensions: 1, 2 or 3 + * \param logicalBaseFormat basic texture derived from the user's + * internal texture format value + * \param textureBaseFormat the actual basic format of the texture + * \param srcWidth source image width + * \param srcHeight source image height + * \param srcDepth source image depth + * \param srcFormat source image format + * \param srcType source image type + * \param srcAddr source image address + * \param srcPacking source image pixel packing + * \return resulting image with format = textureBaseFormat and type = GLfloat. + */ +GLfloat * +_mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps) +{ + GLfloat *tempImage; + const GLint components = _mesa_components_in_format(logicalBaseFormat); + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLfloat *dst; + GLint img, row; + + ASSERT(dims >= 1 && dims <= 3); + + ASSERT(logicalBaseFormat == GL_RGBA || + logicalBaseFormat == GL_RGB || + logicalBaseFormat == GL_RG || + logicalBaseFormat == GL_RED || + logicalBaseFormat == GL_LUMINANCE_ALPHA || + logicalBaseFormat == GL_LUMINANCE || + logicalBaseFormat == GL_ALPHA || + logicalBaseFormat == GL_INTENSITY || + logicalBaseFormat == GL_COLOR_INDEX || + logicalBaseFormat == GL_DEPTH_COMPONENT); + + ASSERT(textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_RGB || + textureBaseFormat == GL_RG || + textureBaseFormat == GL_RED || + textureBaseFormat == GL_LUMINANCE_ALPHA || + textureBaseFormat == GL_LUMINANCE || + textureBaseFormat == GL_ALPHA || + textureBaseFormat == GL_INTENSITY || + textureBaseFormat == GL_COLOR_INDEX || + textureBaseFormat == GL_DEPTH_COMPONENT); + + tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLfloat)); + if (!tempImage) + return NULL; + + dst = tempImage; + for (img = 0; img < srcDepth; img++) { + const GLubyte *src + = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_color_span_float(ctx, srcWidth, logicalBaseFormat, + dst, srcFormat, srcType, src, + srcPacking, transferOps); + dst += srcWidth * components; + src += srcStride; + } + } + + if (logicalBaseFormat != textureBaseFormat) { + /* more work */ + GLint texComponents = _mesa_components_in_format(textureBaseFormat); + GLint logComponents = _mesa_components_in_format(logicalBaseFormat); + GLfloat *newImage; + GLint i, n; + GLubyte map[6]; + + /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ + ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_LUMINANCE_ALPHA); + + /* The actual texture format should have at least as many components + * as the logical texture format. + */ + ASSERT(texComponents >= logComponents); + + newImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth + * texComponents * sizeof(GLfloat)); + if (!newImage) { + free(tempImage); + return NULL; + } + + compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); + + n = srcWidth * srcHeight * srcDepth; + for (i = 0; i < n; i++) { + GLint k; + for (k = 0; k < texComponents; k++) { + GLint j = map[k]; + if (j == ZERO) + newImage[i * texComponents + k] = 0.0F; + else if (j == ONE) + newImage[i * texComponents + k] = 1.0F; + else + newImage[i * texComponents + k] = tempImage[i * logComponents + j]; + } + } + + free(tempImage); + tempImage = newImage; + } + + return tempImage; +} + + +/** + * Make temporary image with uint pixel values. Used for unsigned + * integer-valued textures. + */ +static GLuint * +make_temp_uint_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking) +{ + GLuint *tempImage; + const GLint components = _mesa_components_in_format(logicalBaseFormat); + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLuint *dst; + GLint img, row; + + ASSERT(dims >= 1 && dims <= 3); + + ASSERT(logicalBaseFormat == GL_RGBA || + logicalBaseFormat == GL_RGB || + logicalBaseFormat == GL_RG || + logicalBaseFormat == GL_RED || + logicalBaseFormat == GL_LUMINANCE_ALPHA || + logicalBaseFormat == GL_LUMINANCE || + logicalBaseFormat == GL_INTENSITY || + logicalBaseFormat == GL_ALPHA); + + ASSERT(textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_RGB || + textureBaseFormat == GL_RG || + textureBaseFormat == GL_RED || + textureBaseFormat == GL_LUMINANCE_ALPHA || + textureBaseFormat == GL_LUMINANCE || + textureBaseFormat == GL_ALPHA); + + tempImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLuint)); + if (!tempImage) + return NULL; + + dst = tempImage; + for (img = 0; img < srcDepth; img++) { + const GLubyte *src + = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_color_span_uint(ctx, srcWidth, logicalBaseFormat, + dst, srcFormat, srcType, src, + srcPacking); + dst += srcWidth * components; + src += srcStride; + } + } + + if (logicalBaseFormat != textureBaseFormat) { + /* more work */ + GLint texComponents = _mesa_components_in_format(textureBaseFormat); + GLint logComponents = _mesa_components_in_format(logicalBaseFormat); + GLuint *newImage; + GLint i, n; + GLubyte map[6]; + + /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ + ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_LUMINANCE_ALPHA); + + /* The actual texture format should have at least as many components + * as the logical texture format. + */ + ASSERT(texComponents >= logComponents); + + newImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth + * texComponents * sizeof(GLuint)); + if (!newImage) { + free(tempImage); + return NULL; + } + + compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); + + n = srcWidth * srcHeight * srcDepth; + for (i = 0; i < n; i++) { + GLint k; + for (k = 0; k < texComponents; k++) { + GLint j = map[k]; + if (j == ZERO) + newImage[i * texComponents + k] = 0.0F; + else if (j == ONE) + newImage[i * texComponents + k] = 1.0F; + else + newImage[i * texComponents + k] = tempImage[i * logComponents + j]; + } + } + + free(tempImage); + tempImage = newImage; + } + + return tempImage; +} + + + +/** + * Make a temporary (color) texture image with GLchan components. + * Apply all needed pixel unpacking and pixel transfer operations. + * Note that there are both logicalBaseFormat and textureBaseFormat parameters. + * Suppose the user specifies GL_LUMINANCE as the internal texture format + * but the graphics hardware doesn't support luminance textures. So, we might + * use an RGB hardware format instead. + * If logicalBaseFormat != textureBaseFormat we have some extra work to do. + * + * \param ctx the rendering context + * \param dims image dimensions: 1, 2 or 3 + * \param logicalBaseFormat basic texture derived from the user's + * internal texture format value + * \param textureBaseFormat the actual basic format of the texture + * \param srcWidth source image width + * \param srcHeight source image height + * \param srcDepth source image depth + * \param srcFormat source image format + * \param srcType source image type + * \param srcAddr source image address + * \param srcPacking source image pixel packing + * \return resulting image with format = textureBaseFormat and type = GLchan. + */ +GLchan * +_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking) +{ + GLuint transferOps = ctx->_ImageTransferState; + const GLint components = _mesa_components_in_format(logicalBaseFormat); + GLint img, row; + GLchan *tempImage, *dst; + + ASSERT(dims >= 1 && dims <= 3); + + ASSERT(logicalBaseFormat == GL_RGBA || + logicalBaseFormat == GL_RGB || + logicalBaseFormat == GL_RG || + logicalBaseFormat == GL_RED || + logicalBaseFormat == GL_LUMINANCE_ALPHA || + logicalBaseFormat == GL_LUMINANCE || + logicalBaseFormat == GL_ALPHA || + logicalBaseFormat == GL_INTENSITY); + + ASSERT(textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_RGB || + textureBaseFormat == GL_RG || + textureBaseFormat == GL_RED || + textureBaseFormat == GL_LUMINANCE_ALPHA || + textureBaseFormat == GL_LUMINANCE || + textureBaseFormat == GL_ALPHA || + textureBaseFormat == GL_INTENSITY); + + /* unpack and transfer the source image */ + tempImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLchan)); + if (!tempImage) { + return NULL; + } + + dst = tempImage; + for (img = 0; img < srcDepth; img++) { + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + const GLubyte *src = + (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_color_span_chan(ctx, srcWidth, logicalBaseFormat, dst, + srcFormat, srcType, src, srcPacking, + transferOps); + dst += srcWidth * components; + src += srcStride; + } + } + + if (logicalBaseFormat != textureBaseFormat) { + /* one more conversion step */ + GLint texComponents = _mesa_components_in_format(textureBaseFormat); + GLint logComponents = _mesa_components_in_format(logicalBaseFormat); + GLchan *newImage; + GLint i, n; + GLubyte map[6]; + + /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ + ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_LUMINANCE_ALPHA); + + /* The actual texture format should have at least as many components + * as the logical texture format. + */ + ASSERT(texComponents >= logComponents); + + newImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth + * texComponents * sizeof(GLchan)); + if (!newImage) { + free(tempImage); + return NULL; + } + + compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); + + n = srcWidth * srcHeight * srcDepth; + for (i = 0; i < n; i++) { + GLint k; + for (k = 0; k < texComponents; k++) { + GLint j = map[k]; + if (j == ZERO) + newImage[i * texComponents + k] = 0; + else if (j == ONE) + newImage[i * texComponents + k] = CHAN_MAX; + else + newImage[i * texComponents + k] = tempImage[i * logComponents + j]; + } + } + + free(tempImage); + tempImage = newImage; + } + + return tempImage; +} + + +/** + * Copy GLubyte pixels from <src> to <dst> with swizzling. + * \param dst destination pixels + * \param dstComponents number of color components in destination pixels + * \param src source pixels + * \param srcComponents number of color components in source pixels + * \param map the swizzle mapping. map[X] says where to find the X component + * in the source image's pixels. For example, if the source image + * is GL_BGRA and X = red, map[0] yields 2. + * \param count number of pixels to copy/swizzle. + */ +static void +swizzle_copy(GLubyte *dst, GLuint dstComponents, const GLubyte *src, + GLuint srcComponents, const GLubyte *map, GLuint count) +{ +#define SWZ_CPY(dst, src, count, dstComps, srcComps) \ + do { \ + GLuint i; \ + for (i = 0; i < count; i++) { \ + GLuint j; \ + if (srcComps == 4) { \ + COPY_4UBV(tmp, src); \ + } \ + else { \ + for (j = 0; j < srcComps; j++) { \ + tmp[j] = src[j]; \ + } \ + } \ + src += srcComps; \ + for (j = 0; j < dstComps; j++) { \ + dst[j] = tmp[map[j]]; \ + } \ + dst += dstComps; \ + } \ + } while (0) + + GLubyte tmp[6]; + + tmp[ZERO] = 0x0; + tmp[ONE] = 0xff; + + ASSERT(srcComponents <= 4); + ASSERT(dstComponents <= 4); + + switch (dstComponents) { + case 4: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 4, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 4, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 4, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 4, 1); + break; + default: + ; + } + break; + case 3: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 3, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 3, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 3, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 3, 1); + break; + default: + ; + } + break; + case 2: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 2, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 2, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 2, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 2, 1); + break; + default: + ; + } + break; + case 1: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 1, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 1, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 1, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 1, 1); + break; + default: + ; + } + break; + default: + ; + } +#undef SWZ_CPY +} + + + +static const GLubyte map_identity[6] = { 0, 1, 2, 3, ZERO, ONE }; +static const GLubyte map_3210[6] = { 3, 2, 1, 0, ZERO, ONE }; + + +/** + * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a + * mapping array depending on endianness. + */ +static const GLubyte * +type_mapping( GLenum srcType ) +{ + switch (srcType) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + return map_identity; + case GL_UNSIGNED_INT_8_8_8_8: + return _mesa_little_endian() ? map_3210 : map_identity; + case GL_UNSIGNED_INT_8_8_8_8_REV: + return _mesa_little_endian() ? map_identity : map_3210; + default: + return NULL; + } +} + + +/** + * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a + * mapping array depending on pixelstore byte swapping state. + */ +static const GLubyte * +byteswap_mapping( GLboolean swapBytes, + GLenum srcType ) +{ + if (!swapBytes) + return map_identity; + + switch (srcType) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + return map_identity; + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + return map_3210; + default: + return NULL; + } +} + + + +/** + * Transfer a GLubyte texture image with component swizzling. + */ +static void +_mesa_swizzle_ubyte_image(struct gl_context *ctx, + GLuint dimensions, + GLenum srcFormat, + GLenum srcType, + + GLenum baseInternalFormat, + + const GLubyte *rgba2dst, + GLuint dstComponents, + + GLvoid *dstAddr, + GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, + GLint dstRowStride, + const GLuint *dstImageOffsets, + + GLint srcWidth, GLint srcHeight, GLint srcDepth, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking ) +{ + GLint srcComponents = _mesa_components_in_format(srcFormat); + const GLubyte *srctype2ubyte, *swap; + GLubyte map[4], src2base[6], base2rgba[6]; + GLint i; + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, + srcFormat, GL_UNSIGNED_BYTE); + const GLint srcImageStride + = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat, + GL_UNSIGNED_BYTE); + const GLubyte *srcImage + = (const GLubyte *) _mesa_image_address(dimensions, srcPacking, srcAddr, + srcWidth, srcHeight, srcFormat, + GL_UNSIGNED_BYTE, 0, 0, 0); + + (void) ctx; + + /* Translate from src->baseInternal->GL_RGBA->dst. This will + * correctly deal with RGBA->RGB->RGBA conversions where the final + * A value must be 0xff regardless of the incoming alpha values. + */ + compute_component_mapping(srcFormat, baseInternalFormat, src2base); + compute_component_mapping(baseInternalFormat, GL_RGBA, base2rgba); + swap = byteswap_mapping(srcPacking->SwapBytes, srcType); + srctype2ubyte = type_mapping(srcType); + + + for (i = 0; i < 4; i++) + map[i] = srctype2ubyte[swap[src2base[base2rgba[rgba2dst[i]]]]]; + +/* printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */ + + if (srcComponents == dstComponents && + srcRowStride == dstRowStride && + srcRowStride == srcWidth * srcComponents && + dimensions < 3) { + /* 1 and 2D images only */ + GLubyte *dstImage = (GLubyte *) dstAddr + + dstYoffset * dstRowStride + + dstXoffset * dstComponents; + swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map, + srcWidth * srcHeight); + } + else { + GLint img, row; + for (img = 0; img < srcDepth; img++) { + const GLubyte *srcRow = srcImage; + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * dstComponents + + dstYoffset * dstRowStride + + dstXoffset * dstComponents; + for (row = 0; row < srcHeight; row++) { + swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth); + dstRow += dstRowStride; + srcRow += srcRowStride; + } + srcImage += srcImageStride; + } + } +} + + +/** + * Teximage storage routine for when a simple memcpy will do. + * No pixel transfer operations or special texel encodings allowed. + * 1D, 2D and 3D images supported. + */ +static void +memcpy_texture(struct gl_context *ctx, + GLuint dimensions, + gl_format dstFormat, + GLvoid *dstAddr, + GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, + GLint dstRowStride, + const GLuint *dstImageOffsets, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking) +{ + const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, + srcFormat, srcType); + const GLint srcImageStride = _mesa_image_image_stride(srcPacking, + srcWidth, srcHeight, srcFormat, srcType); + const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions, + srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLint bytesPerRow = srcWidth * texelBytes; + +#if 0 + /* XXX update/re-enable for dstImageOffsets array */ + const GLint bytesPerImage = srcHeight * bytesPerRow; + const GLint bytesPerTexture = srcDepth * bytesPerImage; + GLubyte *dstImage = (GLubyte *) dstAddr + + dstZoffset * dstImageStride + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + + if (dstRowStride == srcRowStride && + dstRowStride == bytesPerRow && + ((dstImageStride == srcImageStride && + dstImageStride == bytesPerImage) || + (srcDepth == 1))) { + /* one big memcpy */ + ctx->Driver.TextureMemCpy(dstImage, srcImage, bytesPerTexture); + } + else + { + GLint img, row; + for (img = 0; img < srcDepth; img++) { + const GLubyte *srcRow = srcImage; + GLubyte *dstRow = dstImage; + for (row = 0; row < srcHeight; row++) { + ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow); + dstRow += dstRowStride; + srcRow += srcRowStride; + } + srcImage += srcImageStride; + dstImage += dstImageStride; + } + } +#endif + + GLint img, row; + for (img = 0; img < srcDepth; img++) { + const GLubyte *srcRow = srcImage; + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow); + dstRow += dstRowStride; + srcRow += srcRowStride; + } + srcImage += srcImageStride; + } +} + + + +/** + * Store a 32-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_z32(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffffff; + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_Z32); + ASSERT(texelBytes == sizeof(GLuint)); + + if (ctx->Pixel.DepthScale == 1.0f && + ctx->Pixel.DepthBias == 0.0f && + !srcPacking->SwapBytes && + baseInternalFormat == GL_DEPTH_COMPONENT && + srcFormat == GL_DEPTH_COMPONENT && + srcType == GL_UNSIGNED_INT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, (GLuint *) dstRow, + depthScale, srcType, src, srcPacking); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store a 24-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_x8_z24(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLuint texelBytes = 4; + + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_X8_Z24); + + { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, (GLuint *) dstRow, + depthScale, srcType, src, srcPacking); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store a 24-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_z24_x8(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLuint texelBytes = 4; + + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_Z24_X8); + + { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + GLuint *dst = (GLuint *) dstRow; + GLint i; + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, dst, + depthScale, srcType, src, srcPacking); + for (i = 0; i < srcWidth; i++) + dst[i] <<= 8; + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store a 16-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_z16(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffff; + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_Z16); + ASSERT(texelBytes == sizeof(GLushort)); + + if (ctx->Pixel.DepthScale == 1.0f && + ctx->Pixel.DepthBias == 0.0f && + !srcPacking->SwapBytes && + baseInternalFormat == GL_DEPTH_COMPONENT && + srcFormat == GL_DEPTH_COMPONENT && + srcType == GL_UNSIGNED_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + GLushort *dst16 = (GLushort *) dstRow; + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_SHORT, dst16, depthScale, + srcType, src, srcPacking); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store an rgb565 or rgb565_rev texture image. + */ +static GLboolean +_mesa_texstore_rgb565(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGB565 || + dstFormat == MESA_FORMAT_RGB565_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGB565 && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && + srcType == GL_UNSIGNED_SHORT_5_6_5) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && + srcType == GL_UNSIGNED_BYTE && + dims == 2) { + /* do optimized tex store */ + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + const GLubyte *src = (const GLubyte *) + _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, + srcFormat, srcType, 0, 0, 0); + GLubyte *dst = (GLubyte *) dstAddr + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + GLint row, col; + for (row = 0; row < srcHeight; row++) { + const GLubyte *srcUB = (const GLubyte *) src; + GLushort *dstUS = (GLushort *) dst; + /* check for byteswapped format */ + if (dstFormat == MESA_FORMAT_RGB565) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] ); + srcUB += 3; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565_REV( srcUB[0], srcUB[1], srcUB[2] ); + srcUB += 3; + } + } + dst += dstRowStride; + src += srcRowStride; + } + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + /* check for byteswapped format */ + if (dstFormat == MESA_FORMAT_RGB565) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 3; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565_REV( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 3; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV. + */ +static GLboolean +_mesa_texstore_rgba8888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA8888 || + dstFormat == MESA_FORMAT_RGBA8888_REV); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGBA8888 && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) || + (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGBA8888_REV && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || + (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + (srcType == GL_UNSIGNED_BYTE || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if ((littleEndian && dstFormat == MESA_FORMAT_RGBA8888) || + (!littleEndian && dstFormat == MESA_FORMAT_RGBA8888_REV)) { + dstmap[3] = 0; + dstmap[2] = 1; + dstmap[1] = 2; + dstmap[0] = 3; + } + else { + dstmap[3] = 3; + dstmap[2] = 2; + dstmap[1] = 1; + dstmap[0] = 0; + } + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 4, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_RGBA8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]), + CHAN_TO_UBYTE(src[ACOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]), + CHAN_TO_UBYTE(src[ACOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_argb8888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = GL_RGBA; + + ASSERT(dstFormat == MESA_FORMAT_ARGB8888 || + dstFormat == MESA_FORMAT_ARGB8888_REV || + dstFormat == MESA_FORMAT_XRGB8888 || + dstFormat == MESA_FORMAT_XRGB8888_REV ); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_ARGB8888 || + dstFormat == MESA_FORMAT_XRGB8888) && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + ((srcType == GL_UNSIGNED_BYTE && littleEndian) || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) { + /* simple memcpy path (little endian) */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_ARGB8888_REV || + dstFormat == MESA_FORMAT_XRGB8888_REV) && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + ((srcType == GL_UNSIGNED_BYTE && !littleEndian) || + srcType == GL_UNSIGNED_INT_8_8_8_8)) { + /* simple memcpy path (big endian) */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_ARGB8888 || + dstFormat == MESA_FORMAT_XRGB8888) && + srcFormat == GL_RGB && + (baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB) && + srcType == GL_UNSIGNED_BYTE) { + int img, row, col; + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *d4 = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + d4[col] = PACK_COLOR_8888(0xff, + srcRow[col * 3 + RCOMP], + srcRow[col * 3 + GCOMP], + srcRow[col * 3 + BCOMP]); + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB8888 && + srcFormat == GL_RGBA && + baseInternalFormat == GL_RGBA && + srcType == GL_UNSIGNED_BYTE) { + /* same as above case, but src data has alpha too */ + GLint img, row, col; + /* For some reason, streaming copies to write-combined regions + * are extremely sensitive to the characteristics of how the + * source data is retrieved. By reordering the source reads to + * be in-order, the speed of this operation increases by half. + * Strangely the same isn't required for the RGB path, above. + */ + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *d4 = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + d4[col] = PACK_COLOR_8888(srcRow[col * 4 + ACOMP], + srcRow[col * 4 + RCOMP], + srcRow[col * 4 + GCOMP], + srcRow[col * 4 + BCOMP]); + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + (srcType == GL_UNSIGNED_BYTE || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || + (littleEndian && dstFormat == MESA_FORMAT_XRGB8888) || + (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || + (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV)) { + dstmap[3] = 3; /* alpha */ + dstmap[2] = 0; /* red */ + dstmap[1] = 1; /* green */ + dstmap[0] = 2; /* blue */ + } + else { + assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || + (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || + (littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV) || + (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888)); + dstmap[3] = 2; + dstmap[2] = 1; + dstmap[1] = 0; + dstmap[0] = 3; + } + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 4, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_ARGB8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else if (dstFormat == MESA_FORMAT_XRGB8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( 0xff, + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_rgb888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGB888); + ASSERT(texelBytes == 3); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_BGR && + srcType == GL_UNSIGNED_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_BYTE) { + /* extract RGB from RGBA */ + GLint img, row, col; + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP]; + dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; + dstRow[col * 3 + 2] = srcRow[col * 4 + RCOMP]; + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + dstmap[0] = 2; + dstmap[1] = 1; + dstmap[2] = 0; + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 3, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = (const GLchan *) tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { +#if 0 + if (littleEndian) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]); + dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); + dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]); + srcUB += 3; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = srcUB[BCOMP]; + dstRow[col * 3 + 1] = srcUB[GCOMP]; + dstRow[col * 3 + 2] = srcUB[RCOMP]; + srcUB += 3; + } + } +#else + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[BCOMP]); + dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); + dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[RCOMP]); + src += 3; + } +#endif + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_bgr888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_BGR888); + ASSERT(texelBytes == 3); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && + srcType == GL_UNSIGNED_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_BYTE) { + /* extract BGR from RGBA */ + int img, row, col; + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP]; + dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; + dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP]; + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + dstmap[0] = 0; + dstmap[1] = 1; + dstmap[2] = 2; + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 3, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = (const GLchan *) tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]); + dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); + dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]); + src += 3; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_argb4444(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_ARGB4444 || + dstFormat == MESA_FORMAT_ARGB4444_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB4444 && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + if (dstFormat == MESA_FORMAT_ARGB4444) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_4444_REV( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + +static GLboolean +_mesa_texstore_rgba5551(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA5551); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGBA5551 && + baseInternalFormat == GL_RGBA && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_SHORT_5_5_5_1) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src =tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_5551( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]), + CHAN_TO_UBYTE(src[ACOMP]) ); + src += 4; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + +static GLboolean +_mesa_texstore_argb1555(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_ARGB1555 || + dstFormat == MESA_FORMAT_ARGB1555_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB1555 && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src =tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + if (dstFormat == MESA_FORMAT_ARGB1555) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_1555( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_1555_REV( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_argb2101010(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_ARGB2101010); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB2101010 && + srcFormat == GL_BGRA && + srcType == GL_UNSIGNED_INT_2_10_10_10_REV && + baseInternalFormat == GL_RGBA) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + if (baseInternalFormat == GL_RGBA) { + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort a,r,g,b; + + UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]); + UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]); + dstUI[col] = PACK_COLOR_2101010_US(a, r, g, b); + src += 4; + } + dstRow += dstRowStride; + } + } else if (baseInternalFormat == GL_RGB) { + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort r,g,b; + + UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]); + dstUI[col] = PACK_COLOR_2101010_US(0xffff, r, g, b); + src += 4; + } + dstRow += dstRowStride; + } + } else { + ASSERT(0); + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Do texstore for 2-channel, 4-bit/channel, unsigned normalized formats. + */ +static GLboolean +_mesa_texstore_unorm44(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_AL44); + ASSERT(texelBytes == 1); + + { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLubyte *dstUS = (GLubyte *) dstRow; + for (col = 0; col < srcWidth; col++) { + /* src[0] is luminance, src[1] is alpha */ + dstUS[col] = PACK_COLOR_44( CHAN_TO_UBYTE(src[1]), + CHAN_TO_UBYTE(src[0]) ); + src += 2; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Do texstore for 2-channel, 8-bit/channel, unsigned normalized formats. + */ +static GLboolean +_mesa_texstore_unorm88(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_AL88 || + dstFormat == MESA_FORMAT_AL88_REV || + dstFormat == MESA_FORMAT_RG88 || + dstFormat == MESA_FORMAT_RG88_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_RG88) && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + littleEndian && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if (dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_AL88_REV) { + if ((littleEndian && dstFormat == MESA_FORMAT_AL88) || + (!littleEndian && dstFormat == MESA_FORMAT_AL88_REV)) { + dstmap[0] = 0; + dstmap[1] = 3; + } + else { + dstmap[0] = 3; + dstmap[1] = 0; + } + } + else { + if ((littleEndian && dstFormat == MESA_FORMAT_RG88) || + (!littleEndian && dstFormat == MESA_FORMAT_RG88_REV)) { + dstmap[0] = 0; + dstmap[1] = 1; + } + else { + dstmap[0] = 1; + dstmap[1] = 0; + } + } + dstmap[2] = ZERO; /* ? */ + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 2, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + if (dstFormat == MESA_FORMAT_AL88 || + dstFormat == MESA_FORMAT_RG88) { + for (col = 0; col < srcWidth; col++) { + /* src[0] is luminance, src[1] is alpha */ + dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[1]), + CHAN_TO_UBYTE(src[0]) ); + src += 2; + } + } + else { + for (col = 0; col < srcWidth; col++) { + /* src[0] is luminance, src[1] is alpha */ + dstUS[col] = PACK_COLOR_88_REV( CHAN_TO_UBYTE(src[1]), + CHAN_TO_UBYTE(src[0]) ); + src += 2; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Do texstore for 2-channel, 16-bit/channel, unsigned normalized formats. + */ +static GLboolean +_mesa_texstore_unorm1616(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_AL1616 || + dstFormat == MESA_FORMAT_AL1616_REV || + dstFormat == MESA_FORMAT_RG1616 || + dstFormat == MESA_FORMAT_RG1616_REV); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_AL1616 || dstFormat == MESA_FORMAT_RG1616) && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_SHORT && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_AL1616 || + dstFormat == MESA_FORMAT_RG1616) { + for (col = 0; col < srcWidth; col++) { + GLushort l, a; + + UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); + UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); + dstUI[col] = PACK_COLOR_1616(a, l); + src += 2; + } + } + else { + for (col = 0; col < srcWidth; col++) { + GLushort l, a; + + UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); + UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); + dstUI[col] = PACK_COLOR_1616_REV(a, l); + src += 2; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* Texstore for R16, A16, L16, I16. */ +static GLboolean +_mesa_texstore_unorm16(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_R16 || + dstFormat == MESA_FORMAT_A16 || + dstFormat == MESA_FORMAT_L16 || + dstFormat == MESA_FORMAT_I16); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_SHORT && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort r; + + UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); + dstUS[col] = r; + src += 1; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_rgba_16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_16); + ASSERT(texelBytes == 8); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGBA && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort r, g, b, a; + + UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[1]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[2]); + UNCLAMPED_FLOAT_TO_USHORT(a, src[3]); + dstUS[col*4+0] = r; + dstUS[col*4+1] = g; + dstUS[col*4+2] = b; + dstUS[col*4+3] = a; + src += 4; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_R_16 || + dstFormat == MESA_FORMAT_SIGNED_RG_16 || + dstFormat == MESA_FORMAT_SIGNED_RGB_16 || + dstFormat == MESA_FORMAT_SIGNED_RGBA_16); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGBA && + dstFormat == MESA_FORMAT_SIGNED_RGBA_16 && + srcFormat == GL_RGBA && + srcType == GL_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + const GLuint comps = _mesa_get_format_bytes(dstFormat) / 2; + GLint img, row, col; + + if (!tempImage) + return GL_FALSE; + + /* Note: tempImage is always float[4] / RGBA. We convert to 1, 2, + * 3 or 4 components/pixel here. + */ + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLshort *dstRowS = (GLshort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLuint c; + for (c = 0; c < comps; c++) { + GLshort p; + UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 4 + c]); + dstRowS[col * comps + c] = p; + } + } + dstRow += dstRowStride; + src += 4 * srcWidth; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_rgb332(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGB332); + ASSERT(texelBytes == 1); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col] = PACK_COLOR_332( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 3; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8. + */ +static GLboolean +_mesa_texstore_a8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_A8 || + dstFormat == MESA_FORMAT_L8 || + dstFormat == MESA_FORMAT_I8 || + dstFormat == MESA_FORMAT_R8); + ASSERT(texelBytes == 1); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if (dstFormat == MESA_FORMAT_A8) { + dstmap[0] = 3; + } + else { + dstmap[0] = 0; + } + dstmap[1] = ZERO; /* ? */ + dstmap[2] = ZERO; /* ? */ + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 1, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col] = CHAN_TO_UBYTE(src[col]); + } + dstRow += dstRowStride; + src += srcWidth; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + + +static GLboolean +_mesa_texstore_ci8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + + (void) dims; (void) baseInternalFormat; + ASSERT(dstFormat == MESA_FORMAT_CI8); + ASSERT(texelBytes == 1); + ASSERT(baseInternalFormat == GL_COLOR_INDEX); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + srcFormat == GL_COLOR_INDEX && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + _mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow, + srcType, src, srcPacking, + ctx->_ImageTransferState); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV. + */ +static GLboolean +_mesa_texstore_ycbcr(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + + (void) ctx; (void) dims; (void) baseInternalFormat; + + ASSERT((dstFormat == MESA_FORMAT_YCBCR) || + (dstFormat == MESA_FORMAT_YCBCR_REV)); + ASSERT(texelBytes == 2); + ASSERT(ctx->Extensions.MESA_ycbcr_texture); + ASSERT(srcFormat == GL_YCBCR_MESA); + ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) || + (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA)); + ASSERT(baseInternalFormat == GL_YCBCR_MESA); + + /* always just memcpy since no pixel transfer ops apply */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + + /* Check if we need byte swapping */ + /* XXX the logic here _might_ be wrong */ + if (srcPacking->SwapBytes ^ + (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^ + (dstFormat == MESA_FORMAT_YCBCR_REV) ^ + !littleEndian) { + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + _mesa_swap2((GLushort *) dstRow, srcWidth); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + +static GLboolean +_mesa_texstore_dudv8(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_DUDV8); + ASSERT(texelBytes == 2); + ASSERT(ctx->Extensions.ATI_envmap_bumpmap); + ASSERT((srcFormat == GL_DU8DV8_ATI) || + (srcFormat == GL_DUDV_ATI)); + ASSERT(baseInternalFormat == GL_DUDV_ATI); + + if (!srcPacking->SwapBytes && srcType == GL_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (srcType == GL_BYTE) { + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if (littleEndian) { + dstmap[0] = 0; + dstmap[1] = 3; + } + else { + dstmap[0] = 3; + dstmap[1] = 0; + } + dstmap[2] = ZERO; /* ? */ + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + GL_LUMINANCE_ALPHA, /* hack */ + GL_UNSIGNED_BYTE, /* hack */ + GL_LUMINANCE_ALPHA, /* hack */ + dstmap, 2, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path - note this is defined for 2d textures only */ + const GLint components = _mesa_components_in_format(baseInternalFormat); + const GLint srcStride = _mesa_image_row_stride(srcPacking, srcWidth, + srcFormat, srcType); + GLbyte *tempImage, *dst, *src; + GLint row; + + tempImage = (GLbyte *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLbyte)); + if (!tempImage) + return GL_FALSE; + + src = (GLbyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + 0, 0, 0); + + dst = tempImage; + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_dudv_span_byte(ctx, srcWidth, baseInternalFormat, + dst, srcFormat, srcType, src, + srcPacking, 0); + dst += srcWidth * components; + src += srcStride; + } + + src = tempImage; + dst = (GLbyte *) dstAddr + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + memcpy(dst, src, srcWidth * texelBytes); + dst += dstRowStride; + src += srcWidth * texelBytes; + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_SIGNED_R8 format. + */ +static GLboolean +_mesa_texstore_signed_r8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_R8); + ASSERT(texelBytes == 1); + + /* XXX look at adding optimized paths */ + { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLubyte *dstB = (GLubyte *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstB[col] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]); + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_SIGNED_RG88 format. + */ +static GLboolean +_mesa_texstore_signed_rg88(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG88); + ASSERT(texelBytes == 1); + + /* XXX look at adding optimized paths */ + { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_88(FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP])); + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_SIGNED_RGBX8888. + */ +static GLboolean +_mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBX8888); + ASSERT(texelBytes == 4); + + { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), + 0xff ); + srcRow += 4; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + + +/** + * Store a texture in MESA_FORMAT_SIGNED_RGBA8888 or + * MESA_FORMAT_SIGNED_RGBA8888_REV + */ +static GLboolean +_mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBA8888 || + dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_SIGNED_RGBA8888 && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_BYTE && !littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_BYTE && littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + (srcType == GL_BYTE) && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if ((littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888) || + (!littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV)) { + dstmap[3] = 0; + dstmap[2] = 1; + dstmap[1] = 2; + dstmap[0] = 3; + } + else { + dstmap[3] = 3; + dstmap[2] = 2; + dstmap[1] = 1; + dstmap[0] = 0; + } + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 4, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_SIGNED_RGBA8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) ); + srcRow += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888_REV( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) ); + srcRow += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a combined depth/stencil texture image. + */ +static GLboolean +_mesa_texstore_z24_s8(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; + + ASSERT(dstFormat == MESA_FORMAT_Z24_S8); + ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT); + ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT); + + if (srcFormat != GL_DEPTH_COMPONENT && ctx->Pixel.DepthScale == 1.0f && + ctx->Pixel.DepthBias == 0.0f && + !srcPacking->SwapBytes) { + /* simple path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (srcFormat == GL_DEPTH_COMPONENT) { + /* In case we only upload depth we need to preserve the stencil */ + for (img = 0; img < srcDepth; img++) { + GLuint *dstRow = (GLuint *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLuint depth[MAX_WIDTH]; + GLubyte stencil[MAX_WIDTH]; + GLint i; + GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE; + + if (srcFormat == GL_DEPTH_COMPONENT) { /* preserve stencil */ + keepstencil = GL_TRUE; + } + else if (srcFormat == GL_STENCIL_INDEX) { /* preserve depth */ + keepdepth = GL_TRUE; + } + + if (keepdepth == GL_FALSE) + /* the 24 depth bits will be in the low position: */ + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, /* dst type */ + keepstencil ? depth : dstRow, /* dst addr */ + depthScale, + srcType, src, srcPacking); + + if (keepstencil == GL_FALSE) + /* get the 8-bit stencil values */ + _mesa_unpack_stencil_span(ctx, srcWidth, + GL_UNSIGNED_BYTE, /* dst type */ + stencil, /* dst addr */ + srcType, src, srcPacking, + ctx->_ImageTransferState); + + for (i = 0; i < srcWidth; i++) { + if (keepstencil) + dstRow[i] = depth[i] << 8 | (dstRow[i] & 0x000000FF); + else + dstRow[i] = (dstRow[i] & 0xFFFFFF00) | (stencil[i] & 0xFF); + } + + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLuint); + } + } + } + return GL_TRUE; +} + + +/** + * Store a combined depth/stencil texture image. + */ +static GLboolean +_mesa_texstore_s8_z24(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; + + ASSERT(dstFormat == MESA_FORMAT_S8_Z24); + ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || + srcFormat == GL_DEPTH_COMPONENT || + srcFormat == GL_STENCIL_INDEX); + ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || + srcType == GL_UNSIGNED_INT_24_8_EXT); + + for (img = 0; img < srcDepth; img++) { + GLuint *dstRow = (GLuint *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLuint depth[MAX_WIDTH]; + GLubyte stencil[MAX_WIDTH]; + GLint i; + GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE; + + if (srcFormat == GL_DEPTH_COMPONENT) { /* preserve stencil */ + keepstencil = GL_TRUE; + } + else if (srcFormat == GL_STENCIL_INDEX) { /* preserve depth */ + keepdepth = GL_TRUE; + } + + if (keepdepth == GL_FALSE) + /* the 24 depth bits will be in the low position: */ + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, /* dst type */ + keepstencil ? depth : dstRow, /* dst addr */ + depthScale, + srcType, src, srcPacking); + + if (keepstencil == GL_FALSE) + /* get the 8-bit stencil values */ + _mesa_unpack_stencil_span(ctx, srcWidth, + GL_UNSIGNED_BYTE, /* dst type */ + stencil, /* dst addr */ + srcType, src, srcPacking, + ctx->_ImageTransferState); + + /* merge stencil values into depth values */ + for (i = 0; i < srcWidth; i++) { + if (keepstencil) + dstRow[i] = depth[i] | (dstRow[i] & 0xFF000000); + else + dstRow[i] = (dstRow[i] & 0xFFFFFF) | (stencil[i] << 24); + + } + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLuint); + } + } + return GL_TRUE; +} + + +/** + * Store simple 8-bit/value stencil texture data. + */ +static GLboolean +_mesa_texstore_s8(TEXSTORE_PARAMS) +{ + ASSERT(dstFormat == MESA_FORMAT_S8); + ASSERT(srcFormat == GL_STENCIL_INDEX); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; + + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLubyte stencil[MAX_WIDTH]; + GLint i; + + /* get the 8-bit stencil values */ + _mesa_unpack_stencil_span(ctx, srcWidth, + GL_UNSIGNED_BYTE, /* dst type */ + stencil, /* dst addr */ + srcType, src, srcPacking, + ctx->_ImageTransferState); + /* merge stencil values into depth values */ + for (i = 0; i < srcWidth; i++) + dstRow[i] = stencil[i]; + + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLubyte); + } + } + + } + + return GL_TRUE; +} + + +/** + * Store an image in any of the formats: + * _mesa_texformat_rgba_float32 + * _mesa_texformat_rgb_float32 + * _mesa_texformat_alpha_float32 + * _mesa_texformat_luminance_float32 + * _mesa_texformat_luminance_alpha_float32 + * _mesa_texformat_intensity_float32 + */ +static GLboolean +_mesa_texstore_rgba_float32(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT32 || + dstFormat == MESA_FORMAT_RGB_FLOAT32 || + dstFormat == MESA_FORMAT_ALPHA_FLOAT32 || + dstFormat == MESA_FORMAT_LUMINANCE_FLOAT32 || + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32 || + dstFormat == MESA_FORMAT_INTENSITY_FLOAT32); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLfloat)); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_FLOAT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint bytesPerRow; + GLint img, row; + if (!tempImage) + return GL_FALSE; + bytesPerRow = srcWidth * components * sizeof(GLfloat); + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + memcpy(dstRow, srcRow, bytesPerRow); + dstRow += dstRowStride; + srcRow += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + + +/** + * As above, but store 16-bit floats. + */ +static GLboolean +_mesa_texstore_rgba_float16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT16 || + dstFormat == MESA_FORMAT_RGB_FLOAT16 || + dstFormat == MESA_FORMAT_ALPHA_FLOAT16 || + dstFormat == MESA_FORMAT_LUMINANCE_FLOAT16 || + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16 || + dstFormat == MESA_FORMAT_INTENSITY_FLOAT16); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLhalfARB)); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_HALF_FLOAT_ARB) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLhalfARB *dstTexel = (GLhalfARB *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = _mesa_float_to_half(src[i]); + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, signed int8 */ +static GLboolean +_mesa_texstore_rgba_int8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_INT8); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLbyte)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLbyte *dstTexel = (GLbyte *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLbyte) src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, signed int16 */ +static GLboolean +_mesa_texstore_rgba_int16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_INT16); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLshort)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLshort *dstTexel = (GLshort *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLint) src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, signed int32 */ +static GLboolean +_mesa_texstore_rgba_int32(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_INT32); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLint)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_INT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLint *dstTexel = (GLint *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLint) src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, unsigned int8 */ +static GLboolean +_mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT8); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLubyte)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLuint *tempImage = + make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + const GLuint *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLubyte *dstTexel = (GLubyte *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLubyte) CLAMP(src[i], 0, 0xff); + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, unsigned int16 */ +static GLboolean +_mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT16); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLushort)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLuint *tempImage = + make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + const GLuint *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstTexel = (GLushort *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLushort) CLAMP(src[i], 0, 0xffff); + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, unsigned int32 */ +static GLboolean +_mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT32); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLuint)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_INT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLuint *tempImage = + make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + const GLuint *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstTexel = (GLuint *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + + + +#if FEATURE_EXT_texture_sRGB +static GLboolean +_mesa_texstore_srgb8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SRGB8); + + /* reuse normal rgb texstore code */ + newDstFormat = MESA_FORMAT_RGB888; + + k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_srgba8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SRGBA8); + + /* reuse normal rgba texstore code */ + newDstFormat = MESA_FORMAT_RGBA8888; + k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_sargb8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SARGB8); + + /* reuse normal rgba texstore code */ + newDstFormat = MESA_FORMAT_ARGB8888; + + k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_sl8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SL8); + + newDstFormat = MESA_FORMAT_L8; + + /* _mesa_textore_a8 handles luminance8 too */ + k = _mesa_texstore_a8(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_sla8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SLA8); + + /* reuse normal luminance/alpha texstore code */ + newDstFormat = MESA_FORMAT_AL88; + + k = _mesa_texstore_unorm88(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + +#else + +/* these are used only in texstore_funcs[] below */ +#define _mesa_texstore_srgb8 NULL +#define _mesa_texstore_srgba8 NULL +#define _mesa_texstore_sargb8 NULL +#define _mesa_texstore_sl8 NULL +#define _mesa_texstore_sla8 NULL + +#endif /* FEATURE_EXT_texture_sRGB */ + + + + +/** + * Table mapping MESA_FORMAT_* to _mesa_texstore_*() + * XXX this is somewhat temporary. + */ +static const struct { + gl_format Name; + StoreTexImageFunc Store; +} +texstore_funcs[MESA_FORMAT_COUNT] = +{ + { MESA_FORMAT_NONE, NULL }, + { MESA_FORMAT_RGBA8888, _mesa_texstore_rgba8888 }, + { MESA_FORMAT_RGBA8888_REV, _mesa_texstore_rgba8888 }, + { MESA_FORMAT_ARGB8888, _mesa_texstore_argb8888 }, + { MESA_FORMAT_ARGB8888_REV, _mesa_texstore_argb8888 }, + { MESA_FORMAT_XRGB8888, _mesa_texstore_argb8888 }, + { MESA_FORMAT_XRGB8888_REV, _mesa_texstore_argb8888 }, + { MESA_FORMAT_RGB888, _mesa_texstore_rgb888 }, + { MESA_FORMAT_BGR888, _mesa_texstore_bgr888 }, + { MESA_FORMAT_RGB565, _mesa_texstore_rgb565 }, + { MESA_FORMAT_RGB565_REV, _mesa_texstore_rgb565 }, + { MESA_FORMAT_ARGB4444, _mesa_texstore_argb4444 }, + { MESA_FORMAT_ARGB4444_REV, _mesa_texstore_argb4444 }, + { MESA_FORMAT_RGBA5551, _mesa_texstore_rgba5551 }, + { MESA_FORMAT_ARGB1555, _mesa_texstore_argb1555 }, + { MESA_FORMAT_ARGB1555_REV, _mesa_texstore_argb1555 }, + { MESA_FORMAT_AL44, _mesa_texstore_unorm44 }, + { MESA_FORMAT_AL88, _mesa_texstore_unorm88 }, + { MESA_FORMAT_AL88_REV, _mesa_texstore_unorm88 }, + { MESA_FORMAT_AL1616, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_AL1616_REV, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_RGB332, _mesa_texstore_rgb332 }, + { MESA_FORMAT_A8, _mesa_texstore_a8 }, + { MESA_FORMAT_A16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_L8, _mesa_texstore_a8 }, + { MESA_FORMAT_L16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_I8, _mesa_texstore_a8 }, + { MESA_FORMAT_I16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_CI8, _mesa_texstore_ci8 }, + { MESA_FORMAT_YCBCR, _mesa_texstore_ycbcr }, + { MESA_FORMAT_YCBCR_REV, _mesa_texstore_ycbcr }, + { MESA_FORMAT_R8, _mesa_texstore_a8 }, + { MESA_FORMAT_RG88, _mesa_texstore_unorm88 }, + { MESA_FORMAT_RG88_REV, _mesa_texstore_unorm88 }, + { MESA_FORMAT_R16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_RG1616, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_RG1616_REV, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_ARGB2101010, _mesa_texstore_argb2101010 }, + { MESA_FORMAT_Z24_S8, _mesa_texstore_z24_s8 }, + { MESA_FORMAT_S8_Z24, _mesa_texstore_s8_z24 }, + { MESA_FORMAT_Z16, _mesa_texstore_z16 }, + { MESA_FORMAT_X8_Z24, _mesa_texstore_x8_z24 }, + { MESA_FORMAT_Z24_X8, _mesa_texstore_z24_x8 }, + { MESA_FORMAT_Z32, _mesa_texstore_z32 }, + { MESA_FORMAT_S8, _mesa_texstore_s8 }, + { MESA_FORMAT_SRGB8, _mesa_texstore_srgb8 }, + { MESA_FORMAT_SRGBA8, _mesa_texstore_srgba8 }, + { MESA_FORMAT_SARGB8, _mesa_texstore_sargb8 }, + { MESA_FORMAT_SL8, _mesa_texstore_sl8 }, + { MESA_FORMAT_SLA8, _mesa_texstore_sla8 }, + { MESA_FORMAT_SRGB_DXT1, _mesa_texstore_rgb_dxt1 }, + { MESA_FORMAT_SRGBA_DXT1, _mesa_texstore_rgba_dxt1 }, + { MESA_FORMAT_SRGBA_DXT3, _mesa_texstore_rgba_dxt3 }, + { MESA_FORMAT_SRGBA_DXT5, _mesa_texstore_rgba_dxt5 }, + { MESA_FORMAT_RGB_FXT1, _mesa_texstore_rgb_fxt1 }, + { MESA_FORMAT_RGBA_FXT1, _mesa_texstore_rgba_fxt1 }, + { MESA_FORMAT_RGB_DXT1, _mesa_texstore_rgb_dxt1 }, + { MESA_FORMAT_RGBA_DXT1, _mesa_texstore_rgba_dxt1 }, + { MESA_FORMAT_RGBA_DXT3, _mesa_texstore_rgba_dxt3 }, + { MESA_FORMAT_RGBA_DXT5, _mesa_texstore_rgba_dxt5 }, + { MESA_FORMAT_RGBA_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_RGBA_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_RGB_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_RGB_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_LUMINANCE_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_LUMINANCE_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_INTENSITY_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_INTENSITY_FLOAT16, _mesa_texstore_rgba_float16 }, + + { MESA_FORMAT_RGBA_INT8, _mesa_texstore_rgba_int8 }, + { MESA_FORMAT_RGBA_INT16, _mesa_texstore_rgba_int16 }, + { MESA_FORMAT_RGBA_INT32, _mesa_texstore_rgba_int32 }, + { MESA_FORMAT_RGBA_UINT8, _mesa_texstore_rgba_uint8 }, + { MESA_FORMAT_RGBA_UINT16, _mesa_texstore_rgba_uint16 }, + { MESA_FORMAT_RGBA_UINT32, _mesa_texstore_rgba_uint32 }, + + { MESA_FORMAT_DUDV8, _mesa_texstore_dudv8 }, + + { MESA_FORMAT_SIGNED_R8, _mesa_texstore_signed_r8 }, + { MESA_FORMAT_SIGNED_RG88, _mesa_texstore_signed_rg88 }, + { MESA_FORMAT_SIGNED_RGBX8888, _mesa_texstore_signed_rgbx8888 }, + + { MESA_FORMAT_SIGNED_RGBA8888, _mesa_texstore_signed_rgba8888 }, + { MESA_FORMAT_SIGNED_RGBA8888_REV, _mesa_texstore_signed_rgba8888 }, + + { MESA_FORMAT_SIGNED_R_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RG_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RGB_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RGBA_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_RGBA_16, _mesa_texstore_rgba_16 }, + + { MESA_FORMAT_RED_RGTC1, _mesa_texstore_red_rgtc1 }, + { MESA_FORMAT_SIGNED_RED_RGTC1, _mesa_texstore_signed_red_rgtc1 }, + { MESA_FORMAT_RG_RGTC2, _mesa_texstore_rg_rgtc2 }, + { MESA_FORMAT_SIGNED_RG_RGTC2, _mesa_texstore_signed_rg_rgtc2 } +}; + + +static GLboolean +_mesa_texstore_null(TEXSTORE_PARAMS) +{ + (void) ctx; (void) dims; + (void) baseInternalFormat; + (void) dstFormat; + (void) dstAddr; + (void) dstXoffset; (void) dstYoffset; (void) dstZoffset; + (void) dstRowStride; (void) dstImageOffsets; + (void) srcWidth; (void) srcHeight; (void) srcDepth; + (void) srcFormat; (void) srcType; + (void) srcAddr; + (void) srcPacking; + + /* should never happen */ + _mesa_problem(NULL, "_mesa_texstore_null() is called"); + return GL_FALSE; +} + + +/** + * Return the StoreTexImageFunc pointer to store an image in the given format. + */ +static StoreTexImageFunc +_mesa_get_texstore_func(gl_format format) +{ +#ifdef DEBUG + GLuint i; + for (i = 0; i < MESA_FORMAT_COUNT; i++) { + ASSERT(texstore_funcs[i].Name == i); + } +#endif + ASSERT(texstore_funcs[format].Name == format); + + if (texstore_funcs[format].Store) + return texstore_funcs[format].Store; + else + return _mesa_texstore_null; +} + + +/** + * Store user data into texture memory. + * Called via glTex[Sub]Image1/2/3D() + */ +GLboolean +_mesa_texstore(TEXSTORE_PARAMS) +{ + StoreTexImageFunc storeImage; + GLboolean success; + + storeImage = _mesa_get_texstore_func(dstFormat); + + success = storeImage(ctx, dims, baseInternalFormat, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + return success; +} + + +/** + * Check if an unpack PBO is active prior to fetching a texture image. + * If so, do bounds checking and map the buffer into main memory. + * Any errors detected will be recorded. + * The caller _must_ call _mesa_unmap_teximage_pbo() too! + */ +const GLvoid * +_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *unpack, + const char *funcName) +{ + GLubyte *buf; + + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* no PBO */ + return pixels; + } + if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, + format, type, pixels)) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); + return NULL; + } + + buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, unpack->BufferObj); + if (!buf) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped)"); + return NULL; + } + + return ADD_POINTERS(buf, pixels); +} + + +/** + * Check if an unpack PBO is active prior to fetching a compressed texture + * image. + * If so, do bounds checking and map the buffer into main memory. + * Any errors detected will be recorded. + * The caller _must_ call _mesa_unmap_teximage_pbo() too! + */ +const GLvoid * +_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, + GLsizei imageSize, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + const char *funcName) +{ + GLubyte *buf; + + if (!_mesa_is_bufferobj(packing->BufferObj)) { + /* not using a PBO - return pointer unchanged */ + return pixels; + } + if ((const GLubyte *) pixels + imageSize > + ((const GLubyte *) 0) + packing->BufferObj->Size) { + /* out of bounds read! */ + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); + return NULL; + } + + buf = (GLubyte*) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, packing->BufferObj); + if (!buf) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped"); + return NULL; + } + + return ADD_POINTERS(buf, pixels); +} + + +/** + * This function must be called after either of the validate_pbo_*_teximage() + * functions. It unmaps the PBO buffer if it was mapped earlier. + */ +void +_mesa_unmap_teximage_pbo(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack) +{ + if (_mesa_is_bufferobj(unpack->BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + unpack->BufferObj); + } +} + + +/** Return texture size in bytes */ +static GLuint +texture_size(const struct gl_texture_image *texImage) +{ + GLuint sz = _mesa_format_image_size(texImage->TexFormat, texImage->Width, + texImage->Height, texImage->Depth); + return sz; +} + + +/** Return row stride in bytes */ +static GLuint +texture_row_stride(const struct gl_texture_image *texImage) +{ + GLuint stride = _mesa_format_row_stride(texImage->TexFormat, + texImage->Width); + return stride; +} + + + +/** + * This is the software fallback for Driver.TexImage1D() + * and Driver.CopyTexImage1D(). + * \sa _mesa_store_teximage2d() + */ +void +_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLuint sizeInBytes; + (void) border; + + /* allocate memory */ + sizeInBytes = texture_size(texImage); + texImage->Data = _mesa_alloc_texmemory(sizeInBytes); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); + return; + } + + pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, + pixels, packing, "glTexImage1D"); + if (!pixels) { + /* Note: we check for a NULL image pointer here, _after_ we allocated + * memory for the texture. That's what the GL spec calls for. + */ + return; + } + else { + const GLint dstRowStride = 0; + GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, + texImage->ImageOffsets, + width, 1, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + +/** + * This is the software fallback for Driver.TexImage2D() + * and Driver.CopyTexImage2D(). + * + * This function is oriented toward storing images in main memory, rather + * than VRAM. Device driver's can easily plug in their own replacement. + */ +void +_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLuint sizeInBytes; + (void) border; + + /* allocate memory */ + sizeInBytes = texture_size(texImage); + texImage->Data = _mesa_alloc_texmemory(sizeInBytes); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); + return; + } + + pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type, + pixels, packing, "glTexImage2D"); + if (!pixels) { + /* Note: we check for a NULL image pointer here, _after_ we allocated + * memory for the texture. That's what the GL spec calls for. + */ + return; + } + else { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, + texImage->ImageOffsets, + width, height, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + + +/** + * This is the software fallback for Driver.TexImage3D() + * and Driver.CopyTexImage3D(). + * \sa _mesa_store_teximage2d() + */ +void +_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLuint sizeInBytes; + (void) border; + + /* allocate memory */ + sizeInBytes = texture_size(texImage); + texImage->Data = _mesa_alloc_texmemory(sizeInBytes); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); + return; + } + + pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, + type, pixels, packing, "glTexImage3D"); + if (!pixels) { + /* Note: we check for a NULL image pointer here, _after_ we allocated + * memory for the texture. That's what the GL spec calls for. + */ + return; + } + else { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, + texImage->ImageOffsets, + width, height, depth, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + + + +/* + * This is the software fallback for Driver.TexSubImage1D() + * and Driver.CopyTexSubImage1D(). + */ +void +_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint width, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, + pixels, packing, "glTexSubImage1D"); + if (!pixels) + return; + + { + const GLint dstRowStride = 0; + GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + xoffset, 0, 0, /* offsets */ + dstRowStride, + texImage->ImageOffsets, + width, 1, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + + +/** + * This is the software fallback for Driver.TexSubImage2D() + * and Driver.CopyTexSubImage2D(). + */ +void +_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint width, GLint height, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type, + pixels, packing, "glTexSubImage2D"); + if (!pixels) + return; + + { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + xoffset, yoffset, 0, + dstRowStride, + texImage->ImageOffsets, + width, height, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + +/* + * This is the software fallback for Driver.TexSubImage3D(). + * and Driver.CopyTexSubImage3D(). + */ +void +_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, + type, pixels, packing, + "glTexSubImage3D"); + if (!pixels) + return; + + { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + xoffset, yoffset, zoffset, + dstRowStride, + texImage->ImageOffsets, + width, height, depth, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + +/* + * Fallback for Driver.CompressedTexImage1D() + */ +void +_mesa_store_compressed_teximage1d(struct gl_context *ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* this space intentionally left blank */ + (void) ctx; + (void) target; (void) level; + (void) internalFormat; + (void) width; (void) border; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} + + + +/** + * Fallback for Driver.CompressedTexImage2D() + */ +void +_mesa_store_compressed_teximage2d(struct gl_context *ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + (void) width; (void) height; (void) border; + + /* This is pretty simple, basically just do a memcpy without worrying + * about the usual image unpacking or image transfer operations. + */ + ASSERT(texObj); + ASSERT(texImage); + ASSERT(texImage->Width > 0); + ASSERT(texImage->Height > 0); + ASSERT(texImage->Depth == 1); + ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */ + + /* allocate storage */ + texImage->Data = _mesa_alloc_texmemory(imageSize); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); + return; + } + + data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, + &ctx->Unpack, + "glCompressedTexImage2D"); + if (!data) + return; + + /* copy the data */ + memcpy(texImage->Data, data, imageSize); + + _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack); +} + + + +/* + * Fallback for Driver.CompressedTexImage3D() + */ +void +_mesa_store_compressed_teximage3d(struct gl_context *ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, + GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* this space intentionally left blank */ + (void) ctx; + (void) target; (void) level; + (void) internalFormat; + (void) width; (void) height; (void) depth; + (void) border; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} + + + +/** + * Fallback for Driver.CompressedTexSubImage1D() + */ +void +_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* there are no compressed 1D texture formats yet */ + (void) ctx; + (void) target; (void) level; + (void) xoffset; (void) width; + (void) format; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} + + +/** + * Fallback for Driver.CompressedTexSubImage2D() + */ +void +_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLint bytesPerRow, destRowStride, srcRowStride; + GLint i, rows; + GLubyte *dest; + const GLubyte *src; + const gl_format texFormat = texImage->TexFormat; + const GLint destWidth = texImage->Width; + GLuint bw, bh; + + _mesa_get_format_block_size(texFormat, &bw, &bh); + + (void) level; + (void) format; + + /* these should have been caught sooner */ + ASSERT((width % bw) == 0 || width == 2 || width == 1); + ASSERT((height % bh) == 0 || height == 2 || height == 1); + ASSERT((xoffset % bw) == 0); + ASSERT((yoffset % bh) == 0); + + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, + &ctx->Unpack, + "glCompressedTexSubImage2D"); + if (!data) + return; + + srcRowStride = _mesa_format_row_stride(texFormat, width); + src = (const GLubyte *) data; + + destRowStride = _mesa_format_row_stride(texFormat, destWidth); + dest = _mesa_compressed_image_address(xoffset, yoffset, 0, + texFormat, destWidth, + (GLubyte *) texImage->Data); + + bytesPerRow = srcRowStride; /* bytes per row of blocks */ + rows = height / bh; /* rows in blocks */ + + /* copy rows of blocks */ + for (i = 0; i < rows; i++) { + memcpy(dest, src, bytesPerRow); + dest += destRowStride; + src += srcRowStride; + } + + _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack); +} + + +/** + * Fallback for Driver.CompressedTexSubImage3D() + */ +void +_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* there are no compressed 3D texture formats yet */ + (void) ctx; + (void) target; (void) level; + (void) xoffset; (void) yoffset; (void) zoffset; + (void) width; (void) height; (void) depth; + (void) format; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} diff --git a/mesalib/src/mesa/main/texstore.h b/mesalib/src/mesa/main/texstore.h index 8640a23a7..2f3c4e821 100644 --- a/mesalib/src/mesa/main/texstore.h +++ b/mesalib/src/mesa/main/texstore.h @@ -1,218 +1,227 @@ -/*
- * Mesa 3-D graphics library
- * Version: 6.5.1
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- * Copyright (c) 2008 VMware, Inc.
- *
- * 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
- * BRIAN PAUL 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.
- */
-
-
-/**
- * \file texstore.h
- * Texture image storage routines.
- *
- * \author Brian Paul
- */
-
-
-#ifndef TEXSTORE_H
-#define TEXSTORE_H
-
-
-#include "mtypes.h"
-#include "formats.h"
-
-
-/**
- * This macro defines the (many) parameters to the texstore functions.
- * \param dims either 1 or 2 or 3
- * \param baseInternalFormat user-specified base internal format
- * \param dstFormat destination Mesa texture format
- * \param dstAddr destination image address
- * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels
- * \param dstRowStride destination image row stride, in bytes
- * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels
- * \param srcWidth/Height/Depth source image size, in pixels
- * \param srcFormat incoming image format
- * \param srcType incoming image data type
- * \param srcAddr source image address
- * \param srcPacking source image packing parameters
- */
-#define TEXSTORE_PARAMS \
- struct gl_context *ctx, GLuint dims, \
- GLenum baseInternalFormat, \
- gl_format dstFormat, \
- GLvoid *dstAddr, \
- GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
- GLint dstRowStride, const GLuint *dstImageOffsets, \
- GLint srcWidth, GLint srcHeight, GLint srcDepth, \
- GLenum srcFormat, GLenum srcType, \
- const GLvoid *srcAddr, \
- const struct gl_pixelstore_attrib *srcPacking
-
-
-extern GLboolean
-_mesa_texstore(TEXSTORE_PARAMS);
-
-
-extern GLchan *
-_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims,
- GLenum logicalBaseFormat,
- GLenum textureBaseFormat,
- GLint srcWidth, GLint srcHeight, GLint srcDepth,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcAddr,
- const struct gl_pixelstore_attrib *srcPacking);
-
-
-extern void
-_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint border,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-
-extern void
-_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint border,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-
-extern void
-_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint depth, GLint border,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-
-extern void
-_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint width,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-
-extern void
-_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint width, GLint height,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-
-extern void
-_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLint width, GLint height, GLint depth,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-
-extern void
-_mesa_store_compressed_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-extern void
-_mesa_store_compressed_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-extern void
-_mesa_store_compressed_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint depth,
- GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-
-extern void
-_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target,
- GLint level,
- GLint xoffset, GLsizei width,
- GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-extern void
-_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target,
- GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-extern void
-_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target,
- GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-
-extern const GLvoid *
-_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *unpack,
- const char *funcName);
-
-extern const GLvoid *
-_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx,
- GLsizei imageSize, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- const char *funcName);
-
-extern void
-_mesa_unmap_teximage_pbo(struct gl_context *ctx,
- const struct gl_pixelstore_attrib *unpack);
-
-
-#endif
+/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, Inc. + * + * 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 + * BRIAN PAUL 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. + */ + + +/** + * \file texstore.h + * Texture image storage routines. + * + * \author Brian Paul + */ + + +#ifndef TEXSTORE_H +#define TEXSTORE_H + + +#include "mtypes.h" +#include "formats.h" + + +/** + * This macro defines the (many) parameters to the texstore functions. + * \param dims either 1 or 2 or 3 + * \param baseInternalFormat user-specified base internal format + * \param dstFormat destination Mesa texture format + * \param dstAddr destination image address + * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels + * \param dstRowStride destination image row stride, in bytes + * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels + * \param srcWidth/Height/Depth source image size, in pixels + * \param srcFormat incoming image format + * \param srcType incoming image data type + * \param srcAddr source image address + * \param srcPacking source image packing parameters + */ +#define TEXSTORE_PARAMS \ + struct gl_context *ctx, GLuint dims, \ + GLenum baseInternalFormat, \ + gl_format dstFormat, \ + GLvoid *dstAddr, \ + GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \ + GLint dstRowStride, const GLuint *dstImageOffsets, \ + GLint srcWidth, GLint srcHeight, GLint srcDepth, \ + GLenum srcFormat, GLenum srcType, \ + const GLvoid *srcAddr, \ + const struct gl_pixelstore_attrib *srcPacking + + +extern GLboolean +_mesa_texstore(TEXSTORE_PARAMS); + + +extern GLchan * +_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking); + +GLfloat * +_mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps); + +extern void +_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint width, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint width, GLint height, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_compressed_teximage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_teximage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_teximage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, + GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern const GLvoid * +_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *unpack, + const char *funcName); + +extern const GLvoid * +_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, + GLsizei imageSize, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + const char *funcName); + +extern void +_mesa_unmap_teximage_pbo(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack); + + +#endif diff --git a/mesalib/src/mesa/sources.mak b/mesalib/src/mesa/sources.mak index b10881c55..bdf4126cf 100644 --- a/mesalib/src/mesa/sources.mak +++ b/mesalib/src/mesa/sources.mak @@ -1,368 +1,369 @@ -### Lists of source files, included by Makefiles
-
-# this is part of MAIN_SOURCES
-MAIN_ES_SOURCES = \
- main/api_exec_es1.c \
- main/api_exec_es2.c
-
-MAIN_SOURCES = \
- main/api_arrayelt.c \
- main/api_exec.c \
- main/api_loopback.c \
- main/api_noop.c \
- main/api_validate.c \
- main/accum.c \
- main/arbprogram.c \
- main/atifragshader.c \
- main/attrib.c \
- main/arrayobj.c \
- main/blend.c \
- main/bufferobj.c \
- main/buffers.c \
- main/clear.c \
- main/clip.c \
- main/colortab.c \
- main/condrender.c \
- main/context.c \
- main/convolve.c \
- main/cpuinfo.c \
- main/debug.c \
- main/depth.c \
- main/depthstencil.c \
- main/dlist.c \
- main/dlopen.c \
- main/drawpix.c \
- main/drawtex.c \
- main/enable.c \
- main/enums.c \
- main/eval.c \
- main/execmem.c \
- main/extensions.c \
- main/fbobject.c \
- main/feedback.c \
- main/ffvertex_prog.c \
- main/fog.c \
- main/formats.c \
- main/framebuffer.c \
- main/get.c \
- main/getstring.c \
- main/hash.c \
- main/hint.c \
- main/histogram.c \
- main/image.c \
- main/imports.c \
- main/light.c \
- main/lines.c \
- main/matrix.c \
- main/mipmap.c \
- main/mm.c \
- main/multisample.c \
- main/nvprogram.c \
- main/pack.c \
- main/pixel.c \
- main/pixelstore.c \
- main/pixeltransfer.c \
- main/points.c \
- main/polygon.c \
- main/queryobj.c \
- main/querymatrix.c \
- main/rastpos.c \
- main/readpix.c \
- main/remap.c \
- main/renderbuffer.c \
- main/scissor.c \
- main/shaderapi.c \
- main/shaderobj.c \
- main/shared.c \
- main/state.c \
- main/stencil.c \
- main/syncobj.c \
- main/texcompress.c \
- main/texcompress_s3tc.c \
- main/texcompress_fxt1.c \
- main/texenv.c \
- main/texenvprogram.c \
- main/texfetch.c \
- main/texformat.c \
- main/texgen.c \
- main/texgetimage.c \
- main/teximage.c \
- main/texobj.c \
- main/texpal.c \
- main/texparam.c \
- main/texrender.c \
- main/texstate.c \
- main/texstore.c \
- main/transformfeedback.c \
- main/uniforms.c \
- main/varray.c \
- main/version.c \
- main/viewport.c \
- main/vtxfmt.c \
- $(MAIN_ES_SOURCES)
-
-MATH_SOURCES = \
- math/m_debug_clip.c \
- math/m_debug_norm.c \
- math/m_debug_xform.c \
- math/m_eval.c \
- math/m_matrix.c \
- math/m_translate.c \
- math/m_vector.c
-
-MATH_XFORM_SOURCES = \
- math/m_xform.c
-
-SWRAST_SOURCES = \
- swrast/s_aaline.c \
- swrast/s_aatriangle.c \
- swrast/s_accum.c \
- swrast/s_alpha.c \
- swrast/s_atifragshader.c \
- swrast/s_bitmap.c \
- swrast/s_blend.c \
- swrast/s_blit.c \
- swrast/s_clear.c \
- swrast/s_copypix.c \
- swrast/s_context.c \
- swrast/s_depth.c \
- swrast/s_drawpix.c \
- swrast/s_feedback.c \
- swrast/s_fog.c \
- swrast/s_fragprog.c \
- swrast/s_lines.c \
- swrast/s_logic.c \
- swrast/s_masking.c \
- swrast/s_points.c \
- swrast/s_readpix.c \
- swrast/s_span.c \
- swrast/s_stencil.c \
- swrast/s_texcombine.c \
- swrast/s_texfilter.c \
- swrast/s_triangle.c \
- swrast/s_zoom.c
-
-SWRAST_SETUP_SOURCES = \
- swrast_setup/ss_context.c \
- swrast_setup/ss_triangle.c
-
-TNL_SOURCES = \
- tnl/t_context.c \
- tnl/t_pipeline.c \
- tnl/t_draw.c \
- tnl/t_rasterpos.c \
- tnl/t_vb_program.c \
- tnl/t_vb_render.c \
- tnl/t_vb_texgen.c \
- tnl/t_vb_texmat.c \
- tnl/t_vb_vertex.c \
- tnl/t_vb_fog.c \
- tnl/t_vb_light.c \
- tnl/t_vb_normals.c \
- tnl/t_vb_points.c \
- tnl/t_vp_build.c \
- tnl/t_vertex.c \
- tnl/t_vertex_sse.c \
- tnl/t_vertex_generic.c
-
-VBO_SOURCES = \
- vbo/vbo_context.c \
- vbo/vbo_exec.c \
- vbo/vbo_exec_api.c \
- vbo/vbo_exec_array.c \
- vbo/vbo_exec_draw.c \
- vbo/vbo_exec_eval.c \
- vbo/vbo_rebase.c \
- vbo/vbo_split.c \
- vbo/vbo_split_copy.c \
- vbo/vbo_split_inplace.c \
- vbo/vbo_save.c \
- vbo/vbo_save_api.c \
- vbo/vbo_save_draw.c \
- vbo/vbo_save_loopback.c
-
-STATETRACKER_SOURCES = \
- state_tracker/st_atom.c \
- state_tracker/st_atom_blend.c \
- state_tracker/st_atom_clip.c \
- state_tracker/st_atom_constbuf.c \
- state_tracker/st_atom_depth.c \
- state_tracker/st_atom_framebuffer.c \
- state_tracker/st_atom_msaa.c \
- state_tracker/st_atom_pixeltransfer.c \
- state_tracker/st_atom_sampler.c \
- state_tracker/st_atom_scissor.c \
- state_tracker/st_atom_shader.c \
- state_tracker/st_atom_rasterizer.c \
- state_tracker/st_atom_stipple.c \
- state_tracker/st_atom_texture.c \
- state_tracker/st_atom_viewport.c \
- state_tracker/st_cb_accum.c \
- state_tracker/st_cb_bitmap.c \
- state_tracker/st_cb_blit.c \
- state_tracker/st_cb_bufferobjects.c \
- state_tracker/st_cb_clear.c \
- state_tracker/st_cb_condrender.c \
- state_tracker/st_cb_flush.c \
- state_tracker/st_cb_drawpixels.c \
- state_tracker/st_cb_drawtex.c \
- state_tracker/st_cb_eglimage.c \
- state_tracker/st_cb_fbo.c \
- state_tracker/st_cb_feedback.c \
- state_tracker/st_cb_program.c \
- state_tracker/st_cb_queryobj.c \
- state_tracker/st_cb_rasterpos.c \
- state_tracker/st_cb_readpixels.c \
- state_tracker/st_cb_strings.c \
- state_tracker/st_cb_texture.c \
- state_tracker/st_cb_viewport.c \
- state_tracker/st_cb_xformfb.c \
- state_tracker/st_context.c \
- state_tracker/st_debug.c \
- state_tracker/st_draw.c \
- state_tracker/st_draw_feedback.c \
- state_tracker/st_extensions.c \
- state_tracker/st_format.c \
- state_tracker/st_gen_mipmap.c \
- state_tracker/st_manager.c \
- state_tracker/st_mesa_to_tgsi.c \
- state_tracker/st_program.c \
- state_tracker/st_texture.c
-
-PROGRAM_SOURCES = \
- program/arbprogparse.c \
- program/hash_table.c \
- program/lex.yy.c \
- program/nvfragparse.c \
- program/nvvertparse.c \
- program/program.c \
- program/program_parse.tab.c \
- program/program_parse_extra.c \
- program/prog_cache.c \
- program/prog_execute.c \
- program/prog_instruction.c \
- program/prog_noise.c \
- program/prog_optimize.c \
- program/prog_parameter.c \
- program/prog_parameter_layout.c \
- program/prog_print.c \
- program/prog_statevars.c \
- program/prog_uniform.c \
- program/programopt.c \
- program/register_allocate.c \
- program/symbol_table.c
-
-SHADER_CXX_SOURCES = \
- program/ir_to_mesa.cpp \
- program/sampler.cpp
-
-ASM_C_SOURCES = \
- x86/common_x86.c \
- x86/x86_xform.c \
- x86/3dnow.c \
- x86/sse.c \
- x86/rtasm/x86sse.c \
- sparc/sparc.c \
- ppc/common_ppc.c \
- x86-64/x86-64.c
-
-X86_SOURCES = \
- x86/common_x86_asm.S \
- x86/x86_xform2.S \
- x86/x86_xform3.S \
- x86/x86_xform4.S \
- x86/x86_cliptest.S \
- x86/mmx_blend.S \
- x86/3dnow_xform1.S \
- x86/3dnow_xform2.S \
- x86/3dnow_xform3.S \
- x86/3dnow_xform4.S \
- x86/3dnow_normal.S \
- x86/sse_xform1.S \
- x86/sse_xform2.S \
- x86/sse_xform3.S \
- x86/sse_xform4.S \
- x86/sse_normal.S \
- x86/read_rgba_span_x86.S
-
-X86-64_SOURCES = \
- x86-64/xform4.S
-
-SPARC_SOURCES = \
- sparc/clip.S \
- sparc/norm.S \
- sparc/xform.S
-
-COMMON_DRIVER_SOURCES = \
- drivers/common/driverfuncs.c \
- drivers/common/meta.c
-
-
-# Sources for building non-Gallium drivers
-MESA_SOURCES = \
- $(MAIN_SOURCES) \
- $(MATH_SOURCES) \
- $(MATH_XFORM_SOURCES) \
- $(VBO_SOURCES) \
- $(TNL_SOURCES) \
- $(PROGRAM_SOURCES) \
- $(SWRAST_SOURCES) \
- $(SWRAST_SETUP_SOURCES) \
- $(COMMON_DRIVER_SOURCES)\
- $(ASM_C_SOURCES)
-
-MESA_CXX_SOURCES = \
- $(SHADER_CXX_SOURCES)
-
-# Sources for building Gallium drivers
-MESA_GALLIUM_SOURCES = \
- $(MAIN_SOURCES) \
- $(MATH_SOURCES) \
- $(VBO_SOURCES) \
- $(STATETRACKER_SOURCES) \
- $(PROGRAM_SOURCES) \
- ppc/common_ppc.c \
- x86/common_x86.c
-
-MESA_GALLIUM_CXX_SOURCES = \
- $(SHADER_CXX_SOURCES)
-
-# All the core C sources, for dependency checking
-ALL_SOURCES = \
- $(MESA_SOURCES) \
- $(MESA_CXX_SOURCES) \
- $(MESA_ASM_SOURCES) \
- $(STATETRACKER_SOURCES)
-
-
-### Object files
-
-MESA_OBJECTS = \
- $(MESA_SOURCES:.c=.o) \
- $(MESA_CXX_SOURCES:.cpp=.o) \
- $(MESA_ASM_SOURCES:.S=.o)
-
-MESA_GALLIUM_OBJECTS = \
- $(MESA_GALLIUM_SOURCES:.c=.o) \
- $(MESA_GALLIUM_CXX_SOURCES:.cpp=.o) \
- $(MESA_ASM_SOURCES:.S=.o)
-
-
-COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o)
-
-
-### Other archives/libraries
-
-GLSL_LIBS = \
- $(TOP)/src/glsl/libglsl.a
-
-
-### Include directories
-
-INCLUDE_DIRS = \
- -I$(TOP)/include \
- -I$(TOP)/src/glsl \
- -I$(TOP)/src/mesa \
- -I$(TOP)/src/mapi \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/auxiliary
+### Lists of source files, included by Makefiles + +# this is part of MAIN_SOURCES +MAIN_ES_SOURCES = \ + main/api_exec_es1.c \ + main/api_exec_es2.c + +MAIN_SOURCES = \ + main/api_arrayelt.c \ + main/api_exec.c \ + main/api_loopback.c \ + main/api_noop.c \ + main/api_validate.c \ + main/accum.c \ + main/arbprogram.c \ + main/atifragshader.c \ + main/attrib.c \ + main/arrayobj.c \ + main/blend.c \ + main/bufferobj.c \ + main/buffers.c \ + main/clear.c \ + main/clip.c \ + main/colortab.c \ + main/condrender.c \ + main/context.c \ + main/convolve.c \ + main/cpuinfo.c \ + main/debug.c \ + main/depth.c \ + main/depthstencil.c \ + main/dlist.c \ + main/dlopen.c \ + main/drawpix.c \ + main/drawtex.c \ + main/enable.c \ + main/enums.c \ + main/eval.c \ + main/execmem.c \ + main/extensions.c \ + main/fbobject.c \ + main/feedback.c \ + main/ffvertex_prog.c \ + main/fog.c \ + main/formats.c \ + main/framebuffer.c \ + main/get.c \ + main/getstring.c \ + main/hash.c \ + main/hint.c \ + main/histogram.c \ + main/image.c \ + main/imports.c \ + main/light.c \ + main/lines.c \ + main/matrix.c \ + main/mipmap.c \ + main/mm.c \ + main/multisample.c \ + main/nvprogram.c \ + main/pack.c \ + main/pixel.c \ + main/pixelstore.c \ + main/pixeltransfer.c \ + main/points.c \ + main/polygon.c \ + main/queryobj.c \ + main/querymatrix.c \ + main/rastpos.c \ + main/readpix.c \ + main/remap.c \ + main/renderbuffer.c \ + main/scissor.c \ + main/shaderapi.c \ + main/shaderobj.c \ + main/shared.c \ + main/state.c \ + main/stencil.c \ + main/syncobj.c \ + main/texcompress.c \ + main/texcompress_rgtc.c \ + main/texcompress_s3tc.c \ + main/texcompress_fxt1.c \ + main/texenv.c \ + main/texenvprogram.c \ + main/texfetch.c \ + main/texformat.c \ + main/texgen.c \ + main/texgetimage.c \ + main/teximage.c \ + main/texobj.c \ + main/texpal.c \ + main/texparam.c \ + main/texrender.c \ + main/texstate.c \ + main/texstore.c \ + main/transformfeedback.c \ + main/uniforms.c \ + main/varray.c \ + main/version.c \ + main/viewport.c \ + main/vtxfmt.c \ + $(MAIN_ES_SOURCES) + +MATH_SOURCES = \ + math/m_debug_clip.c \ + math/m_debug_norm.c \ + math/m_debug_xform.c \ + math/m_eval.c \ + math/m_matrix.c \ + math/m_translate.c \ + math/m_vector.c + +MATH_XFORM_SOURCES = \ + math/m_xform.c + +SWRAST_SOURCES = \ + swrast/s_aaline.c \ + swrast/s_aatriangle.c \ + swrast/s_accum.c \ + swrast/s_alpha.c \ + swrast/s_atifragshader.c \ + swrast/s_bitmap.c \ + swrast/s_blend.c \ + swrast/s_blit.c \ + swrast/s_clear.c \ + swrast/s_copypix.c \ + swrast/s_context.c \ + swrast/s_depth.c \ + swrast/s_drawpix.c \ + swrast/s_feedback.c \ + swrast/s_fog.c \ + swrast/s_fragprog.c \ + swrast/s_lines.c \ + swrast/s_logic.c \ + swrast/s_masking.c \ + swrast/s_points.c \ + swrast/s_readpix.c \ + swrast/s_span.c \ + swrast/s_stencil.c \ + swrast/s_texcombine.c \ + swrast/s_texfilter.c \ + swrast/s_triangle.c \ + swrast/s_zoom.c + +SWRAST_SETUP_SOURCES = \ + swrast_setup/ss_context.c \ + swrast_setup/ss_triangle.c + +TNL_SOURCES = \ + tnl/t_context.c \ + tnl/t_pipeline.c \ + tnl/t_draw.c \ + tnl/t_rasterpos.c \ + tnl/t_vb_program.c \ + tnl/t_vb_render.c \ + tnl/t_vb_texgen.c \ + tnl/t_vb_texmat.c \ + tnl/t_vb_vertex.c \ + tnl/t_vb_fog.c \ + tnl/t_vb_light.c \ + tnl/t_vb_normals.c \ + tnl/t_vb_points.c \ + tnl/t_vp_build.c \ + tnl/t_vertex.c \ + tnl/t_vertex_sse.c \ + tnl/t_vertex_generic.c + +VBO_SOURCES = \ + vbo/vbo_context.c \ + vbo/vbo_exec.c \ + vbo/vbo_exec_api.c \ + vbo/vbo_exec_array.c \ + vbo/vbo_exec_draw.c \ + vbo/vbo_exec_eval.c \ + vbo/vbo_rebase.c \ + vbo/vbo_split.c \ + vbo/vbo_split_copy.c \ + vbo/vbo_split_inplace.c \ + vbo/vbo_save.c \ + vbo/vbo_save_api.c \ + vbo/vbo_save_draw.c \ + vbo/vbo_save_loopback.c + +STATETRACKER_SOURCES = \ + state_tracker/st_atom.c \ + state_tracker/st_atom_blend.c \ + state_tracker/st_atom_clip.c \ + state_tracker/st_atom_constbuf.c \ + state_tracker/st_atom_depth.c \ + state_tracker/st_atom_framebuffer.c \ + state_tracker/st_atom_msaa.c \ + state_tracker/st_atom_pixeltransfer.c \ + state_tracker/st_atom_sampler.c \ + state_tracker/st_atom_scissor.c \ + state_tracker/st_atom_shader.c \ + state_tracker/st_atom_rasterizer.c \ + state_tracker/st_atom_stipple.c \ + state_tracker/st_atom_texture.c \ + state_tracker/st_atom_viewport.c \ + state_tracker/st_cb_accum.c \ + state_tracker/st_cb_bitmap.c \ + state_tracker/st_cb_blit.c \ + state_tracker/st_cb_bufferobjects.c \ + state_tracker/st_cb_clear.c \ + state_tracker/st_cb_condrender.c \ + state_tracker/st_cb_flush.c \ + state_tracker/st_cb_drawpixels.c \ + state_tracker/st_cb_drawtex.c \ + state_tracker/st_cb_eglimage.c \ + state_tracker/st_cb_fbo.c \ + state_tracker/st_cb_feedback.c \ + state_tracker/st_cb_program.c \ + state_tracker/st_cb_queryobj.c \ + state_tracker/st_cb_rasterpos.c \ + state_tracker/st_cb_readpixels.c \ + state_tracker/st_cb_strings.c \ + state_tracker/st_cb_texture.c \ + state_tracker/st_cb_viewport.c \ + state_tracker/st_cb_xformfb.c \ + state_tracker/st_context.c \ + state_tracker/st_debug.c \ + state_tracker/st_draw.c \ + state_tracker/st_draw_feedback.c \ + state_tracker/st_extensions.c \ + state_tracker/st_format.c \ + state_tracker/st_gen_mipmap.c \ + state_tracker/st_manager.c \ + state_tracker/st_mesa_to_tgsi.c \ + state_tracker/st_program.c \ + state_tracker/st_texture.c + +PROGRAM_SOURCES = \ + program/arbprogparse.c \ + program/hash_table.c \ + program/lex.yy.c \ + program/nvfragparse.c \ + program/nvvertparse.c \ + program/program.c \ + program/program_parse.tab.c \ + program/program_parse_extra.c \ + program/prog_cache.c \ + program/prog_execute.c \ + program/prog_instruction.c \ + program/prog_noise.c \ + program/prog_optimize.c \ + program/prog_parameter.c \ + program/prog_parameter_layout.c \ + program/prog_print.c \ + program/prog_statevars.c \ + program/prog_uniform.c \ + program/programopt.c \ + program/register_allocate.c \ + program/symbol_table.c + +SHADER_CXX_SOURCES = \ + program/ir_to_mesa.cpp \ + program/sampler.cpp + +ASM_C_SOURCES = \ + x86/common_x86.c \ + x86/x86_xform.c \ + x86/3dnow.c \ + x86/sse.c \ + x86/rtasm/x86sse.c \ + sparc/sparc.c \ + ppc/common_ppc.c \ + x86-64/x86-64.c + +X86_SOURCES = \ + x86/common_x86_asm.S \ + x86/x86_xform2.S \ + x86/x86_xform3.S \ + x86/x86_xform4.S \ + x86/x86_cliptest.S \ + x86/mmx_blend.S \ + x86/3dnow_xform1.S \ + x86/3dnow_xform2.S \ + x86/3dnow_xform3.S \ + x86/3dnow_xform4.S \ + x86/3dnow_normal.S \ + x86/sse_xform1.S \ + x86/sse_xform2.S \ + x86/sse_xform3.S \ + x86/sse_xform4.S \ + x86/sse_normal.S \ + x86/read_rgba_span_x86.S + +X86-64_SOURCES = \ + x86-64/xform4.S + +SPARC_SOURCES = \ + sparc/clip.S \ + sparc/norm.S \ + sparc/xform.S + +COMMON_DRIVER_SOURCES = \ + drivers/common/driverfuncs.c \ + drivers/common/meta.c + + +# Sources for building non-Gallium drivers +MESA_SOURCES = \ + $(MAIN_SOURCES) \ + $(MATH_SOURCES) \ + $(MATH_XFORM_SOURCES) \ + $(VBO_SOURCES) \ + $(TNL_SOURCES) \ + $(PROGRAM_SOURCES) \ + $(SWRAST_SOURCES) \ + $(SWRAST_SETUP_SOURCES) \ + $(COMMON_DRIVER_SOURCES)\ + $(ASM_C_SOURCES) + +MESA_CXX_SOURCES = \ + $(SHADER_CXX_SOURCES) + +# Sources for building Gallium drivers +MESA_GALLIUM_SOURCES = \ + $(MAIN_SOURCES) \ + $(MATH_SOURCES) \ + $(VBO_SOURCES) \ + $(STATETRACKER_SOURCES) \ + $(PROGRAM_SOURCES) \ + ppc/common_ppc.c \ + x86/common_x86.c + +MESA_GALLIUM_CXX_SOURCES = \ + $(SHADER_CXX_SOURCES) + +# All the core C sources, for dependency checking +ALL_SOURCES = \ + $(MESA_SOURCES) \ + $(MESA_CXX_SOURCES) \ + $(MESA_ASM_SOURCES) \ + $(STATETRACKER_SOURCES) + + +### Object files + +MESA_OBJECTS = \ + $(MESA_SOURCES:.c=.o) \ + $(MESA_CXX_SOURCES:.cpp=.o) \ + $(MESA_ASM_SOURCES:.S=.o) + +MESA_GALLIUM_OBJECTS = \ + $(MESA_GALLIUM_SOURCES:.c=.o) \ + $(MESA_GALLIUM_CXX_SOURCES:.cpp=.o) \ + $(MESA_ASM_SOURCES:.S=.o) + + +COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o) + + +### Other archives/libraries + +GLSL_LIBS = \ + $(TOP)/src/glsl/libglsl.a + + +### Include directories + +INCLUDE_DIRS = \ + -I$(TOP)/include \ + -I$(TOP)/src/glsl \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/mapi \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/auxiliary diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c index 6530a06ad..c99eafbad 100644 --- a/mesalib/src/mesa/state_tracker/st_draw.c +++ b/mesalib/src/mesa/state_tracker/st_draw.c @@ -579,6 +579,7 @@ st_validate_varrays(struct gl_context *ctx, if (is_interleaved_arrays(vp, vpv, arrays)) { setup_interleaved_attribs(ctx, vp, vpv, arrays, vbuffer, velements, max_index); + num_vbuffers = 1; num_velements = vpv->num_inputs; if (num_velements == 0) @@ -645,6 +646,7 @@ st_draw_vbo(struct gl_context *ctx, for (i = 0; i < nr_prims; i++) { min_index = MIN2(min_index, prims[i].start); max_index = MAX2(max_index, prims[i].start + prims[i].count - 1); + max_index = MAX2(max_index, prims[i].num_instances); } } diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index b1ede1c8b..d2098987d 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -1,482 +1,498 @@ -/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * Copyright (c) 2008 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, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "main/imports.h"
-#include "main/context.h"
-#include "main/macros.h"
-#include "main/mfeatures.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_screen.h"
-
-#include "st_context.h"
-#include "st_extensions.h"
-
-
-static int _min(int a, int b)
-{
- return (a < b) ? a : b;
-}
-
-static float _maxf(float a, float b)
-{
- return (a > b) ? a : b;
-}
-
-static int _clamp(int a, int min, int max)
-{
- if (a < min)
- return min;
- else if (a > max)
- return max;
- else
- return a;
-}
-
-
-/**
- * Query driver to get implementation limits.
- * Note that we have to limit/clamp against Mesa's internal limits too.
- */
-void st_init_limits(struct st_context *st)
-{
- struct pipe_screen *screen = st->pipe->screen;
- struct gl_constants *c = &st->ctx->Const;
- gl_shader_type sh;
-
- c->MaxTextureLevels
- = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
- MAX_TEXTURE_LEVELS);
-
- c->Max3DTextureLevels
- = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS),
- MAX_3D_TEXTURE_LEVELS);
-
- c->MaxCubeTextureLevels
- = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS),
- MAX_CUBE_TEXTURE_LEVELS);
-
- c->MaxTextureRectSize
- = _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE);
-
- c->MaxTextureImageUnits
- = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS),
- MAX_TEXTURE_IMAGE_UNITS);
-
- c->MaxVertexTextureImageUnits
- = _min(screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS),
- MAX_VERTEX_TEXTURE_IMAGE_UNITS);
-
- c->MaxCombinedTextureImageUnits
- = _min(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS),
- MAX_COMBINED_TEXTURE_IMAGE_UNITS);
-
- c->MaxTextureCoordUnits
- = _min(c->MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS);
-
- c->MaxTextureUnits = _min(c->MaxTextureImageUnits, c->MaxTextureCoordUnits);
-
- c->MaxDrawBuffers
- = _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
- 1, MAX_DRAW_BUFFERS);
-
- c->MaxLineWidth
- = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH));
- c->MaxLineWidthAA
- = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA));
-
- c->MaxPointSize
- = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH));
- c->MaxPointSizeAA
- = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA));
- /* called after _mesa_create_context/_mesa_init_point, fix default user
- * settable max point size up
- */
- st->ctx->Point.MaxSize = MAX2(c->MaxPointSize, c->MaxPointSizeAA);
- /* these are not queryable. Note that GL basically mandates a 1.0 minimum
- * for non-aa sizes, but we can go down to 0.0 for aa points.
- */
- c->MinPointSize = 1.0f;
- c->MinPointSizeAA = 0.0f;
-
- c->MaxTextureMaxAnisotropy
- = _maxf(2.0f, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY));
-
- c->MaxTextureLodBias
- = screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_LOD_BIAS);
-
- c->MaxDrawBuffers
- = CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
- 1, MAX_DRAW_BUFFERS);
-
- /* Quads always follow GL provoking rules. */
- c->QuadsFollowProvokingVertexConvention = GL_FALSE;
-
- for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) {
- struct gl_shader_compiler_options *options =
- &st->ctx->ShaderCompilerOptions[sh];
- struct gl_program_constants *pc;
-
- switch (sh) {
- case PIPE_SHADER_FRAGMENT:
- pc = &c->FragmentProgram;
- break;
- case PIPE_SHADER_VERTEX:
- pc = &c->VertexProgram;
- break;
- case PIPE_SHADER_GEOMETRY:
- pc = &c->GeometryProgram;
- break;
- default:
- assert(0);
- continue;
- }
-
- pc->MaxNativeInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS);
- pc->MaxNativeAluInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS);
- pc->MaxNativeTexInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS);
- pc->MaxNativeTexIndirections = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS);
- pc->MaxNativeAttribs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS);
- pc->MaxNativeTemps = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEMPS);
- pc->MaxNativeAddressRegs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS);
- pc->MaxNativeParameters = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONSTS);
- pc->MaxUniformComponents = 4 * MIN2(pc->MaxNativeParameters, MAX_UNIFORMS);
-
- options->EmitNoNoise = TRUE;
-
- /* TODO: make these more fine-grained if anyone needs it */
- options->EmitNoIfs = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
- options->EmitNoLoops = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
- options->EmitNoFunctions = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES);
- options->EmitNoMainReturn = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES);
-
- options->EmitNoCont = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED);
-
- options->EmitNoIndirectInput = !screen->get_shader_param(screen, sh,
- PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR);
- options->EmitNoIndirectOutput = !screen->get_shader_param(screen, sh,
- PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR);
- options->EmitNoIndirectTemp = !screen->get_shader_param(screen, sh,
- PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR);
- options->EmitNoIndirectUniform = !screen->get_shader_param(screen, sh,
- PIPE_SHADER_CAP_INDIRECT_CONST_ADDR);
-
- if(options->EmitNoLoops)
- options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536);
- }
-
- /* PIPE_CAP_MAX_FS_INPUTS specifies the number of COLORn + GENERICn inputs
- * and is set in MaxNativeAttribs. It's always 2 colors + N generic
- * attributes. The GLSL compiler never uses COLORn for varyings, so we
- * subtract the 2 colors to get the maximum number of varyings (generic
- * attributes) supported by a driver. */
- c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INPUTS) - 2;
- c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING);
-
- /* XXX we'll need a better query here someday */
- if (screen->get_param(screen, PIPE_CAP_GLSL)) {
- c->GLSLVersion = 120;
- }
-}
-
-
-/**
- * Use pipe_screen::get_param() to query PIPE_CAP_ values to determine
- * which GL extensions are supported.
- * Quite a few extensions are always supported because they are standard
- * features or can be built on top of other gallium features.
- * Some fine tuning may still be needed.
- */
-void st_init_extensions(struct st_context *st)
-{
- struct pipe_screen *screen = st->pipe->screen;
- struct gl_context *ctx = st->ctx;
-
- /*
- * Extensions that are supported by all Gallium drivers:
- */
- ctx->Extensions.ARB_copy_buffer = GL_TRUE;
- ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE;
- ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE;
- ctx->Extensions.ARB_fragment_program = GL_TRUE;
- ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
- ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
- ctx->Extensions.ARB_multisample = GL_TRUE;
- ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */
- ctx->Extensions.ARB_texture_compression = GL_TRUE;
- ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
- ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
- ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
- ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
- ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
- ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;
- ctx->Extensions.ARB_vertex_program = GL_TRUE;
- ctx->Extensions.ARB_window_pos = GL_TRUE;
-
- ctx->Extensions.EXT_blend_color = GL_TRUE;
- ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
- ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
- ctx->Extensions.EXT_blend_minmax = GL_TRUE;
- ctx->Extensions.EXT_blend_subtract = GL_TRUE;
- ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
- ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
- ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE;
- ctx->Extensions.EXT_fog_coord = GL_TRUE;
- ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
- ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
- ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
- ctx->Extensions.EXT_point_parameters = GL_TRUE;
- ctx->Extensions.EXT_provoking_vertex = GL_TRUE;
- ctx->Extensions.EXT_secondary_color = GL_TRUE;
- ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
- ctx->Extensions.EXT_texture_env_add = GL_TRUE;
- ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
- ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
- ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
- ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
- if (ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2)
- ctx->Extensions.EXT_texture_format_BGRA8888 = GL_TRUE;
-
- ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
-
- ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
-
- ctx->Extensions.MESA_pack_invert = GL_TRUE;
-
- ctx->Extensions.NV_blend_square = GL_TRUE;
- ctx->Extensions.NV_texgen_reflection = GL_TRUE;
- ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
- ctx->Extensions.NV_texture_rectangle = GL_TRUE;
-#if 0
- /* possibly could support the following two */
- ctx->Extensions.NV_vertex_program = GL_TRUE;
- ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
-#endif
-
-#if FEATURE_OES_EGL_image
- ctx->Extensions.OES_EGL_image = GL_TRUE;
-#endif
-#if FEATURE_OES_draw_texture
- ctx->Extensions.OES_draw_texture = GL_TRUE;
-#endif
-
- ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
-
- /*
- * Extensions that depend on the driver/hardware:
- */
- if (screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS) > 0) {
- ctx->Extensions.ARB_draw_buffers = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_TEXTURE_SWIZZLE) > 0) {
- ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_GLSL)) {
- ctx->Extensions.ARB_fragment_shader = GL_TRUE;
- ctx->Extensions.ARB_vertex_shader = GL_TRUE;
- ctx->Extensions.ARB_shader_objects = GL_TRUE;
- ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
- ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE;
- ctx->Extensions.EXT_separate_shader_objects = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_REPEAT) > 0) {
- ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_BLEND_EQUATION_SEPARATE)) {
- ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_CLAMP) > 0) {
- ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
- ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES)) {
- ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS) > 1) {
- ctx->Extensions.ARB_multitexture = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_TWO_SIDED_STENCIL)) {
- ctx->Extensions.ATI_separate_stencil = GL_TRUE;
- ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_ANISOTROPIC_FILTER)) {
- ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_POINT_SPRITE)) {
- ctx->Extensions.ARB_point_sprite = GL_TRUE;
- /* GL_NV_point_sprite is not supported by gallium because we don't
- * support the GL_POINT_SPRITE_R_MODE_NV option.
- */
- }
-
- if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) {
- ctx->Extensions.ARB_occlusion_query = GL_TRUE;
- ctx->Extensions.ARB_occlusion_query2 = GL_TRUE;
- }
- if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY)) {
- ctx->Extensions.EXT_timer_query = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) {
- ctx->Extensions.ARB_depth_texture = GL_TRUE;
- ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE;
- ctx->Extensions.ARB_shadow = GL_TRUE;
- ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
- /*ctx->Extensions.ARB_shadow_ambient = GL_TRUE;*/
- }
-
- /* GL_EXT_packed_depth_stencil requires both the ability to render to
- * a depth/stencil buffer and texture from depth/stencil source.
- */
- if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_DEPTH_STENCIL, 0) &&
- screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_SAMPLER_VIEW, 0)) {
- ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
- }
- else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_DEPTH_STENCIL, 0) &&
- screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_SAMPLER_VIEW, 0)) {
- ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
- }
-
- /* sRGB support */
- if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_SAMPLER_VIEW, 0) ||
- screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_SAMPLER_VIEW, 0)) {
- ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
- ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE;
- if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_RENDER_TARGET, 0) ||
- screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_RENDER_TARGET, 0)) {
- ctx->Extensions.EXT_framebuffer_sRGB = GL_TRUE;
- ctx->Const.sRGBCapable = GL_TRUE;
- }
- }
-
- if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_SAMPLER_VIEW, 0)) {
- ctx->Extensions.ARB_texture_rg = GL_TRUE;
- }
-
- /* s3tc support */
- if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_SAMPLER_VIEW, 0) &&
- ctx->Mesa_DXTn) {
- ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
- ctx->Extensions.S3_s3tc = GL_TRUE;
- }
-
- /* ycbcr support */
- if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_SAMPLER_VIEW, 0) ||
- screen->is_format_supported(screen, PIPE_FORMAT_YUYV,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_SAMPLER_VIEW, 0)) {
- ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
- }
-
- /* GL_EXT_texture_array */
- if (screen->get_param(screen, PIPE_CAP_ARRAY_TEXTURES)) {
- ctx->Extensions.EXT_texture_array = GL_TRUE;
- ctx->Extensions.MESA_texture_array = GL_TRUE;
- }
-
- /* GL_ARB_framebuffer_object */
- if (ctx->Extensions.EXT_packed_depth_stencil) {
- /* we support always support GL_EXT_framebuffer_blit */
- ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
- }
-
- if (st->pipe->render_condition) {
- ctx->Extensions.NV_conditional_render = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_ENABLE)) {
- ctx->Extensions.EXT_draw_buffers2 = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC)) {
- ctx->Extensions.ARB_draw_buffers_blend = GL_TRUE;
- }
-
- /* GL_ARB_half_float_vertex */
- if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT,
- PIPE_BUFFER, 0,
- PIPE_BIND_VERTEX_BUFFER, 0)) {
- ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
- }
-
- if (screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY, PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
-#if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */
- ctx->Extensions.ARB_geometry_shader4 = GL_TRUE;
-#endif
- }
-
- if (screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART)) {
- ctx->Extensions.NV_primitive_restart = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_DEPTH_CLAMP)) {
- ctx->Extensions.ARB_depth_clamp = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) {
- ctx->Extensions.ARB_shader_stencil_export = GL_TRUE;
- }
-
- if (screen->get_param(screen, PIPE_CAP_INSTANCED_DRAWING)) {
- ctx->Extensions.ARB_draw_instanced = GL_TRUE;
- ctx->Extensions.ARB_instanced_arrays = GL_TRUE;
- }
-}
+/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright (c) 2008 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, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "main/imports.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/mfeatures.h" + +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_screen.h" + +#include "st_context.h" +#include "st_extensions.h" + + +static int _min(int a, int b) +{ + return (a < b) ? a : b; +} + +static float _maxf(float a, float b) +{ + return (a > b) ? a : b; +} + +static int _clamp(int a, int min, int max) +{ + if (a < min) + return min; + else if (a > max) + return max; + else + return a; +} + + +/** + * Query driver to get implementation limits. + * Note that we have to limit/clamp against Mesa's internal limits too. + */ +void st_init_limits(struct st_context *st) +{ + struct pipe_screen *screen = st->pipe->screen; + struct gl_constants *c = &st->ctx->Const; + gl_shader_type sh; + + c->MaxTextureLevels + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), + MAX_TEXTURE_LEVELS); + + c->Max3DTextureLevels + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), + MAX_3D_TEXTURE_LEVELS); + + c->MaxCubeTextureLevels + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), + MAX_CUBE_TEXTURE_LEVELS); + + c->MaxTextureRectSize + = _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); + + c->MaxTextureImageUnits + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS), + MAX_TEXTURE_IMAGE_UNITS); + + c->MaxVertexTextureImageUnits + = _min(screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS), + MAX_VERTEX_TEXTURE_IMAGE_UNITS); + + c->MaxCombinedTextureImageUnits + = _min(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS), + MAX_COMBINED_TEXTURE_IMAGE_UNITS); + + c->MaxTextureCoordUnits + = _min(c->MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS); + + c->MaxTextureUnits = _min(c->MaxTextureImageUnits, c->MaxTextureCoordUnits); + + c->MaxDrawBuffers + = _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), + 1, MAX_DRAW_BUFFERS); + + c->MaxLineWidth + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH)); + c->MaxLineWidthAA + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA)); + + c->MaxPointSize + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH)); + c->MaxPointSizeAA + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA)); + /* called after _mesa_create_context/_mesa_init_point, fix default user + * settable max point size up + */ + st->ctx->Point.MaxSize = MAX2(c->MaxPointSize, c->MaxPointSizeAA); + /* these are not queryable. Note that GL basically mandates a 1.0 minimum + * for non-aa sizes, but we can go down to 0.0 for aa points. + */ + c->MinPointSize = 1.0f; + c->MinPointSizeAA = 0.0f; + + c->MaxTextureMaxAnisotropy + = _maxf(2.0f, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY)); + + c->MaxTextureLodBias + = screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_LOD_BIAS); + + c->MaxDrawBuffers + = CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), + 1, MAX_DRAW_BUFFERS); + + /* Quads always follow GL provoking rules. */ + c->QuadsFollowProvokingVertexConvention = GL_FALSE; + + for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) { + struct gl_shader_compiler_options *options = + &st->ctx->ShaderCompilerOptions[sh]; + struct gl_program_constants *pc; + + switch (sh) { + case PIPE_SHADER_FRAGMENT: + pc = &c->FragmentProgram; + break; + case PIPE_SHADER_VERTEX: + pc = &c->VertexProgram; + break; + case PIPE_SHADER_GEOMETRY: + pc = &c->GeometryProgram; + break; + default: + assert(0); + continue; + } + + pc->MaxNativeInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS); + pc->MaxNativeAluInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS); + pc->MaxNativeTexInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS); + pc->MaxNativeTexIndirections = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS); + pc->MaxNativeAttribs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS); + pc->MaxNativeTemps = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEMPS); + pc->MaxNativeAddressRegs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS); + pc->MaxNativeParameters = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONSTS); + pc->MaxUniformComponents = 4 * MIN2(pc->MaxNativeParameters, MAX_UNIFORMS); + + options->EmitNoNoise = TRUE; + + /* TODO: make these more fine-grained if anyone needs it */ + options->EmitNoIfs = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH); + options->EmitNoLoops = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH); + options->EmitNoFunctions = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES); + options->EmitNoMainReturn = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES); + + options->EmitNoCont = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED); + + options->EmitNoIndirectInput = !screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR); + options->EmitNoIndirectOutput = !screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR); + options->EmitNoIndirectTemp = !screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR); + options->EmitNoIndirectUniform = !screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_INDIRECT_CONST_ADDR); + + if(options->EmitNoLoops) + options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536); + } + + /* PIPE_CAP_MAX_FS_INPUTS specifies the number of COLORn + GENERICn inputs + * and is set in MaxNativeAttribs. It's always 2 colors + N generic + * attributes. The GLSL compiler never uses COLORn for varyings, so we + * subtract the 2 colors to get the maximum number of varyings (generic + * attributes) supported by a driver. */ + c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INPUTS) - 2; + c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING); + + /* XXX we'll need a better query here someday */ + if (screen->get_param(screen, PIPE_CAP_GLSL)) { + c->GLSLVersion = 120; + } +} + + +/** + * Use pipe_screen::get_param() to query PIPE_CAP_ values to determine + * which GL extensions are supported. + * Quite a few extensions are always supported because they are standard + * features or can be built on top of other gallium features. + * Some fine tuning may still be needed. + */ +void st_init_extensions(struct st_context *st) +{ + struct pipe_screen *screen = st->pipe->screen; + struct gl_context *ctx = st->ctx; + + /* + * Extensions that are supported by all Gallium drivers: + */ + ctx->Extensions.ARB_copy_buffer = GL_TRUE; + ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE; + ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; + ctx->Extensions.ARB_fragment_program = GL_TRUE; + ctx->Extensions.ARB_half_float_pixel = GL_TRUE; + ctx->Extensions.ARB_map_buffer_range = GL_TRUE; + ctx->Extensions.ARB_multisample = GL_TRUE; + ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */ + ctx->Extensions.ARB_texture_compression = GL_TRUE; + ctx->Extensions.ARB_texture_cube_map = GL_TRUE; + ctx->Extensions.ARB_texture_env_combine = GL_TRUE; + ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; + ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; + ctx->Extensions.ARB_vertex_array_object = GL_TRUE; + ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE; + ctx->Extensions.ARB_vertex_program = GL_TRUE; + ctx->Extensions.ARB_window_pos = GL_TRUE; + + ctx->Extensions.EXT_blend_color = GL_TRUE; + ctx->Extensions.EXT_blend_func_separate = GL_TRUE; + ctx->Extensions.EXT_blend_logic_op = GL_TRUE; + ctx->Extensions.EXT_blend_minmax = GL_TRUE; + ctx->Extensions.EXT_blend_subtract = GL_TRUE; + ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; + ctx->Extensions.EXT_framebuffer_object = GL_TRUE; + ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; + ctx->Extensions.EXT_fog_coord = GL_TRUE; + ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; + ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE; + ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; + ctx->Extensions.EXT_point_parameters = GL_TRUE; + ctx->Extensions.EXT_provoking_vertex = GL_TRUE; + ctx->Extensions.EXT_secondary_color = GL_TRUE; + ctx->Extensions.EXT_stencil_wrap = GL_TRUE; + ctx->Extensions.EXT_texture_env_add = GL_TRUE; + ctx->Extensions.EXT_texture_env_combine = GL_TRUE; + ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; + ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; + ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; + if (ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2) + ctx->Extensions.EXT_texture_format_BGRA8888 = GL_TRUE; + + ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; + + ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; + + ctx->Extensions.MESA_pack_invert = GL_TRUE; + + ctx->Extensions.NV_blend_square = GL_TRUE; + ctx->Extensions.NV_texgen_reflection = GL_TRUE; + ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; + ctx->Extensions.NV_texture_rectangle = GL_TRUE; +#if 0 + /* possibly could support the following two */ + ctx->Extensions.NV_vertex_program = GL_TRUE; + ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; +#endif + +#if FEATURE_OES_EGL_image + ctx->Extensions.OES_EGL_image = GL_TRUE; +#endif +#if FEATURE_OES_draw_texture + ctx->Extensions.OES_draw_texture = GL_TRUE; +#endif + + ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; + + /* + * Extensions that depend on the driver/hardware: + */ + if (screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS) > 0) { + ctx->Extensions.ARB_draw_buffers = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_TEXTURE_SWIZZLE) > 0) { + ctx->Extensions.EXT_texture_swizzle = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_GLSL)) { + ctx->Extensions.ARB_fragment_shader = GL_TRUE; + ctx->Extensions.ARB_vertex_shader = GL_TRUE; + ctx->Extensions.ARB_shader_objects = GL_TRUE; + ctx->Extensions.ARB_shading_language_100 = GL_TRUE; + ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE; + ctx->Extensions.EXT_separate_shader_objects = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_REPEAT) > 0) { + ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_BLEND_EQUATION_SEPARATE)) { + ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_CLAMP) > 0) { + ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE; + ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES)) { + ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS) > 1) { + ctx->Extensions.ARB_multitexture = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_TWO_SIDED_STENCIL)) { + ctx->Extensions.ATI_separate_stencil = GL_TRUE; + ctx->Extensions.EXT_stencil_two_side = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_ANISOTROPIC_FILTER)) { + ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_POINT_SPRITE)) { + ctx->Extensions.ARB_point_sprite = GL_TRUE; + /* GL_NV_point_sprite is not supported by gallium because we don't + * support the GL_POINT_SPRITE_R_MODE_NV option. + */ + } + + if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) { + ctx->Extensions.ARB_occlusion_query = GL_TRUE; + ctx->Extensions.ARB_occlusion_query2 = GL_TRUE; + } + if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY)) { + ctx->Extensions.EXT_timer_query = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) { + ctx->Extensions.ARB_depth_texture = GL_TRUE; + ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; + ctx->Extensions.ARB_shadow = GL_TRUE; + ctx->Extensions.EXT_shadow_funcs = GL_TRUE; + /*ctx->Extensions.ARB_shadow_ambient = GL_TRUE;*/ + } + + /* GL_EXT_packed_depth_stencil requires both the ability to render to + * a depth/stencil buffer and texture from depth/stencil source. + */ + if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_DEPTH_STENCIL, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; + } + else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_DEPTH_STENCIL, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; + } + + /* sRGB support */ + if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) || + screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.EXT_texture_sRGB = GL_TRUE; + ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE; + if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_RENDER_TARGET, 0) || + screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_RENDER_TARGET, 0)) { + ctx->Extensions.EXT_framebuffer_sRGB = GL_TRUE; + ctx->Const.sRGBCapable = GL_TRUE; + } + } + + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.ARB_texture_rg = GL_TRUE; + } + + /* s3tc support */ + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) && + ctx->Mesa_DXTn) { + ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; + ctx->Extensions.S3_s3tc = GL_TRUE; + } + + if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_SNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_SNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) + ) { + ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE; + } + + /* ycbcr support */ + if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) || + screen->is_format_supported(screen, PIPE_FORMAT_YUYV, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; + } + + /* GL_EXT_texture_array */ + if (screen->get_param(screen, PIPE_CAP_ARRAY_TEXTURES)) { + ctx->Extensions.EXT_texture_array = GL_TRUE; + ctx->Extensions.MESA_texture_array = GL_TRUE; + } + + /* GL_ARB_framebuffer_object */ + if (ctx->Extensions.EXT_packed_depth_stencil) { + /* we support always support GL_EXT_framebuffer_blit */ + ctx->Extensions.ARB_framebuffer_object = GL_TRUE; + } + + if (st->pipe->render_condition) { + ctx->Extensions.NV_conditional_render = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_ENABLE)) { + ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC)) { + ctx->Extensions.ARB_draw_buffers_blend = GL_TRUE; + } + + /* GL_ARB_half_float_vertex */ + if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT, + PIPE_BUFFER, 0, + PIPE_BIND_VERTEX_BUFFER, 0)) { + ctx->Extensions.ARB_half_float_vertex = GL_TRUE; + } + + if (screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY, PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) { +#if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */ + ctx->Extensions.ARB_geometry_shader4 = GL_TRUE; +#endif + } + + if (screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART)) { + ctx->Extensions.NV_primitive_restart = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_DEPTH_CLAMP)) { + ctx->Extensions.ARB_depth_clamp = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) { + ctx->Extensions.ARB_shader_stencil_export = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_INSTANCED_DRAWING)) { + ctx->Extensions.ARB_draw_instanced = GL_TRUE; + ctx->Extensions.ARB_instanced_arrays = GL_TRUE; + } +} diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index 577ee6189..c58ec9267 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -241,6 +241,14 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) case MESA_FORMAT_RGBA_UINT32: return PIPE_FORMAT_R32G32B32A32_USCALED; + case MESA_FORMAT_RED_RGTC1: + return PIPE_FORMAT_RGTC1_UNORM; + case MESA_FORMAT_SIGNED_RED_RGTC1: + return PIPE_FORMAT_RGTC1_SNORM; + case MESA_FORMAT_RG_RGTC2: + return PIPE_FORMAT_RGTC2_UNORM; + case MESA_FORMAT_SIGNED_RG_RGTC2: + return PIPE_FORMAT_RGTC2_SNORM; default: assert(0); return PIPE_FORMAT_NONE; @@ -380,6 +388,15 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_R32G32B32A32_USCALED: return MESA_FORMAT_RGBA_UINT32; + case PIPE_FORMAT_RGTC1_UNORM: + return MESA_FORMAT_RED_RGTC1; + case PIPE_FORMAT_RGTC1_SNORM: + return MESA_FORMAT_SIGNED_RED_RGTC1; + case PIPE_FORMAT_RGTC2_UNORM: + return MESA_FORMAT_RG_RGTC2; + case PIPE_FORMAT_RGTC2_SNORM: + return MESA_FORMAT_SIGNED_RG_RGTC2; + default: assert(0); return MESA_FORMAT_NONE; diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c index 5c68fd78c..c07739f9d 100644 --- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -224,9 +224,9 @@ src_register( struct st_translate *t, case PROGRAM_TEMPORARY: assert(index >= 0); + assert(index < Elements(t->temps)); if (ureg_dst_is_undef(t->temps[index])) t->temps[index] = ureg_DECL_temporary( t->ureg ); - assert(index < Elements(t->temps)); return ureg_src(t->temps[index]); case PROGRAM_NAMED_PARAM: diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac index f3b293940..85d5c980e 100644 --- a/xorg-server/configure.ac +++ b/xorg-server/configure.ac @@ -26,8 +26,8 @@ dnl dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) -AC_INIT([xorg-server], 1.9.99.903, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) -RELEASE_DATE="2011-2-24" +AC_INIT([xorg-server], 1.10.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +RELEASE_DATE="2011-2-25" AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE @@ -2173,6 +2173,8 @@ AC_SUBST([libdir]) AC_SUBST([exec_prefix]) AC_SUBST([prefix]) +AC_CONFIG_COMMANDS([sdksyms], [touch hw/xfree86/loader/sdksyms.dep]) + AC_OUTPUT([ Makefile glx/Makefile @@ -2246,6 +2248,7 @@ hw/xfree86/utils/gtf/Makefile hw/dmx/config/Makefile hw/dmx/config/man/Makefile hw/dmx/doc/Makefile +hw/dmx/doc/doxygen.conf hw/dmx/examples/Makefile hw/dmx/input/Makefile hw/dmx/glxProxy/Makefile diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c index 08eb6c1cd..89294aacb 100644 --- a/xorg-server/dix/devices.c +++ b/xorg-server/dix/devices.c @@ -1,2602 +1,2604 @@ -/************************************************************
-
-Copyright 1987, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-********************************************************/
-
-
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include "misc.h"
-#include "resource.h"
-#include <X11/Xproto.h>
-#include <X11/Xatom.h>
-#include "windowstr.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include "cursorstr.h"
-#include "dixstruct.h"
-#include "ptrveloc.h"
-#include "site.h"
-#include "xkbsrv.h"
-#include "privates.h"
-#include "xace.h"
-#include "mi.h"
-
-#include "dispatch.h"
-#include "swaprep.h"
-#include "dixevents.h"
-#include "mipointer.h"
-#include "eventstr.h"
-
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XI2.h>
-#include <X11/extensions/XIproto.h>
-#include <math.h>
-#include <pixman.h>
-#include "exglobals.h"
-#include "exevents.h"
-#include "xiquerydevice.h" /* for SizeDeviceClasses */
-#include "xiproperty.h"
-#include "enterleave.h" /* for EnterWindow() */
-#include "xserver-properties.h"
-#include "xichangehierarchy.h" /* For XISendDeviceHierarchyEvent */
-
-/** @file
- * This file handles input device-related stuff.
- */
-
-static void RecalculateMasterButtons(DeviceIntPtr slave);
-
-static void
-DeviceSetTransform(DeviceIntPtr dev, float *transform)
-{
- struct pixman_f_transform scale;
- double sx, sy;
- int x, y;
-
- /**
- * calculate combined transformation matrix:
- *
- * M = InvScale * Transform * Scale
- *
- * So we can later transform points using M * p
- *
- * Where:
- * Scale scales coordinates into 0..1 range
- * Transform is the user supplied (affine) transform
- * InvScale scales coordinates back up into their native range
- */
- sx = dev->valuator->axes[0].max_value - dev->valuator->axes[0].min_value;
- sy = dev->valuator->axes[1].max_value - dev->valuator->axes[1].min_value;
-
- /* invscale */
- pixman_f_transform_init_scale(&scale, sx, sy);
- scale.m[0][2] = dev->valuator->axes[0].min_value;
- scale.m[1][2] = dev->valuator->axes[1].min_value;
-
- /* transform */
- for (y=0; y<3; y++)
- for (x=0; x<3; x++)
- dev->transform.m[y][x] = *transform++;
-
- pixman_f_transform_multiply(&dev->transform, &scale, &dev->transform);
-
- /* scale */
- pixman_f_transform_init_scale(&scale, 1.0 / sx, 1.0 / sy);
- scale.m[0][2] = -dev->valuator->axes[0].min_value / sx;
- scale.m[1][2] = -dev->valuator->axes[1].min_value / sy;
-
- pixman_f_transform_multiply(&dev->transform, &dev->transform, &scale);
-}
-
-/**
- * DIX property handler.
- */
-static int
-DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
- BOOL checkonly)
-{
- if (property == XIGetKnownProperty(XI_PROP_ENABLED))
- {
- if (prop->format != 8 || prop->type != XA_INTEGER || prop->size != 1)
- return BadValue;
-
- /* Don't allow disabling of VCP/VCK */
- if ((dev == inputInfo.pointer || dev == inputInfo.keyboard) &&
- !(*(CARD8*)prop->data))
- return BadAccess;
-
- if (!checkonly)
- {
- if ((*((CARD8*)prop->data)) && !dev->enabled)
- EnableDevice(dev, TRUE);
- else if (!(*((CARD8*)prop->data)) && dev->enabled)
- DisableDevice(dev, TRUE);
- }
- } else if (property == XIGetKnownProperty(XI_PROP_TRANSFORM))
- {
- float *f = (float*)prop->data;
- int i;
-
- if (prop->format != 32 || prop->size != 9 ||
- prop->type != XIGetKnownProperty(XATOM_FLOAT))
- return BadValue;
-
- for (i=0; i<9; i++)
- if (!isfinite(f[i]))
- return BadValue;
-
- if (!checkonly)
- DeviceSetTransform(dev, f);
- }
-
- return Success;
-}
-
-/* Pair the keyboard to the pointer device. Keyboard events will follow the
- * pointer sprite. Only applicable for master devices.
- * If the client is set, the request to pair comes from some client. In this
- * case, we need to check for access. If the client is NULL, it's from an
- * internal automatic pairing, we must always permit this.
- */
-static int
-PairDevices(ClientPtr client, DeviceIntPtr ptr, DeviceIntPtr kbd)
-{
- if (!ptr)
- return BadDevice;
-
- /* Don't allow pairing for slave devices */
- if (!IsMaster(ptr) || !IsMaster(kbd))
- return BadDevice;
-
- if (ptr->spriteInfo->paired)
- return BadDevice;
-
- if (kbd->spriteInfo->spriteOwner)
- {
- free(kbd->spriteInfo->sprite);
- kbd->spriteInfo->sprite = NULL;
- kbd->spriteInfo->spriteOwner = FALSE;
- }
-
- kbd->spriteInfo->sprite = ptr->spriteInfo->sprite;
- kbd->spriteInfo->paired = ptr;
- ptr->spriteInfo->paired = kbd;
- return Success;
-}
-
-
-/**
- * Find and return the next unpaired MD pointer device.
- */
-static DeviceIntPtr
-NextFreePointerDevice(void)
-{
- DeviceIntPtr dev;
- for (dev = inputInfo.devices; dev; dev = dev->next)
- if (IsMaster(dev) &&
- dev->spriteInfo->spriteOwner &&
- !dev->spriteInfo->paired)
- return dev;
- return NULL;
-}
-
-/**
- * Create a new input device and init it to sane values. The device is added
- * to the server's off_devices list.
- *
- * @param deviceProc Callback for device control function (switch dev on/off).
- * @return The newly created device.
- */
-DeviceIntPtr
-AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
-{
- DeviceIntPtr dev, *prev; /* not a typo */
- DeviceIntPtr devtmp;
- int devid;
- char devind[MAXDEVICES];
- BOOL enabled;
- float transform[9];
-
- /* Find next available id, 0 and 1 are reserved */
- memset(devind, 0, sizeof(char)*MAXDEVICES);
- for (devtmp = inputInfo.devices; devtmp; devtmp = devtmp->next)
- devind[devtmp->id]++;
- for (devtmp = inputInfo.off_devices; devtmp; devtmp = devtmp->next)
- devind[devtmp->id]++;
- for (devid = 2; devid < MAXDEVICES && devind[devid]; devid++)
- ;
-
- if (devid >= MAXDEVICES)
- return (DeviceIntPtr)NULL;
- dev = _dixAllocateObjectWithPrivates(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec),
- sizeof(DeviceIntRec) + sizeof(SpriteInfoRec),
- offsetof(DeviceIntRec, devPrivates), PRIVATE_DEVICE);
- if (!dev)
- return (DeviceIntPtr)NULL;
- dev->id = devid;
- dev->public.processInputProc = ProcessOtherEvent;
- dev->public.realInputProc = ProcessOtherEvent;
- dev->public.enqueueInputProc = EnqueueEvent;
- dev->deviceProc = deviceProc;
- dev->startup = autoStart;
-
- /* device grab defaults */
- dev->deviceGrab.grabTime = currentTime;
- dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
- dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
-
- XkbSetExtension(dev, ProcessKeyboardEvent);
-
- dev->coreEvents = TRUE;
-
- /* sprite defaults */
- dev->spriteInfo = (SpriteInfoPtr)&dev[1];
-
- /* security creation/labeling check
- */
- if (XaceHook(XACE_DEVICE_ACCESS, client, dev, DixCreateAccess)) {
- free(dev);
- return NULL;
- }
-
- inputInfo.numDevices++;
-
- for (prev = &inputInfo.off_devices; *prev; prev = &(*prev)->next)
- ;
- *prev = dev;
- dev->next = NULL;
-
- enabled = FALSE;
- XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
- XA_INTEGER, 8, PropModeReplace, 1, &enabled,
- FALSE);
- XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_ENABLED), FALSE);
-
- /* unity matrix */
- memset(transform, 0, sizeof(transform));
- transform[0] = transform[4] = transform[8] = 1.0f;
-
- XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_TRANSFORM),
- XIGetKnownProperty(XATOM_FLOAT), 32,
- PropModeReplace, 9, transform, FALSE);
- XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_TRANSFORM),
- FALSE);
-
- XIRegisterPropertyHandler(dev, DeviceSetProperty, NULL, NULL);
-
- return dev;
-}
-
-void
-SendDevicePresenceEvent(int deviceid, int type)
-{
- DeviceIntRec dummyDev;
- devicePresenceNotify ev;
-
- memset(&dummyDev, 0, sizeof(DeviceIntRec));
- ev.type = DevicePresenceNotify;
- ev.time = currentTime.milliseconds;
- ev.devchange = type;
- ev.deviceid = deviceid;
- dummyDev.id = XIAllDevices;
- SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
- (xEvent*)&ev, 1);
-}
-
-/**
- * Enable the device through the driver, add the device to the device list.
- * Switch device ON through the driver and push it onto the global device
- * list. Initialize the DIX sprite or pair the device. All clients are
- * notified about the device being enabled.
- *
- * A master pointer device needs to be enabled before a master keyboard
- * device.
- *
- * @param The device to be enabled.
- * @param sendevent True if an XI2 event should be sent.
- * @return TRUE on success or FALSE otherwise.
- */
-Bool
-EnableDevice(DeviceIntPtr dev, BOOL sendevent)
-{
- DeviceIntPtr *prev;
- int ret;
- DeviceIntPtr other;
- BOOL enabled;
- int flags[MAXDEVICES] = {0};
-
- for (prev = &inputInfo.off_devices;
- *prev && (*prev != dev);
- prev = &(*prev)->next)
- ;
-
- if (!dev->spriteInfo->sprite)
- {
- if (IsMaster(dev))
- {
- /* Sprites appear on first root window, so we can hardcode it */
- if (dev->spriteInfo->spriteOwner)
- {
- InitializeSprite(dev, screenInfo.screens[0]->root);
- /* mode doesn't matter */
- EnterWindow(dev, screenInfo.screens[0]->root, NotifyAncestor);
- }
- else if ((other = NextFreePointerDevice()) == NULL)
- {
- ErrorF("[dix] cannot find pointer to pair with. "
- "This is a bug.\n");
- return FALSE;
- } else
- PairDevices(NULL, other, dev);
- } else
- {
- if (dev->coreEvents)
- other = (IsPointerDevice(dev)) ? inputInfo.pointer :
- inputInfo.keyboard;
- else
- other = NULL; /* auto-float non-core devices */
- AttachDevice(NULL, dev, other);
- }
- }
-
- if ((*prev != dev) || !dev->inited ||
- ((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) {
- ErrorF("[dix] couldn't enable device %d\n", dev->id);
- return FALSE;
- }
- dev->enabled = TRUE;
- *prev = dev->next;
-
- for (prev = &inputInfo.devices; *prev; prev = &(*prev)->next)
- ;
- *prev = dev;
- dev->next = NULL;
-
- enabled = TRUE;
- XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
- XA_INTEGER, 8, PropModeReplace, 1, &enabled,
- TRUE);
-
- SendDevicePresenceEvent(dev->id, DeviceEnabled);
- if (sendevent)
- {
- flags[dev->id] |= XIDeviceEnabled;
- XISendDeviceHierarchyEvent(flags);
- }
-
- RecalculateMasterButtons(dev);
-
- return TRUE;
-}
-
-/**
- * Switch a device off through the driver and push it onto the off_devices
- * list. A device will not send events while disabled. All clients are
- * notified about the device being disabled.
- *
- * Master keyboard devices have to be disabled before master pointer devices
- * otherwise things turn bad.
- *
- * @param sendevent True if an XI2 event should be sent.
- * @return TRUE on success or FALSE otherwise.
- */
-Bool
-DisableDevice(DeviceIntPtr dev, BOOL sendevent)
-{
- DeviceIntPtr *prev, other;
- BOOL enabled;
- int flags[MAXDEVICES] = {0};
-
- for (prev = &inputInfo.devices;
- *prev && (*prev != dev);
- prev = &(*prev)->next)
- ;
- if (*prev != dev)
- return FALSE;
-
- /* float attached devices */
- if (IsMaster(dev))
- {
- for (other = inputInfo.devices; other; other = other->next)
- {
- if (other->u.master == dev)
- {
- AttachDevice(NULL, other, NULL);
- flags[other->id] |= XISlaveDetached;
- }
- }
- }
- else
- {
- for (other = inputInfo.devices; other; other = other->next)
- {
- if (IsMaster(other) && other->u.lastSlave == dev)
- other->u.lastSlave = NULL;
- }
- }
-
- if (IsMaster(dev) && dev->spriteInfo->sprite)
- {
- for (other = inputInfo.devices; other; other = other->next)
- {
- if (other->spriteInfo->paired == dev)
- {
- ErrorF("[dix] cannot disable device, still paired. "
- "This is a bug. \n");
- return FALSE;
- }
- }
- }
-
- (void)(*dev->deviceProc)(dev, DEVICE_OFF);
- dev->enabled = FALSE;
-
- /* now that the device is disabled, we can reset the signal handler's
- * last.slave */
- OsBlockSignals();
- for (other = inputInfo.devices; other; other = other->next)
- {
- if (other->last.slave == dev)
- other->last.slave = NULL;
- }
- OsReleaseSignals();
-
- LeaveWindow(dev);
- SetFocusOut(dev);
-
- *prev = dev->next;
- dev->next = inputInfo.off_devices;
- inputInfo.off_devices = dev;
-
- enabled = FALSE;
- XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
- XA_INTEGER, 8, PropModeReplace, 1, &enabled,
- TRUE);
-
- SendDevicePresenceEvent(dev->id, DeviceDisabled);
- if (sendevent)
- {
- flags[dev->id] = XIDeviceDisabled;
- XISendDeviceHierarchyEvent(flags);
- }
-
- RecalculateMasterButtons(dev);
-
- return TRUE;
-}
-
-/**
- * Initialise a new device through the driver and tell all clients about the
- * new device.
- *
- * Must be called before EnableDevice.
- * The device will NOT send events until it is enabled!
- *
- * @param sendevent True if an XI2 event should be sent.
- * @return Success or an error code on failure.
- */
-int
-ActivateDevice(DeviceIntPtr dev, BOOL sendevent)
-{
- int ret = Success;
- ScreenPtr pScreen = screenInfo.screens[0];
-
- if (!dev || !dev->deviceProc)
- return BadImplementation;
-
- ret = (*dev->deviceProc) (dev, DEVICE_INIT);
- dev->inited = (ret == Success);
- if (!dev->inited)
- return ret;
-
- /* Initialize memory for sprites. */
- if (IsMaster(dev) && dev->spriteInfo->spriteOwner)
- if (!pScreen->DeviceCursorInitialize(dev, pScreen))
- ret = BadAlloc;
-
- SendDevicePresenceEvent(dev->id, DeviceAdded);
- if (sendevent)
- {
- int flags[MAXDEVICES] = {0};
- flags[dev->id] = XISlaveAdded;
- XISendDeviceHierarchyEvent(flags);
- }
- return ret;
-}
-
-/**
- * Ring the bell.
- * The actual task of ringing the bell is the job of the DDX.
- */
-static void
-CoreKeyboardBell(int volume, DeviceIntPtr pDev, pointer arg, int something)
-{
- KeybdCtrl *ctrl = arg;
-
- DDXRingBell(volume, ctrl->bell_pitch, ctrl->bell_duration);
-}
-
-static void
-CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
-{
- return;
-}
-
-/**
- * Device control function for the Virtual Core Keyboard.
- */
-int
-CoreKeyboardProc(DeviceIntPtr pDev, int what)
-{
-
- switch (what) {
- case DEVICE_INIT:
- if (!InitKeyboardDeviceStruct(pDev, NULL, CoreKeyboardBell,
- CoreKeyboardCtl))
- {
- ErrorF("Keyboard initialization failed. This could be a missing "
- "or incorrect setup of xkeyboard-config.\n");
- return BadValue;
- }
- return Success;
-
- case DEVICE_ON:
- case DEVICE_OFF:
- return Success;
-
- case DEVICE_CLOSE:
- return Success;
- }
-
- return BadMatch;
-}
-
-/**
- * Device control function for the Virtual Core Pointer.
- */
-int
-CorePointerProc(DeviceIntPtr pDev, int what)
-{
-#define NBUTTONS 10
-#define NAXES 2
- BYTE map[NBUTTONS + 1];
- int i = 0;
- Atom btn_labels[NBUTTONS] = {0};
- Atom axes_labels[NAXES] = {0};
-
- switch (what) {
- case DEVICE_INIT:
- for (i = 1; i <= NBUTTONS; i++)
- map[i] = i;
-
- btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
- btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
- btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
- btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
- btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
- btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
- btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
- /* don't know about the rest */
-
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
-
- if (!InitPointerDeviceStruct((DevicePtr)pDev, map, NBUTTONS, btn_labels,
- (PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), NAXES, axes_labels))
- {
- ErrorF("Could not initialize device '%s'. Out of memory.\n",
- pDev->name);
- return BadAlloc; /* IPDS only fails on allocs */
- }
- pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
- pDev->last.valuators[0] = pDev->valuator->axisVal[0];
- pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
- pDev->last.valuators[1] = pDev->valuator->axisVal[1];
- break;
-
- case DEVICE_CLOSE:
- break;
-
- default:
- break;
- }
-
- return Success;
-
-#undef NBUTTONS
-#undef NAXES
-}
-
-/**
- * Initialise the two core devices, VCP and VCK (see events.c).
- * Both devices are not tied to physical devices, but guarantee that there is
- * always a keyboard and a pointer present and keep the protocol semantics.
- *
- * Note that the server MUST have two core devices at all times, even if there
- * is no physical device connected.
- */
-void
-InitCoreDevices(void)
-{
- if (AllocDevicePair(serverClient, "Virtual core",
- &inputInfo.pointer, &inputInfo.keyboard,
- CorePointerProc, CoreKeyboardProc,
- TRUE) != Success)
- FatalError("Failed to allocate core devices");
-
- if (ActivateDevice(inputInfo.pointer, TRUE) != Success ||
- ActivateDevice(inputInfo.keyboard, TRUE) != Success)
- FatalError("Failed to activate core devices.");
- if (!EnableDevice(inputInfo.pointer, TRUE) ||
- !EnableDevice(inputInfo.keyboard, TRUE))
- FatalError("Failed to enable core devices.");
-
- InitXTestDevices();
-}
-
-/**
- * Activate all switched-off devices and then enable all those devices.
- *
- * Will return an error if no core keyboard or core pointer is present.
- * In theory this should never happen if you call InitCoreDevices() first.
- *
- * InitAndStartDevices needs to be called AFTER the windows are initialized.
- * Devices will start sending events after InitAndStartDevices() has
- * completed.
- *
- * @return Success or error code on failure.
- */
-int
-InitAndStartDevices(void)
-{
- DeviceIntPtr dev, next;
-
- for (dev = inputInfo.off_devices; dev; dev = dev->next) {
- DebugF("(dix) initialising device %d\n", dev->id);
- if (!dev->inited)
- ActivateDevice(dev, TRUE);
- }
-
- /* enable real devices */
- for (dev = inputInfo.off_devices; dev; dev = next)
- {
- DebugF("(dix) enabling device %d\n", dev->id);
- next = dev->next;
- if (dev->inited && dev->startup)
- EnableDevice(dev, TRUE);
- }
-
- return Success;
-}
-
-/**
- * Free the given device class and reset the pointer to NULL.
- */
-static void
-FreeDeviceClass(int type, pointer *class)
-{
- if (!(*class))
- return;
-
- switch(type)
- {
- case KeyClass:
- {
- KeyClassPtr* k = (KeyClassPtr*)class;
- if ((*k)->xkbInfo)
- {
- XkbFreeInfo((*k)->xkbInfo);
- (*k)->xkbInfo = NULL;
- }
- free((*k));
- break;
- }
- case ButtonClass:
- {
- ButtonClassPtr *b = (ButtonClassPtr*)class;
- free((*b)->xkb_acts);
- free((*b));
- break;
- }
- case ValuatorClass:
- {
- ValuatorClassPtr *v = (ValuatorClassPtr*)class;
-
- free((*v)->motion);
- free((*v));
- break;
- }
- case FocusClass:
- {
- FocusClassPtr *f = (FocusClassPtr*)class;
- free((*f)->trace);
- free((*f));
- break;
- }
- case ProximityClass:
- {
- ProximityClassPtr *p = (ProximityClassPtr*)class;
- free((*p));
- break;
- }
- }
- *class = NULL;
-}
-
-static void
-FreeFeedbackClass(int type, pointer *class)
-{
- if (!(*class))
- return;
-
- switch(type)
- {
- case KbdFeedbackClass:
- {
- KbdFeedbackPtr *kbdfeed = (KbdFeedbackPtr*)class;
- KbdFeedbackPtr k, knext;
- for (k = (*kbdfeed); k; k = knext) {
- knext = k->next;
- if (k->xkb_sli)
- XkbFreeSrvLedInfo(k->xkb_sli);
- free(k);
- }
- break;
- }
- case PtrFeedbackClass:
- {
- PtrFeedbackPtr *ptrfeed = (PtrFeedbackPtr*)class;
- PtrFeedbackPtr p, pnext;
-
- for (p = (*ptrfeed); p; p = pnext) {
- pnext = p->next;
- free(p);
- }
- break;
- }
- case IntegerFeedbackClass:
- {
- IntegerFeedbackPtr *intfeed = (IntegerFeedbackPtr*)class;
- IntegerFeedbackPtr i, inext;
-
- for (i = (*intfeed); i; i = inext) {
- inext = i->next;
- free(i);
- }
- break;
- }
- case StringFeedbackClass:
- {
- StringFeedbackPtr *stringfeed = (StringFeedbackPtr*)class;
- StringFeedbackPtr s, snext;
-
- for (s = (*stringfeed); s; s = snext) {
- snext = s->next;
- free(s->ctrl.symbols_supported);
- free(s->ctrl.symbols_displayed);
- free(s);
- }
- break;
- }
- case BellFeedbackClass:
- {
- BellFeedbackPtr *bell = (BellFeedbackPtr*)class;
- BellFeedbackPtr b, bnext;
-
- for (b = (*bell); b; b = bnext) {
- bnext = b->next;
- free(b);
- }
- break;
- }
- case LedFeedbackClass:
- {
- LedFeedbackPtr *leds = (LedFeedbackPtr*)class;
- LedFeedbackPtr l, lnext;
-
- for (l = (*leds); l; l = lnext) {
- lnext = l->next;
- if (l->xkb_sli)
- XkbFreeSrvLedInfo(l->xkb_sli);
- free(l);
- }
- break;
- }
- }
- *class = NULL;
-}
-
-static void
-FreeAllDeviceClasses(ClassesPtr classes)
-{
- if (!classes)
- return;
-
- FreeDeviceClass(KeyClass, (pointer)&classes->key);
- FreeDeviceClass(ValuatorClass, (pointer)&classes->valuator);
- FreeDeviceClass(ButtonClass, (pointer)&classes->button);
- FreeDeviceClass(FocusClass, (pointer)&classes->focus);
- FreeDeviceClass(ProximityClass, (pointer)&classes->proximity);
-
- FreeFeedbackClass(KbdFeedbackClass, (pointer)&classes->kbdfeed);
- FreeFeedbackClass(PtrFeedbackClass, (pointer)&classes->ptrfeed);
- FreeFeedbackClass(IntegerFeedbackClass, (pointer)&classes->intfeed);
- FreeFeedbackClass(StringFeedbackClass, (pointer)&classes->stringfeed);
- FreeFeedbackClass(BellFeedbackClass, (pointer)&classes->bell);
- FreeFeedbackClass(LedFeedbackClass, (pointer)&classes->leds);
-
-}
-
-/**
- * Close down a device and free all resources.
- * Once closed down, the driver will probably not expect you that you'll ever
- * enable it again and free associated structs. If you want the device to just
- * be disabled, DisableDevice().
- * Don't call this function directly, use RemoveDevice() instead.
- */
-static void
-CloseDevice(DeviceIntPtr dev)
-{
- ScreenPtr screen = screenInfo.screens[0];
- ClassesPtr classes;
- int j;
-
- if (!dev)
- return;
-
- XIDeleteAllDeviceProperties(dev);
-
- if (dev->inited)
- (void)(*dev->deviceProc)(dev, DEVICE_CLOSE);
-
- /* free sprite memory */
- if (IsMaster(dev) && dev->spriteInfo->sprite)
- screen->DeviceCursorCleanup(dev, screen);
-
- /* free acceleration info */
- if(dev->valuator && dev->valuator->accelScheme.AccelCleanupProc)
- dev->valuator->accelScheme.AccelCleanupProc(dev);
-
- while (dev->xkb_interest)
- XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
-
- free(dev->name);
-
- classes = (ClassesPtr)&dev->key;
- FreeAllDeviceClasses(classes);
-
- if (IsMaster(dev))
- {
- classes = dev->unused_classes;
- FreeAllDeviceClasses(classes);
- free(classes);
- }
-
- if (DevHasCursor(dev) && dev->spriteInfo->sprite) {
- if (dev->spriteInfo->sprite->current)
- FreeCursor(dev->spriteInfo->sprite->current, None);
- free(dev->spriteInfo->sprite->spriteTrace);
- free(dev->spriteInfo->sprite);
- }
-
- /* a client may have the device set as client pointer */
- for (j = 0; j < currentMaxClients; j++)
- {
- if (clients[j] && clients[j]->clientPtr == dev)
- {
- clients[j]->clientPtr = NULL;
- clients[j]->clientPtr = PickPointer(clients[j]);
- }
- }
-
- free(dev->deviceGrab.sync.event);
- dixFreeObjectWithPrivates(dev, PRIVATE_DEVICE);
-}
-
-/**
- * Shut down all devices of one list and free all resources.
- */
-static
-void
-CloseDeviceList(DeviceIntPtr *listHead)
-{
- /* Used to mark devices that we tried to free */
- Bool freedIds[MAXDEVICES];
- DeviceIntPtr dev;
- int i;
-
- if (listHead == NULL)
- return;
-
- for (i = 0; i < MAXDEVICES; i++)
- freedIds[i] = FALSE;
-
- dev = *listHead;
- while (dev != NULL)
- {
- freedIds[dev->id] = TRUE;
- DeleteInputDeviceRequest(dev);
-
- dev = *listHead;
- while (dev != NULL && freedIds[dev->id])
- dev = dev->next;
- }
-}
-
-/**
- * Shut down all devices, free all resources, etc.
- * Only useful if you're shutting down the server!
- */
-void
-CloseDownDevices(void)
-{
- DeviceIntPtr dev;
-
- /* Float all SDs before closing them. Note that at this point resources
- * (e.g. cursors) have been freed already, so we can't just call
- * AttachDevice(NULL, dev, NULL). Instead, we have to forcibly set master
- * to NULL and pretend nothing happened.
- */
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (!IsMaster(dev) && dev->u.master)
- dev->u.master = NULL;
- }
-
- CloseDeviceList(&inputInfo.devices);
- CloseDeviceList(&inputInfo.off_devices);
-
- CloseDevice(inputInfo.pointer);
- CloseDevice(inputInfo.keyboard);
-
- inputInfo.devices = NULL;
- inputInfo.off_devices = NULL;
- inputInfo.keyboard = NULL;
- inputInfo.pointer = NULL;
- XkbDeleteRulesDflts();
-}
-
-/**
- * Remove the cursor sprite for all devices. This needs to be done before any
- * resources are freed or any device is deleted.
- */
-void
-UndisplayDevices(void)
-{
- DeviceIntPtr dev;
- ScreenPtr screen = screenInfo.screens[0];
-
- for (dev = inputInfo.devices; dev; dev = dev->next)
- screen->DisplayCursor(dev, screen, NullCursor);
-}
-
-/**
- * Remove a device from the device list, closes it and thus frees all
- * resources.
- * Removes both enabled and disabled devices and notifies all devices about
- * the removal of the device.
- *
- * No PresenceNotify is sent for device that the client never saw. This can
- * happen if a malloc fails during the addition of master devices. If
- * dev->init is FALSE it means the client never received a DeviceAdded event,
- * so let's not send a DeviceRemoved event either.
- *
- * @param sendevent True if an XI2 event should be sent.
- */
-int
-RemoveDevice(DeviceIntPtr dev, BOOL sendevent)
-{
- DeviceIntPtr prev,tmp,next;
- int ret = BadMatch;
- ScreenPtr screen = screenInfo.screens[0];
- int deviceid;
- int initialized;
- int flags[MAXDEVICES] = {0};
-
- DebugF("(dix) removing device %d\n", dev->id);
-
- if (!dev || dev == inputInfo.keyboard || dev == inputInfo.pointer)
- return BadImplementation;
-
- initialized = dev->inited;
- deviceid = dev->id;
-
- if (initialized)
- {
- if (DevHasCursor(dev))
- screen->DisplayCursor(dev, screen, NullCursor);
-
- DisableDevice(dev, sendevent);
- flags[dev->id] = XIDeviceDisabled;
- }
-
- prev = NULL;
- for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {
- next = tmp->next;
- if (tmp == dev) {
-
- if (prev==NULL)
- inputInfo.devices = next;
- else
- prev->next = next;
-
- flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved;
- CloseDevice(tmp);
- ret = Success;
- }
- }
-
- prev = NULL;
- for (tmp = inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) {
- next = tmp->next;
- if (tmp == dev) {
- flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved;
- CloseDevice(tmp);
-
- if (prev == NULL)
- inputInfo.off_devices = next;
- else
- prev->next = next;
-
- ret = Success;
- }
- }
-
- if (ret == Success && initialized) {
- inputInfo.numDevices--;
- SendDevicePresenceEvent(deviceid, DeviceRemoved);
- if (sendevent)
- XISendDeviceHierarchyEvent(flags);
- }
-
- return ret;
-}
-
-int
-NumMotionEvents(void)
-{
- /* only called to fill data in initial connection reply.
- * VCP is ok here, it is the only fixed device we have. */
- return inputInfo.pointer->valuator->numMotionEvents;
-}
-
-int
-dixLookupDevice(DeviceIntPtr *pDev, int id, ClientPtr client, Mask access_mode)
-{
- DeviceIntPtr dev;
- int rc;
- *pDev = NULL;
-
- for (dev=inputInfo.devices; dev; dev=dev->next) {
- if (dev->id == id)
- goto found;
- }
- for (dev=inputInfo.off_devices; dev; dev=dev->next) {
- if (dev->id == id)
- goto found;
- }
- return BadDevice;
-
-found:
- rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
- if (rc == Success)
- *pDev = dev;
- return rc;
-}
-
-void
-QueryMinMaxKeyCodes(KeyCode *minCode, KeyCode *maxCode)
-{
- if (inputInfo.keyboard) {
- *minCode = inputInfo.keyboard->key->xkbInfo->desc->min_key_code;
- *maxCode = inputInfo.keyboard->key->xkbInfo->desc->max_key_code;
- }
-}
-
-/* Notably, this function does not expand the destination's keycode range, or
- * notify clients. */
-Bool
-SetKeySymsMap(KeySymsPtr dst, KeySymsPtr src)
-{
- int i, j;
- KeySym *tmp;
- int rowDif = src->minKeyCode - dst->minKeyCode;
-
- /* if keysym map size changes, grow map first */
- if (src->mapWidth < dst->mapWidth) {
- for (i = src->minKeyCode; i <= src->maxKeyCode; i++) {
-#define SI(r, c) (((r - src->minKeyCode) * src->mapWidth) + (c))
-#define DI(r, c) (((r - dst->minKeyCode) * dst->mapWidth) + (c))
- for (j = 0; j < src->mapWidth; j++)
- dst->map[DI(i, j)] = src->map[SI(i, j)];
- for (j = src->mapWidth; j < dst->mapWidth; j++)
- dst->map[DI(i, j)] = NoSymbol;
-#undef SI
-#undef DI
- }
- return TRUE;
- }
- else if (src->mapWidth > dst->mapWidth) {
- i = sizeof(KeySym) * src->mapWidth *
- (dst->maxKeyCode - dst->minKeyCode + 1);
- tmp = calloc(sizeof(KeySym), i);
- if (!tmp)
- return FALSE;
-
- if (dst->map) {
- for (i = 0; i <= dst->maxKeyCode-dst->minKeyCode; i++)
- memmove(&tmp[i * src->mapWidth], &dst->map[i * dst->mapWidth],
- dst->mapWidth * sizeof(KeySym));
- free(dst->map);
- }
- dst->mapWidth = src->mapWidth;
- dst->map = tmp;
- }
- else if (!dst->map) {
- i = sizeof(KeySym) * src->mapWidth *
- (dst->maxKeyCode - dst->minKeyCode + 1);
- tmp = calloc(sizeof(KeySym), i);
- if (!tmp)
- return FALSE;
-
- dst->map = tmp;
- dst->mapWidth = src->mapWidth;
- }
-
- memmove(&dst->map[rowDif * dst->mapWidth], src->map,
- (src->maxKeyCode - src->minKeyCode + 1) *
- dst->mapWidth * sizeof(KeySym));
-
- return TRUE;
-}
-
-Bool
-InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom* labels,
- CARD8 *map)
-{
- ButtonClassPtr butc;
- int i;
-
- butc = calloc(1, sizeof(ButtonClassRec));
- if (!butc)
- return FALSE;
- butc->numButtons = numButtons;
- butc->sourceid = dev->id;
- for (i = 1; i <= numButtons; i++)
- butc->map[i] = map[i];
- for (i = numButtons + 1; i < MAP_LENGTH; i++)
- butc->map[i] = i;
- memcpy(butc->labels, labels, numButtons * sizeof(Atom));
- dev->button = butc;
- return TRUE;
-}
-
-Bool
-InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
- int numMotionEvents, int mode)
-{
- int i;
- ValuatorClassPtr valc;
-
- if (!dev)
- return FALSE;
-
- if (numAxes > MAX_VALUATORS)
- {
- LogMessage(X_WARNING,
- "Device '%s' has %d axes, only using first %d.\n",
- dev->name, numAxes, MAX_VALUATORS);
- numAxes = MAX_VALUATORS;
- }
-
- valc = (ValuatorClassPtr)calloc(1, sizeof(ValuatorClassRec) +
- numAxes * sizeof(AxisInfo) +
- numAxes * sizeof(double));
- if (!valc)
- return FALSE;
-
- valc->sourceid = dev->id;
- valc->motion = NULL;
- valc->first_motion = 0;
- valc->last_motion = 0;
-
- valc->numMotionEvents = numMotionEvents;
- valc->motionHintWindow = NullWindow;
- valc->numAxes = numAxes;
- valc->axes = (AxisInfoPtr)(valc + 1);
- valc->axisVal = (double *)(valc->axes + numAxes);
-
- if (mode & OutOfProximity)
- InitProximityClassDeviceStruct(dev);
-
- dev->valuator = valc;
-
- AllocateMotionHistory(dev);
-
- for (i=0; i<numAxes; i++) {
- InitValuatorAxisStruct(dev, i, labels[i], NO_AXIS_LIMITS, NO_AXIS_LIMITS,
- 0, 0, 0, mode);
- valc->axisVal[i]=0;
- }
-
- dev->last.numValuators = numAxes;
-
- if (IsMaster(dev) || /* do not accelerate master or xtest devices */
- IsXTestDevice(dev, NULL))
- InitPointerAccelerationScheme(dev, PtrAccelNoOp);
- else
- InitPointerAccelerationScheme(dev, PtrAccelDefault);
- return TRUE;
-}
-
-/* global list of acceleration schemes */
-ValuatorAccelerationRec pointerAccelerationScheme[] = {
- {PtrAccelNoOp, NULL, NULL, NULL},
- {PtrAccelPredictable, acceleratePointerPredictable, NULL, AccelerationDefaultCleanup},
- {PtrAccelLightweight, acceleratePointerLightweight, NULL, NULL},
- {-1, NULL, NULL, NULL} /* terminator */
-};
-
-/**
- * install an acceleration scheme. returns TRUE on success, and should not
- * change anything if unsuccessful.
- */
-Bool
-InitPointerAccelerationScheme(DeviceIntPtr dev,
- int scheme)
-{
- int x, i = -1;
- void* data = NULL;
- ValuatorClassPtr val;
-
- val = dev->valuator;
-
- if(!val)
- return FALSE;
-
- if(IsMaster(dev) && scheme != PtrAccelNoOp)
- return FALSE;
-
- for(x = 0; pointerAccelerationScheme[x].number >= 0; x++) {
- if(pointerAccelerationScheme[x].number == scheme){
- i = x;
- break;
- }
- }
-
- if(-1 == i)
- return FALSE;
-
- if (val->accelScheme.AccelCleanupProc)
- val->accelScheme.AccelCleanupProc(dev);
-
- /* init scheme-specific data */
- switch(scheme){
- case PtrAccelPredictable:
- {
- DeviceVelocityPtr s;
- s = malloc(sizeof(DeviceVelocityRec));
- if(!s)
- return FALSE;
- InitVelocityData(s);
- data = s;
- break;
- }
- default:
- break;
- }
-
- val->accelScheme = pointerAccelerationScheme[i];
- val->accelScheme.accelData = data;
-
- /* post-init scheme */
- switch(scheme){
- case PtrAccelPredictable:
- InitializePredictableAccelerationProperties(dev);
- break;
-
- default:
- break;
- }
-
- return TRUE;
-}
-
-Bool
-InitAbsoluteClassDeviceStruct(DeviceIntPtr dev)
-{
- AbsoluteClassPtr abs;
-
- abs = malloc(sizeof(AbsoluteClassRec));
- if (!abs)
- return FALSE;
-
- /* we don't do anything sensible with these, but should */
- abs->min_x = NO_AXIS_LIMITS;
- abs->min_y = NO_AXIS_LIMITS;
- abs->max_x = NO_AXIS_LIMITS;
- abs->max_y = NO_AXIS_LIMITS;
- abs->flip_x = 0;
- abs->flip_y = 0;
- abs->rotation = 0;
- abs->button_threshold = 0;
-
- abs->offset_x = 0;
- abs->offset_y = 0;
- abs->width = NO_AXIS_LIMITS;
- abs->height = NO_AXIS_LIMITS;
- abs->following = 0;
- abs->screen = 0;
-
- abs->sourceid = dev->id;
-
- dev->absolute = abs;
-
- return TRUE;
-}
-
-Bool
-InitFocusClassDeviceStruct(DeviceIntPtr dev)
-{
- FocusClassPtr focc;
-
- focc = malloc(sizeof(FocusClassRec));
- if (!focc)
- return FALSE;
- focc->win = PointerRootWin;
- focc->revert = None;
- focc->time = currentTime;
- focc->trace = (WindowPtr *)NULL;
- focc->traceSize = 0;
- focc->traceGood = 0;
- focc->sourceid = dev->id;
- dev->focus = focc;
- return TRUE;
-}
-
-Bool
-InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc)
-{
- PtrFeedbackPtr feedc;
-
- feedc = malloc(sizeof(PtrFeedbackClassRec));
- if (!feedc)
- return FALSE;
- feedc->CtrlProc = controlProc;
- feedc->ctrl = defaultPointerControl;
- feedc->ctrl.id = 0;
- if ( (feedc->next = dev->ptrfeed) )
- feedc->ctrl.id = dev->ptrfeed->ctrl.id + 1;
- dev->ptrfeed = feedc;
- (*controlProc)(dev, &feedc->ctrl);
- return TRUE;
-}
-
-
-static LedCtrl defaultLedControl = {
- DEFAULT_LEDS, DEFAULT_LEDS_MASK, 0};
-
-static BellCtrl defaultBellControl = {
- DEFAULT_BELL,
- DEFAULT_BELL_PITCH,
- DEFAULT_BELL_DURATION,
- 0};
-
-static IntegerCtrl defaultIntegerControl = {
- DEFAULT_INT_RESOLUTION,
- DEFAULT_INT_MIN_VALUE,
- DEFAULT_INT_MAX_VALUE,
- DEFAULT_INT_DISPLAYED,
- 0};
-
-Bool
-InitStringFeedbackClassDeviceStruct (
- DeviceIntPtr dev, StringCtrlProcPtr controlProc,
- int max_symbols, int num_symbols_supported, KeySym *symbols)
-{
- int i;
- StringFeedbackPtr feedc;
-
- feedc = malloc(sizeof(StringFeedbackClassRec));
- if (!feedc)
- return FALSE;
- feedc->CtrlProc = controlProc;
- feedc->ctrl.num_symbols_supported = num_symbols_supported;
- feedc->ctrl.num_symbols_displayed = 0;
- feedc->ctrl.max_symbols = max_symbols;
- feedc->ctrl.symbols_supported = malloc(sizeof (KeySym) * num_symbols_supported);
- feedc->ctrl.symbols_displayed = malloc(sizeof (KeySym) * max_symbols);
- if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed)
- {
- free(feedc->ctrl.symbols_supported);
- free(feedc->ctrl.symbols_displayed);
- free(feedc);
- return FALSE;
- }
- for (i=0; i<num_symbols_supported; i++)
- *(feedc->ctrl.symbols_supported+i) = *symbols++;
- for (i=0; i<max_symbols; i++)
- *(feedc->ctrl.symbols_displayed+i) = (KeySym) 0;
- feedc->ctrl.id = 0;
- if ( (feedc->next = dev->stringfeed) )
- feedc->ctrl.id = dev->stringfeed->ctrl.id + 1;
- dev->stringfeed = feedc;
- (*controlProc)(dev, &feedc->ctrl);
- return TRUE;
-}
-
-Bool
-InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc,
- BellCtrlProcPtr controlProc)
-{
- BellFeedbackPtr feedc;
-
- feedc = malloc(sizeof(BellFeedbackClassRec));
- if (!feedc)
- return FALSE;
- feedc->CtrlProc = controlProc;
- feedc->BellProc = bellProc;
- feedc->ctrl = defaultBellControl;
- feedc->ctrl.id = 0;
- if ( (feedc->next = dev->bell) )
- feedc->ctrl.id = dev->bell->ctrl.id + 1;
- dev->bell = feedc;
- (*controlProc)(dev, &feedc->ctrl);
- return TRUE;
-}
-
-Bool
-InitLedFeedbackClassDeviceStruct (DeviceIntPtr dev, LedCtrlProcPtr controlProc)
-{
- LedFeedbackPtr feedc;
-
- feedc = malloc(sizeof(LedFeedbackClassRec));
- if (!feedc)
- return FALSE;
- feedc->CtrlProc = controlProc;
- feedc->ctrl = defaultLedControl;
- feedc->ctrl.id = 0;
- if ( (feedc->next = dev->leds) )
- feedc->ctrl.id = dev->leds->ctrl.id + 1;
- feedc->xkb_sli= NULL;
- dev->leds = feedc;
- (*controlProc)(dev, &feedc->ctrl);
- return TRUE;
-}
-
-Bool
-InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr controlProc)
-{
- IntegerFeedbackPtr feedc;
-
- feedc = malloc(sizeof(IntegerFeedbackClassRec));
- if (!feedc)
- return FALSE;
- feedc->CtrlProc = controlProc;
- feedc->ctrl = defaultIntegerControl;
- feedc->ctrl.id = 0;
- if ( (feedc->next = dev->intfeed) )
- feedc->ctrl.id = dev->intfeed->ctrl.id + 1;
- dev->intfeed = feedc;
- (*controlProc)(dev, &feedc->ctrl);
- return TRUE;
-}
-
-Bool
-InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons, Atom* btn_labels,
- PtrCtrlProcPtr controlProc, int numMotionEvents,
- int numAxes, Atom *axes_labels)
-{
- DeviceIntPtr dev = (DeviceIntPtr)device;
-
- return(InitButtonClassDeviceStruct(dev, numButtons, btn_labels, map) &&
- InitValuatorClassDeviceStruct(dev, numAxes, axes_labels,
- numMotionEvents, Relative) &&
- InitPtrFeedbackClassDeviceStruct(dev, controlProc));
-}
-
-/*
- * Check if the given buffer contains elements between low (inclusive) and
- * high (inclusive) only.
- *
- * @return TRUE if the device map is invalid, FALSE otherwise.
- */
-Bool
-BadDeviceMap(BYTE *buff, int length, unsigned low, unsigned high, XID *errval)
-{
- int i;
-
- for (i = 0; i < length; i++)
- if (buff[i]) /* only check non-zero elements */
- {
- if ((low > buff[i]) || (high < buff[i]))
- {
- *errval = buff[i];
- return TRUE;
- }
- }
- return FALSE;
-}
-
-int
-ProcSetModifierMapping(ClientPtr client)
-{
- xSetModifierMappingReply rep;
- int rc;
- REQUEST(xSetModifierMappingReq);
- REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
-
- if (client->req_len != ((stuff->numKeyPerModifier << 1) +
- bytes_to_int32(sizeof(xSetModifierMappingReq))))
- return BadLength;
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- rc = change_modmap(client, PickKeyboard(client), (KeyCode *)&stuff[1],
- stuff->numKeyPerModifier);
- if (rc == MappingFailed || rc == -1)
- return BadValue;
- if (rc != Success && rc != MappingSuccess && rc != MappingFailed &&
- rc != MappingBusy)
- return rc;
-
- rep.success = rc;
-
- WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep);
- return Success;
-}
-
-int
-ProcGetModifierMapping(ClientPtr client)
-{
- xGetModifierMappingReply rep;
- int max_keys_per_mod = 0;
- KeyCode *modkeymap = NULL;
- REQUEST_SIZE_MATCH(xReq);
-
- generate_modkeymap(client, PickKeyboard(client), &modkeymap,
- &max_keys_per_mod);
-
- memset(&rep, 0, sizeof(xGetModifierMappingReply));
- rep.type = X_Reply;
- rep.numKeyPerModifier = max_keys_per_mod;
- rep.sequenceNumber = client->sequence;
- /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */
- rep.length = max_keys_per_mod << 1;
-
- WriteReplyToClient(client, sizeof(xGetModifierMappingReply), &rep);
- (void)WriteToClient(client, max_keys_per_mod * 8, (char *) modkeymap);
-
- free(modkeymap);
-
- return Success;
-}
-
-int
-ProcChangeKeyboardMapping(ClientPtr client)
-{
- REQUEST(xChangeKeyboardMappingReq);
- unsigned len;
- KeySymsRec keysyms;
- DeviceIntPtr pDev, tmp;
- int rc;
- REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
-
- len = client->req_len - bytes_to_int32(sizeof(xChangeKeyboardMappingReq));
- if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode))
- return BadLength;
-
- pDev = PickKeyboard(client);
-
- if ((stuff->firstKeyCode < pDev->key->xkbInfo->desc->min_key_code) ||
- (stuff->firstKeyCode > pDev->key->xkbInfo->desc->max_key_code)) {
- client->errorValue = stuff->firstKeyCode;
- return BadValue;
-
- }
- if (((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) >
- pDev->key->xkbInfo->desc->max_key_code) ||
- (stuff->keySymsPerKeyCode == 0)) {
- client->errorValue = stuff->keySymsPerKeyCode;
- return BadValue;
- }
-
- keysyms.minKeyCode = stuff->firstKeyCode;
- keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1;
- keysyms.mapWidth = stuff->keySymsPerKeyCode;
- keysyms.map = (KeySym *) &stuff[1];
-
- rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess);
- if (rc != Success)
- return rc;
-
- XkbApplyMappingChange(pDev, &keysyms, stuff->firstKeyCode,
- stuff->keyCodes, NULL, client);
-
- for (tmp = inputInfo.devices; tmp; tmp = tmp->next) {
- if (IsMaster(tmp) || tmp->u.master != pDev)
- continue;
- if (!tmp->key)
- continue;
-
- rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess);
- if (rc != Success)
- continue;
-
- XkbApplyMappingChange(tmp, &keysyms, stuff->firstKeyCode,
- stuff->keyCodes, NULL, client);
- }
-
- return Success;
-}
-
-int
-ProcSetPointerMapping(ClientPtr client)
-{
- BYTE *map;
- int ret;
- int i, j;
- DeviceIntPtr ptr = PickPointer(client);
- xSetPointerMappingReply rep;
- REQUEST(xSetPointerMappingReq);
- REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
-
- if (client->req_len !=
- bytes_to_int32(sizeof(xSetPointerMappingReq) + stuff->nElts))
- return BadLength;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.success = MappingSuccess;
- map = (BYTE *)&stuff[1];
-
- /* So we're bounded here by the number of core buttons. This check
- * probably wants disabling through XFixes. */
- /* MPX: With ClientPointer, we can return the right number of buttons.
- * Let's just hope nobody changed ClientPointer between GetPointerMapping
- * and SetPointerMapping
- */
- if (stuff->nElts != ptr->button->numButtons) {
- client->errorValue = stuff->nElts;
- return BadValue;
- }
-
- /* Core protocol specs don't allow for duplicate mappings; this check
- * almost certainly wants disabling through XFixes too. */
- for (i = 0; i < stuff->nElts; i++) {
- for (j = i + 1; j < stuff->nElts; j++) {
- if (map[i] && map[i] == map[j]) {
- client->errorValue = map[i];
- return BadValue;
- }
- }
- }
-
- ret = ApplyPointerMapping(ptr, map, stuff->nElts, client);
- if (ret == MappingBusy)
- rep.success = ret;
- else if (ret == -1)
- return BadValue;
- else if (ret != Success)
- return ret;
-
- WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
- return Success;
-}
-
-int
-ProcGetKeyboardMapping(ClientPtr client)
-{
- xGetKeyboardMappingReply rep;
- DeviceIntPtr kbd = PickKeyboard(client);
- XkbDescPtr xkb;
- KeySymsPtr syms;
- int rc;
- REQUEST(xGetKeyboardMappingReq);
- REQUEST_SIZE_MATCH(xGetKeyboardMappingReq);
-
- rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- xkb = kbd->key->xkbInfo->desc;
-
- if ((stuff->firstKeyCode < xkb->min_key_code) ||
- (stuff->firstKeyCode > xkb->max_key_code)) {
- client->errorValue = stuff->firstKeyCode;
- return BadValue;
- }
- if (stuff->firstKeyCode + stuff->count > xkb->max_key_code + 1) {
- client->errorValue = stuff->count;
- return BadValue;
- }
-
- syms = XkbGetCoreMap(kbd);
- if (!syms)
- return BadAlloc;
-
- memset(&rep, 0, sizeof(xGetKeyboardMappingReply));
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.keySymsPerKeyCode = syms->mapWidth;
- /* length is a count of 4 byte quantities and KeySyms are 4 bytes */
- rep.length = syms->mapWidth * stuff->count;
- WriteReplyToClient(client, sizeof(xGetKeyboardMappingReply), &rep);
- client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
- WriteSwappedDataToClient(client,
- syms->mapWidth * stuff->count * sizeof(KeySym),
- &syms->map[syms->mapWidth * (stuff->firstKeyCode -
- syms->minKeyCode)]);
- free(syms->map);
- free(syms);
-
- return Success;
-}
-
-int
-ProcGetPointerMapping(ClientPtr client)
-{
- xGetPointerMappingReply rep;
- /* Apps may get different values each time they call GetPointerMapping as
- * the ClientPointer could change. */
- DeviceIntPtr ptr = PickPointer(client);
- ButtonClassPtr butc = ptr->button;
- int rc;
- REQUEST_SIZE_MATCH(xReq);
-
- rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.nElts = (butc) ? butc->numButtons : 0;
- rep.length = ((unsigned)rep.nElts + (4-1))/4;
- WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep);
- if (butc)
- WriteToClient(client, (int)rep.nElts, (char *)&butc->map[1]);
- return Success;
-}
-
-void
-NoteLedState(DeviceIntPtr keybd, int led, Bool on)
-{
- KeybdCtrl *ctrl = &keybd->kbdfeed->ctrl;
- if (on)
- ctrl->leds |= ((Leds)1 << (led - 1));
- else
- ctrl->leds &= ~((Leds)1 << (led - 1));
-}
-
-int
-Ones(unsigned long mask) /* HACKMEM 169 */
-{
- unsigned long y;
-
- y = (mask >> 1) &033333333333;
- y = mask - y - ((y >>1) & 033333333333);
- return (((y + (y >> 3)) & 030707070707) % 077);
-}
-
-static int
-DoChangeKeyboardControl (ClientPtr client, DeviceIntPtr keybd, XID *vlist,
- BITS32 vmask)
-{
-#define DO_ALL (-1)
- KeybdCtrl ctrl;
- int t;
- int led = DO_ALL;
- int key = DO_ALL;
- BITS32 index2;
- int mask = vmask, i;
- XkbEventCauseRec cause;
-
- ctrl = keybd->kbdfeed->ctrl;
- while (vmask) {
- index2 = (BITS32) lowbit (vmask);
- vmask &= ~index2;
- switch (index2) {
- case KBKeyClickPercent:
- t = (INT8)*vlist;
- vlist++;
- if (t == -1) {
- t = defaultKeyboardControl.click;
- }
- else if (t < 0 || t > 100) {
- client->errorValue = t;
- return BadValue;
- }
- ctrl.click = t;
- break;
- case KBBellPercent:
- t = (INT8)*vlist;
- vlist++;
- if (t == -1) {
- t = defaultKeyboardControl.bell;
- }
- else if (t < 0 || t > 100) {
- client->errorValue = t;
- return BadValue;
- }
- ctrl.bell = t;
- break;
- case KBBellPitch:
- t = (INT16)*vlist;
- vlist++;
- if (t == -1) {
- t = defaultKeyboardControl.bell_pitch;
- }
- else if (t < 0) {
- client->errorValue = t;
- return BadValue;
- }
- ctrl.bell_pitch = t;
- break;
- case KBBellDuration:
- t = (INT16)*vlist;
- vlist++;
- if (t == -1)
- t = defaultKeyboardControl.bell_duration;
- else if (t < 0) {
- client->errorValue = t;
- return BadValue;
- }
- ctrl.bell_duration = t;
- break;
- case KBLed:
- led = (CARD8)*vlist;
- vlist++;
- if (led < 1 || led > 32) {
- client->errorValue = led;
- return BadValue;
- }
- if (!(mask & KBLedMode))
- return BadMatch;
- break;
- case KBLedMode:
- t = (CARD8)*vlist;
- vlist++;
- if (t == LedModeOff) {
- if (led == DO_ALL)
- ctrl.leds = 0x0;
- else
- ctrl.leds &= ~(((Leds)(1)) << (led - 1));
- }
- else if (t == LedModeOn) {
- if (led == DO_ALL)
- ctrl.leds = ~0L;
- else
- ctrl.leds |= (((Leds)(1)) << (led - 1));
- }
- else {
- client->errorValue = t;
- return BadValue;
- }
-
- XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client);
- XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))),
- ctrl.leds, &cause);
- ctrl.leds = keybd->kbdfeed->ctrl.leds;
-
- break;
- case KBKey:
- key = (KeyCode)*vlist;
- vlist++;
- if ((KeyCode)key < keybd->key->xkbInfo->desc->min_key_code ||
- (KeyCode)key > keybd->key->xkbInfo->desc->max_key_code) {
- client->errorValue = key;
- return BadValue;
- }
- if (!(mask & KBAutoRepeatMode))
- return BadMatch;
- break;
- case KBAutoRepeatMode:
- i = (key >> 3);
- mask = (1 << (key & 7));
- t = (CARD8)*vlist;
- vlist++;
- if (key != DO_ALL)
- XkbDisableComputedAutoRepeats(keybd,key);
- if (t == AutoRepeatModeOff) {
- if (key == DO_ALL)
- ctrl.autoRepeat = FALSE;
- else
- ctrl.autoRepeats[i] &= ~mask;
- }
- else if (t == AutoRepeatModeOn) {
- if (key == DO_ALL)
- ctrl.autoRepeat = TRUE;
- else
- ctrl.autoRepeats[i] |= mask;
- }
- else if (t == AutoRepeatModeDefault) {
- if (key == DO_ALL)
- ctrl.autoRepeat = defaultKeyboardControl.autoRepeat;
- else
- ctrl.autoRepeats[i] =
- (ctrl.autoRepeats[i] & ~mask) |
- (defaultKeyboardControl.autoRepeats[i] & mask);
- }
- else {
- client->errorValue = t;
- return BadValue;
- }
- break;
- default:
- client->errorValue = mask;
- return BadValue;
- }
- }
- keybd->kbdfeed->ctrl = ctrl;
-
- /* The XKB RepeatKeys control and core protocol global autorepeat */
- /* value are linked */
- XkbSetRepeatKeys(keybd, key, keybd->kbdfeed->ctrl.autoRepeat);
-
- return Success;
-
-#undef DO_ALL
-}
-
-/**
- * Changes kbd control on the ClientPointer and all attached SDs.
- */
-int
-ProcChangeKeyboardControl (ClientPtr client)
-{
- XID *vlist;
- BITS32 vmask;
- int ret = Success, error = Success;
- DeviceIntPtr pDev = NULL, keyboard;
- REQUEST(xChangeKeyboardControlReq);
-
- REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
-
- vmask = stuff->mask;
- vlist = (XID *)&stuff[1];
-
- if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask))
- return BadLength;
-
- keyboard = PickKeyboard(client);
-
- for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
- if ((pDev == keyboard ||
- (!IsMaster(pDev) && GetMaster(pDev, MASTER_KEYBOARD) == keyboard))
- && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
- ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess);
- if (ret != Success)
- return ret;
- }
- }
-
- for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
- if ((pDev == keyboard ||
- (!IsMaster(pDev) && GetMaster(pDev, MASTER_KEYBOARD) == keyboard))
- && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
- ret = DoChangeKeyboardControl(client, pDev, vlist, vmask);
- if (ret != Success)
- error = ret;
- }
- }
-
- return error;
-}
-
-int
-ProcGetKeyboardControl (ClientPtr client)
-{
- int rc, i;
- DeviceIntPtr kbd = PickKeyboard(client);
- KeybdCtrl *ctrl = &kbd->kbdfeed->ctrl;
- xGetKeyboardControlReply rep;
- REQUEST_SIZE_MATCH(xReq);
-
- rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- rep.type = X_Reply;
- rep.length = 5;
- rep.sequenceNumber = client->sequence;
- rep.globalAutoRepeat = ctrl->autoRepeat;
- rep.keyClickPercent = ctrl->click;
- rep.bellPercent = ctrl->bell;
- rep.bellPitch = ctrl->bell_pitch;
- rep.bellDuration = ctrl->bell_duration;
- rep.ledMask = ctrl->leds;
- for (i = 0; i < 32; i++)
- rep.map[i] = ctrl->autoRepeats[i];
- WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep);
- return Success;
-}
-
-int
-ProcBell(ClientPtr client)
-{
- DeviceIntPtr dev, keybd = PickKeyboard(client);
- int base = keybd->kbdfeed->ctrl.bell;
- int newpercent;
- int rc;
- REQUEST(xBellReq);
- REQUEST_SIZE_MATCH(xBellReq);
-
- if (stuff->percent < -100 || stuff->percent > 100) {
- client->errorValue = stuff->percent;
- return BadValue;
- }
-
- newpercent = (base * stuff->percent) / 100;
- if (stuff->percent < 0)
- newpercent = base + newpercent;
- else
- newpercent = base - newpercent + stuff->percent;
-
- for (dev = inputInfo.devices; dev; dev = dev->next) {
- if ((dev == keybd ||
- (!IsMaster(dev) && GetMaster(dev, MASTER_KEYBOARD) == keybd)) &&
- dev->kbdfeed && dev->kbdfeed->BellProc) {
-
- rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixBellAccess);
- if (rc != Success)
- return rc;
- XkbHandleBell(FALSE, FALSE, dev, newpercent,
- &dev->kbdfeed->ctrl, 0, None, NULL, client);
- }
- }
-
- return Success;
-}
-
-int
-ProcChangePointerControl(ClientPtr client)
-{
- DeviceIntPtr dev, mouse = PickPointer(client);
- PtrCtrl ctrl; /* might get BadValue part way through */
- int rc;
- REQUEST(xChangePointerControlReq);
- REQUEST_SIZE_MATCH(xChangePointerControlReq);
-
- ctrl = mouse->ptrfeed->ctrl;
- if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) {
- client->errorValue = stuff->doAccel;
- return BadValue;
- }
- if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) {
- client->errorValue = stuff->doThresh;
- return BadValue;
- }
- if (stuff->doAccel) {
- if (stuff->accelNum == -1) {
- ctrl.num = defaultPointerControl.num;
- }
- else if (stuff->accelNum < 0) {
- client->errorValue = stuff->accelNum;
- return BadValue;
- }
- else {
- ctrl.num = stuff->accelNum;
- }
-
- if (stuff->accelDenum == -1) {
- ctrl.den = defaultPointerControl.den;
- }
- else if (stuff->accelDenum <= 0) {
- client->errorValue = stuff->accelDenum;
- return BadValue;
- }
- else {
- ctrl.den = stuff->accelDenum;
- }
- }
- if (stuff->doThresh) {
- if (stuff->threshold == -1) {
- ctrl.threshold = defaultPointerControl.threshold;
- }
- else if (stuff->threshold < 0) {
- client->errorValue = stuff->threshold;
- return BadValue;
- }
- else {
- ctrl.threshold = stuff->threshold;
- }
- }
-
- for (dev = inputInfo.devices; dev; dev = dev->next) {
- if ((dev == mouse ||
- (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) == mouse)) &&
- dev->ptrfeed) {
- rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixManageAccess);
- if (rc != Success)
- return rc;
- }
- }
-
- for (dev = inputInfo.devices; dev; dev = dev->next) {
- if ((dev == mouse ||
- (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) == mouse)) &&
- dev->ptrfeed) {
- dev->ptrfeed->ctrl = ctrl;
- }
- }
-
- return Success;
-}
-
-int
-ProcGetPointerControl(ClientPtr client)
-{
- DeviceIntPtr ptr = PickPointer(client);
- PtrCtrl *ctrl = &ptr->ptrfeed->ctrl;
- xGetPointerControlReply rep;
- int rc;
- REQUEST_SIZE_MATCH(xReq);
-
- rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.threshold = ctrl->threshold;
- rep.accelNumerator = ctrl->num;
- rep.accelDenominator = ctrl->den;
- WriteReplyToClient(client, sizeof(xGenericReply), &rep);
- return Success;
-}
-
-void
-MaybeStopHint(DeviceIntPtr dev, ClientPtr client)
-{
- GrabPtr grab = dev->deviceGrab.grab;
-
- if ((grab && SameClient(grab, client) &&
- ((grab->eventMask & PointerMotionHintMask) ||
- (grab->ownerEvents &&
- (EventMaskForClient(dev->valuator->motionHintWindow, client) &
- PointerMotionHintMask)))) ||
- (!grab &&
- (EventMaskForClient(dev->valuator->motionHintWindow, client) &
- PointerMotionHintMask)))
- dev->valuator->motionHintWindow = NullWindow;
-}
-
-int
-ProcGetMotionEvents(ClientPtr client)
-{
- WindowPtr pWin;
- xTimecoord * coords = (xTimecoord *) NULL;
- xGetMotionEventsReply rep;
- int i, count, xmin, xmax, ymin, ymax, rc;
- unsigned long nEvents;
- DeviceIntPtr mouse = PickPointer(client);
- TimeStamp start, stop;
- REQUEST(xGetMotionEventsReq);
- REQUEST_SIZE_MATCH(xGetMotionEventsReq);
-
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
- rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess);
- if (rc != Success)
- return rc;
-
- if (mouse->valuator->motionHintWindow)
- MaybeStopHint(mouse, client);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- nEvents = 0;
- start = ClientTimeToServerTime(stuff->start);
- stop = ClientTimeToServerTime(stuff->stop);
- if ((CompareTimeStamps(start, stop) != LATER) &&
- (CompareTimeStamps(start, currentTime) != LATER) &&
- mouse->valuator->numMotionEvents)
- {
- if (CompareTimeStamps(stop, currentTime) == LATER)
- stop = currentTime;
- count = GetMotionHistory(mouse, &coords, start.milliseconds,
- stop.milliseconds, pWin->drawable.pScreen,
- TRUE);
- xmin = pWin->drawable.x - wBorderWidth (pWin);
- xmax = pWin->drawable.x + (int)pWin->drawable.width +
- wBorderWidth (pWin);
- ymin = pWin->drawable.y - wBorderWidth (pWin);
- ymax = pWin->drawable.y + (int)pWin->drawable.height +
- wBorderWidth (pWin);
- for (i = 0; i < count; i++)
- if ((xmin <= coords[i].x) && (coords[i].x < xmax) &&
- (ymin <= coords[i].y) && (coords[i].y < ymax))
- {
- coords[nEvents].time = coords[i].time;
- coords[nEvents].x = coords[i].x - pWin->drawable.x;
- coords[nEvents].y = coords[i].y - pWin->drawable.y;
- nEvents++;
- }
- }
- rep.length = nEvents * bytes_to_int32(sizeof(xTimecoord));
- rep.nEvents = nEvents;
- WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep);
- if (nEvents)
- {
- client->pSwapReplyFunc = (ReplySwapPtr) SwapTimeCoordWrite;
- WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord),
- (char *)coords);
- }
- free(coords);
- return Success;
-}
-
-int
-ProcQueryKeymap(ClientPtr client)
-{
- xQueryKeymapReply rep;
- int rc, i;
- DeviceIntPtr keybd = PickKeyboard(client);
- CARD8 *down = keybd->key->down;
-
- REQUEST_SIZE_MATCH(xReq);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 2;
-
- rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess);
- if (rc != Success && rc != BadAccess)
- return rc;
-
- for (i = 0; i<32; i++)
- rep.map[i] = down[i];
-
- if (rc == BadAccess)
- memset(rep.map, 0, 32);
-
- WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep);
-
- return Success;
-}
-
-
-/**
- * Recalculate the number of buttons for the master device. The number of
- * buttons on the master device is equal to the number of buttons on the
- * slave device with the highest number of buttons.
- */
-static void
-RecalculateMasterButtons(DeviceIntPtr slave)
-{
- DeviceIntPtr dev, master;
- int maxbuttons = 0;
-
- if (!slave->button || IsMaster(slave))
- return;
-
- master = GetMaster(slave, MASTER_POINTER);
- if (!master)
- return;
-
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (IsMaster(dev) ||
- dev->u.master != master ||
- !dev->button)
- continue;
-
- maxbuttons = max(maxbuttons, dev->button->numButtons);
- }
-
- if (master->button && master->button->numButtons != maxbuttons)
- {
- int i;
- DeviceChangedEvent event;
-
- memset(&event, 0, sizeof(event));
-
- master->button->numButtons = maxbuttons;
-
- event.header = ET_Internal;
- event.type = ET_DeviceChanged;
- event.time = GetTimeInMillis();
- event.deviceid = master->id;
- event.flags = DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE;
- event.buttons.num_buttons = maxbuttons;
- memcpy(&event.buttons.names, master->button->labels, maxbuttons *
- sizeof(Atom));
-
- if (master->valuator)
- {
- event.num_valuators = master->valuator->numAxes;
- for (i = 0; i < event.num_valuators; i++)
- {
- event.valuators[i].min = master->valuator->axes[i].min_value;
- event.valuators[i].max = master->valuator->axes[i].max_value;
- event.valuators[i].resolution = master->valuator->axes[i].resolution;
- event.valuators[i].mode = master->valuator->axes[i].mode;
- event.valuators[i].name = master->valuator->axes[i].label;
- }
- }
-
- if (master->key)
- {
- event.keys.min_keycode = master->key->xkbInfo->desc->min_key_code;
- event.keys.max_keycode = master->key->xkbInfo->desc->max_key_code;
- }
-
- XISendDeviceChangedEvent(master, master, &event);
- }
-}
-
-/**
- * Attach device 'dev' to device 'master'.
- * Client is set to the client that issued the request, or NULL if it comes
- * from some internal automatic pairing.
- *
- * Master may be NULL to set the device floating.
- *
- * We don't allow multi-layer hierarchies right now. You can't attach a slave
- * to another slave.
- */
-int
-AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
-{
- ScreenPtr screen;
- DeviceIntPtr oldmaster;
- if (!dev || IsMaster(dev))
- return BadDevice;
-
- if (master && !IsMaster(master)) /* can't attach to slaves */
- return BadDevice;
-
- /* set from floating to floating? */
- if (!dev->u.master && !master && dev->enabled)
- return Success;
-
- /* free the existing sprite. */
- if (!dev->u.master && dev->spriteInfo->paired == dev)
- {
- screen = miPointerGetScreen(dev);
- screen->DeviceCursorCleanup(dev, screen);
- free(dev->spriteInfo->sprite);
- }
-
- oldmaster = dev->u.master;
- dev->u.master = master;
-
- /* If device is set to floating, we need to create a sprite for it,
- * otherwise things go bad. However, we don't want to render the cursor,
- * so we reset spriteOwner.
- * Sprite has to be forced to NULL first, otherwise InitializeSprite won't
- * alloc new memory but overwrite the previous one.
- */
- if (!master)
- {
- WindowPtr currentRoot;
-
- if (dev->spriteInfo->sprite)
- currentRoot = GetCurrentRootWindow(dev);
- else /* new device auto-set to floating */
- currentRoot = screenInfo.screens[0]->root;
-
- /* we need to init a fake sprite */
- screen = currentRoot->drawable.pScreen;
- screen->DeviceCursorInitialize(dev, screen);
- dev->spriteInfo->sprite = NULL;
- InitializeSprite(dev, currentRoot);
- dev->spriteInfo->spriteOwner = FALSE;
- dev->spriteInfo->paired = dev;
- } else
- {
- dev->spriteInfo->sprite = master->spriteInfo->sprite;
- dev->spriteInfo->paired = master;
- dev->spriteInfo->spriteOwner = FALSE;
-
- RecalculateMasterButtons(master);
- }
-
- /* XXX: in theory, the MD should change back to its old, original
- * classes when the last SD is detached. Thanks to the XTEST devices,
- * we'll always have an SD attached until the MD is removed.
- * So let's not worry about that.
- */
-
- return Success;
-}
-
-/**
- * Return the device paired with the given device or NULL.
- * Returns the device paired with the parent master if the given device is a
- * slave device.
- */
-DeviceIntPtr
-GetPairedDevice(DeviceIntPtr dev)
-{
- if (!IsMaster(dev) && dev->u.master)
- dev = dev->u.master;
-
- return dev->spriteInfo->paired;
-}
-
-
-/**
- * Returns the right master for the type of event needed. If the event is a
- * keyboard event.
- * This function may be called with a master device as argument. If so, the
- * returned master is either the device itself or the paired master device.
- * If dev is a floating slave device, NULL is returned.
- *
- * @type ::MASTER_KEYBOARD or ::MASTER_POINTER
- */
-DeviceIntPtr
-GetMaster(DeviceIntPtr dev, int which)
-{
- DeviceIntPtr master;
-
- if (IsMaster(dev))
- master = dev;
- else
- master = dev->u.master;
-
- if (master)
- {
- if (which == MASTER_KEYBOARD)
- {
- if (master->type != MASTER_KEYBOARD)
- master = GetPairedDevice(master);
- } else
- {
- if (master->type != MASTER_POINTER)
- master = GetPairedDevice(master);
- }
- }
-
- return master;
-}
-
-/**
- * Create a new device pair (== one pointer, one keyboard device).
- * Only allocates the devices, you will need to call ActivateDevice() and
- * EnableDevice() manually.
- * Either a master or a slave device can be created depending on
- * the value for master.
- */
-int
-AllocDevicePair (ClientPtr client, char* name,
- DeviceIntPtr* ptr,
- DeviceIntPtr* keybd,
- DeviceProc ptr_proc,
- DeviceProc keybd_proc,
- Bool master)
-{
- DeviceIntPtr pointer;
- DeviceIntPtr keyboard;
- *ptr = *keybd = NULL;
-
- pointer = AddInputDevice(client, ptr_proc, TRUE);
- if (!pointer)
- return BadAlloc;
-
- if (asprintf(&pointer->name, "%s pointer", name) == -1) {
- pointer->name = NULL;
- RemoveDevice(pointer, FALSE);
- return BadAlloc;
- }
-
- pointer->public.processInputProc = ProcessOtherEvent;
- pointer->public.realInputProc = ProcessOtherEvent;
- XkbSetExtension(pointer, ProcessPointerEvent);
- pointer->deviceGrab.ActivateGrab = ActivatePointerGrab;
- pointer->deviceGrab.DeactivateGrab = DeactivatePointerGrab;
- pointer->coreEvents = TRUE;
- pointer->spriteInfo->spriteOwner = TRUE;
-
- pointer->u.lastSlave = NULL;
- pointer->last.slave = NULL;
- pointer->type = (master) ? MASTER_POINTER : SLAVE;
-
- keyboard = AddInputDevice(client, keybd_proc, TRUE);
- if (!keyboard)
- {
- RemoveDevice(pointer, FALSE);
- return BadAlloc;
- }
-
- if (asprintf(&keyboard->name, "%s keyboard", name) == -1) {
- keyboard->name = NULL;
- RemoveDevice(keyboard, FALSE);
- RemoveDevice(pointer, FALSE);
- return BadAlloc;
- }
-
- keyboard->public.processInputProc = ProcessOtherEvent;
- keyboard->public.realInputProc = ProcessOtherEvent;
- XkbSetExtension(keyboard, ProcessKeyboardEvent);
- keyboard->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
- keyboard->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
- keyboard->coreEvents = TRUE;
- keyboard->spriteInfo->spriteOwner = FALSE;
-
- keyboard->u.lastSlave = NULL;
- keyboard->last.slave = NULL;
- keyboard->type = (master) ? MASTER_KEYBOARD : SLAVE;
-
- /* The ClassesRec stores the device classes currently not used. */
- pointer->unused_classes = calloc(1, sizeof(ClassesRec));
- keyboard->unused_classes = calloc(1, sizeof(ClassesRec));
-
- *ptr = pointer;
- *keybd = keyboard;
-
- return Success;
-}
-
-/**
- * Return Relative or Absolute for the device.
- */
-int valuator_get_mode(DeviceIntPtr dev, int axis)
-{
- return (dev->valuator->axes[axis].mode & DeviceMode);
-}
-
-/**
- * Set the given mode for the axis. If axis is VALUATOR_MODE_ALL_AXES, then
- * set the mode for all axes.
- */
-void valuator_set_mode(DeviceIntPtr dev, int axis, int mode)
-{
- if (axis != VALUATOR_MODE_ALL_AXES)
- dev->valuator->axes[axis].mode = mode;
- else {
- int i;
- for (i = 0; i < dev->valuator->numAxes; i++)
- dev->valuator->axes[i].mode = mode;
- }
-}
+/************************************************************ + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +********************************************************/ + + + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <X11/X.h> +#include "misc.h" +#include "resource.h" +#include <X11/Xproto.h> +#include <X11/Xatom.h> +#include "windowstr.h" +#include "inputstr.h" +#include "scrnintstr.h" +#include "cursorstr.h" +#include "dixstruct.h" +#include "ptrveloc.h" +#include "site.h" +#include "xkbsrv.h" +#include "privates.h" +#include "xace.h" +#include "mi.h" + +#include "dispatch.h" +#include "swaprep.h" +#include "dixevents.h" +#include "mipointer.h" +#include "eventstr.h" + +#include <X11/extensions/XI.h> +#include <X11/extensions/XI2.h> +#include <X11/extensions/XIproto.h> +#include <math.h> +#include <pixman.h> +#include "exglobals.h" +#include "exevents.h" +#include "xiquerydevice.h" /* for SizeDeviceClasses */ +#include "xiproperty.h" +#include "enterleave.h" /* for EnterWindow() */ +#include "xserver-properties.h" +#include "xichangehierarchy.h" /* For XISendDeviceHierarchyEvent */ + +/** @file + * This file handles input device-related stuff. + */ + +static void RecalculateMasterButtons(DeviceIntPtr slave); + +static void +DeviceSetTransform(DeviceIntPtr dev, float *transform) +{ + struct pixman_f_transform scale; + double sx, sy; + int x, y; + + /** + * calculate combined transformation matrix: + * + * M = InvScale * Transform * Scale + * + * So we can later transform points using M * p + * + * Where: + * Scale scales coordinates into 0..1 range + * Transform is the user supplied (affine) transform + * InvScale scales coordinates back up into their native range + */ + sx = dev->valuator->axes[0].max_value - dev->valuator->axes[0].min_value; + sy = dev->valuator->axes[1].max_value - dev->valuator->axes[1].min_value; + + /* invscale */ + pixman_f_transform_init_scale(&scale, sx, sy); + scale.m[0][2] = dev->valuator->axes[0].min_value; + scale.m[1][2] = dev->valuator->axes[1].min_value; + + /* transform */ + for (y=0; y<3; y++) + for (x=0; x<3; x++) + dev->transform.m[y][x] = *transform++; + + pixman_f_transform_multiply(&dev->transform, &scale, &dev->transform); + + /* scale */ + pixman_f_transform_init_scale(&scale, 1.0 / sx, 1.0 / sy); + scale.m[0][2] = -dev->valuator->axes[0].min_value / sx; + scale.m[1][2] = -dev->valuator->axes[1].min_value / sy; + + pixman_f_transform_multiply(&dev->transform, &dev->transform, &scale); +} + +/** + * DIX property handler. + */ +static int +DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, + BOOL checkonly) +{ + if (property == XIGetKnownProperty(XI_PROP_ENABLED)) + { + if (prop->format != 8 || prop->type != XA_INTEGER || prop->size != 1) + return BadValue; + + /* Don't allow disabling of VCP/VCK */ + if ((dev == inputInfo.pointer || dev == inputInfo.keyboard) && + !(*(CARD8*)prop->data)) + return BadAccess; + + if (!checkonly) + { + if ((*((CARD8*)prop->data)) && !dev->enabled) + EnableDevice(dev, TRUE); + else if (!(*((CARD8*)prop->data)) && dev->enabled) + DisableDevice(dev, TRUE); + } + } else if (property == XIGetKnownProperty(XI_PROP_TRANSFORM)) + { + float *f = (float*)prop->data; + int i; + + if (prop->format != 32 || prop->size != 9 || + prop->type != XIGetKnownProperty(XATOM_FLOAT)) + return BadValue; + + for (i=0; i<9; i++) + if (!isfinite(f[i])) + return BadValue; + + if (!checkonly) + DeviceSetTransform(dev, f); + } + + return Success; +} + +/* Pair the keyboard to the pointer device. Keyboard events will follow the + * pointer sprite. Only applicable for master devices. + * If the client is set, the request to pair comes from some client. In this + * case, we need to check for access. If the client is NULL, it's from an + * internal automatic pairing, we must always permit this. + */ +static int +PairDevices(ClientPtr client, DeviceIntPtr ptr, DeviceIntPtr kbd) +{ + if (!ptr) + return BadDevice; + + /* Don't allow pairing for slave devices */ + if (!IsMaster(ptr) || !IsMaster(kbd)) + return BadDevice; + + if (ptr->spriteInfo->paired) + return BadDevice; + + if (kbd->spriteInfo->spriteOwner) + { + free(kbd->spriteInfo->sprite); + kbd->spriteInfo->sprite = NULL; + kbd->spriteInfo->spriteOwner = FALSE; + } + + kbd->spriteInfo->sprite = ptr->spriteInfo->sprite; + kbd->spriteInfo->paired = ptr; + ptr->spriteInfo->paired = kbd; + return Success; +} + + +/** + * Find and return the next unpaired MD pointer device. + */ +static DeviceIntPtr +NextFreePointerDevice(void) +{ + DeviceIntPtr dev; + for (dev = inputInfo.devices; dev; dev = dev->next) + if (IsMaster(dev) && + dev->spriteInfo->spriteOwner && + !dev->spriteInfo->paired) + return dev; + return NULL; +} + +/** + * Create a new input device and init it to sane values. The device is added + * to the server's off_devices list. + * + * @param deviceProc Callback for device control function (switch dev on/off). + * @return The newly created device. + */ +DeviceIntPtr +AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart) +{ + DeviceIntPtr dev, *prev; /* not a typo */ + DeviceIntPtr devtmp; + int devid; + char devind[MAXDEVICES]; + BOOL enabled; + float transform[9]; + + /* Find next available id, 0 and 1 are reserved */ + memset(devind, 0, sizeof(char)*MAXDEVICES); + for (devtmp = inputInfo.devices; devtmp; devtmp = devtmp->next) + devind[devtmp->id]++; + for (devtmp = inputInfo.off_devices; devtmp; devtmp = devtmp->next) + devind[devtmp->id]++; + for (devid = 2; devid < MAXDEVICES && devind[devid]; devid++) + ; + + if (devid >= MAXDEVICES) + return (DeviceIntPtr)NULL; + dev = _dixAllocateObjectWithPrivates(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), + sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), + offsetof(DeviceIntRec, devPrivates), PRIVATE_DEVICE); + if (!dev) + return (DeviceIntPtr)NULL; + dev->id = devid; + dev->public.processInputProc = ProcessOtherEvent; + dev->public.realInputProc = ProcessOtherEvent; + dev->public.enqueueInputProc = EnqueueEvent; + dev->deviceProc = deviceProc; + dev->startup = autoStart; + + /* device grab defaults */ + dev->deviceGrab.grabTime = currentTime; + dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab; + dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab; + + XkbSetExtension(dev, ProcessKeyboardEvent); + + dev->coreEvents = TRUE; + + /* sprite defaults */ + dev->spriteInfo = (SpriteInfoPtr)&dev[1]; + + /* security creation/labeling check + */ + if (XaceHook(XACE_DEVICE_ACCESS, client, dev, DixCreateAccess)) { + free(dev); + return NULL; + } + + inputInfo.numDevices++; + + for (prev = &inputInfo.off_devices; *prev; prev = &(*prev)->next) + ; + *prev = dev; + dev->next = NULL; + + enabled = FALSE; + XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED), + XA_INTEGER, 8, PropModeReplace, 1, &enabled, + FALSE); + XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_ENABLED), FALSE); + + /* unity matrix */ + memset(transform, 0, sizeof(transform)); + transform[0] = transform[4] = transform[8] = 1.0f; + + XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_TRANSFORM), + XIGetKnownProperty(XATOM_FLOAT), 32, + PropModeReplace, 9, transform, FALSE); + XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_TRANSFORM), + FALSE); + + XIRegisterPropertyHandler(dev, DeviceSetProperty, NULL, NULL); + + return dev; +} + +void +SendDevicePresenceEvent(int deviceid, int type) +{ + DeviceIntRec dummyDev; + devicePresenceNotify ev; + + memset(&dummyDev, 0, sizeof(DeviceIntRec)); + ev.type = DevicePresenceNotify; + ev.time = currentTime.milliseconds; + ev.devchange = type; + ev.deviceid = deviceid; + dummyDev.id = XIAllDevices; + SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask, + (xEvent*)&ev, 1); +} + +/** + * Enable the device through the driver, add the device to the device list. + * Switch device ON through the driver and push it onto the global device + * list. Initialize the DIX sprite or pair the device. All clients are + * notified about the device being enabled. + * + * A master pointer device needs to be enabled before a master keyboard + * device. + * + * @param The device to be enabled. + * @param sendevent True if an XI2 event should be sent. + * @return TRUE on success or FALSE otherwise. + */ +Bool +EnableDevice(DeviceIntPtr dev, BOOL sendevent) +{ + DeviceIntPtr *prev; + int ret; + DeviceIntPtr other; + BOOL enabled; + int flags[MAXDEVICES] = {0}; + + for (prev = &inputInfo.off_devices; + *prev && (*prev != dev); + prev = &(*prev)->next) + ; + + if (!dev->spriteInfo->sprite) + { + if (IsMaster(dev)) + { + /* Sprites appear on first root window, so we can hardcode it */ + if (dev->spriteInfo->spriteOwner) + { + InitializeSprite(dev, screenInfo.screens[0]->root); + /* mode doesn't matter */ + EnterWindow(dev, screenInfo.screens[0]->root, NotifyAncestor); + } + else if ((other = NextFreePointerDevice()) == NULL) + { + ErrorF("[dix] cannot find pointer to pair with. " + "This is a bug.\n"); + return FALSE; + } else + PairDevices(NULL, other, dev); + } else + { + if (dev->coreEvents) + other = (IsPointerDevice(dev)) ? inputInfo.pointer : + inputInfo.keyboard; + else + other = NULL; /* auto-float non-core devices */ + AttachDevice(NULL, dev, other); + } + } + + if ((*prev != dev) || !dev->inited || + ((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) { + ErrorF("[dix] couldn't enable device %d\n", dev->id); + return FALSE; + } + dev->enabled = TRUE; + *prev = dev->next; + + for (prev = &inputInfo.devices; *prev; prev = &(*prev)->next) + ; + *prev = dev; + dev->next = NULL; + + enabled = TRUE; + XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED), + XA_INTEGER, 8, PropModeReplace, 1, &enabled, + TRUE); + + SendDevicePresenceEvent(dev->id, DeviceEnabled); + if (sendevent) + { + flags[dev->id] |= XIDeviceEnabled; + XISendDeviceHierarchyEvent(flags); + } + + RecalculateMasterButtons(dev); + + return TRUE; +} + +/** + * Switch a device off through the driver and push it onto the off_devices + * list. A device will not send events while disabled. All clients are + * notified about the device being disabled. + * + * Master keyboard devices have to be disabled before master pointer devices + * otherwise things turn bad. + * + * @param sendevent True if an XI2 event should be sent. + * @return TRUE on success or FALSE otherwise. + */ +Bool +DisableDevice(DeviceIntPtr dev, BOOL sendevent) +{ + DeviceIntPtr *prev, other; + BOOL enabled; + int flags[MAXDEVICES] = {0}; + + for (prev = &inputInfo.devices; + *prev && (*prev != dev); + prev = &(*prev)->next) + ; + if (*prev != dev) + return FALSE; + + /* float attached devices */ + if (IsMaster(dev)) + { + for (other = inputInfo.devices; other; other = other->next) + { + if (other->u.master == dev) + { + AttachDevice(NULL, other, NULL); + flags[other->id] |= XISlaveDetached; + } + } + } + else + { + for (other = inputInfo.devices; other; other = other->next) + { + if (IsMaster(other) && other->u.lastSlave == dev) + other->u.lastSlave = NULL; + } + } + + if (IsMaster(dev) && dev->spriteInfo->sprite) + { + for (other = inputInfo.devices; other; other = other->next) + { + if (other->spriteInfo->paired == dev) + { + ErrorF("[dix] cannot disable device, still paired. " + "This is a bug. \n"); + return FALSE; + } + } + } + + (void)(*dev->deviceProc)(dev, DEVICE_OFF); + dev->enabled = FALSE; + + /* now that the device is disabled, we can reset the signal handler's + * last.slave */ + OsBlockSignals(); + for (other = inputInfo.devices; other; other = other->next) + { + if (other->last.slave == dev) + other->last.slave = NULL; + } + OsReleaseSignals(); + + LeaveWindow(dev); + SetFocusOut(dev); + + *prev = dev->next; + dev->next = inputInfo.off_devices; + inputInfo.off_devices = dev; + + enabled = FALSE; + XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED), + XA_INTEGER, 8, PropModeReplace, 1, &enabled, + TRUE); + + SendDevicePresenceEvent(dev->id, DeviceDisabled); + if (sendevent) + { + flags[dev->id] = XIDeviceDisabled; + XISendDeviceHierarchyEvent(flags); + } + + RecalculateMasterButtons(dev); + + return TRUE; +} + +/** + * Initialise a new device through the driver and tell all clients about the + * new device. + * + * Must be called before EnableDevice. + * The device will NOT send events until it is enabled! + * + * @param sendevent True if an XI2 event should be sent. + * @return Success or an error code on failure. + */ +int +ActivateDevice(DeviceIntPtr dev, BOOL sendevent) +{ + int ret = Success; + ScreenPtr pScreen = screenInfo.screens[0]; + + if (!dev || !dev->deviceProc) + return BadImplementation; + + ret = (*dev->deviceProc) (dev, DEVICE_INIT); + dev->inited = (ret == Success); + if (!dev->inited) + return ret; + + /* Initialize memory for sprites. */ + if (IsMaster(dev) && dev->spriteInfo->spriteOwner) + if (!pScreen->DeviceCursorInitialize(dev, pScreen)) + ret = BadAlloc; + + SendDevicePresenceEvent(dev->id, DeviceAdded); + if (sendevent) + { + int flags[MAXDEVICES] = {0}; + flags[dev->id] = XISlaveAdded; + XISendDeviceHierarchyEvent(flags); + } + return ret; +} + +/** + * Ring the bell. + * The actual task of ringing the bell is the job of the DDX. + */ +static void +CoreKeyboardBell(int volume, DeviceIntPtr pDev, pointer arg, int something) +{ + KeybdCtrl *ctrl = arg; + + DDXRingBell(volume, ctrl->bell_pitch, ctrl->bell_duration); +} + +static void +CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl) +{ + return; +} + +/** + * Device control function for the Virtual Core Keyboard. + */ +int +CoreKeyboardProc(DeviceIntPtr pDev, int what) +{ + + switch (what) { + case DEVICE_INIT: + if (!InitKeyboardDeviceStruct(pDev, NULL, CoreKeyboardBell, + CoreKeyboardCtl)) + { + ErrorF("Keyboard initialization failed. This could be a missing " + "or incorrect setup of xkeyboard-config.\n"); + return BadValue; + } + return Success; + + case DEVICE_ON: + case DEVICE_OFF: + return Success; + + case DEVICE_CLOSE: + return Success; + } + + return BadMatch; +} + +/** + * Device control function for the Virtual Core Pointer. + */ +int +CorePointerProc(DeviceIntPtr pDev, int what) +{ +#define NBUTTONS 10 +#define NAXES 2 + BYTE map[NBUTTONS + 1]; + int i = 0; + Atom btn_labels[NBUTTONS] = {0}; + Atom axes_labels[NAXES] = {0}; + + switch (what) { + case DEVICE_INIT: + for (i = 1; i <= NBUTTONS; i++) + map[i] = i; + + btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); + btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); + btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); + btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); + btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); + btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); + btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); + /* don't know about the rest */ + + axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); + axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); + + if (!InitPointerDeviceStruct((DevicePtr)pDev, map, NBUTTONS, btn_labels, + (PtrCtrlProcPtr)NoopDDA, + GetMotionHistorySize(), NAXES, axes_labels)) + { + ErrorF("Could not initialize device '%s'. Out of memory.\n", + pDev->name); + return BadAlloc; /* IPDS only fails on allocs */ + } + pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2; + pDev->last.valuators[0] = pDev->valuator->axisVal[0]; + pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2; + pDev->last.valuators[1] = pDev->valuator->axisVal[1]; + break; + + case DEVICE_CLOSE: + break; + + default: + break; + } + + return Success; + +#undef NBUTTONS +#undef NAXES +} + +/** + * Initialise the two core devices, VCP and VCK (see events.c). + * Both devices are not tied to physical devices, but guarantee that there is + * always a keyboard and a pointer present and keep the protocol semantics. + * + * Note that the server MUST have two core devices at all times, even if there + * is no physical device connected. + */ +void +InitCoreDevices(void) +{ + if (AllocDevicePair(serverClient, "Virtual core", + &inputInfo.pointer, &inputInfo.keyboard, + CorePointerProc, CoreKeyboardProc, + TRUE) != Success) + FatalError("Failed to allocate core devices"); + + if (ActivateDevice(inputInfo.pointer, TRUE) != Success || + ActivateDevice(inputInfo.keyboard, TRUE) != Success) + FatalError("Failed to activate core devices."); + if (!EnableDevice(inputInfo.pointer, TRUE) || + !EnableDevice(inputInfo.keyboard, TRUE)) + FatalError("Failed to enable core devices."); + + InitXTestDevices(); +} + +/** + * Activate all switched-off devices and then enable all those devices. + * + * Will return an error if no core keyboard or core pointer is present. + * In theory this should never happen if you call InitCoreDevices() first. + * + * InitAndStartDevices needs to be called AFTER the windows are initialized. + * Devices will start sending events after InitAndStartDevices() has + * completed. + * + * @return Success or error code on failure. + */ +int +InitAndStartDevices(void) +{ + DeviceIntPtr dev, next; + + for (dev = inputInfo.off_devices; dev; dev = dev->next) { + DebugF("(dix) initialising device %d\n", dev->id); + if (!dev->inited) + ActivateDevice(dev, TRUE); + } + + /* enable real devices */ + for (dev = inputInfo.off_devices; dev; dev = next) + { + DebugF("(dix) enabling device %d\n", dev->id); + next = dev->next; + if (dev->inited && dev->startup) + EnableDevice(dev, TRUE); + } + + return Success; +} + +/** + * Free the given device class and reset the pointer to NULL. + */ +static void +FreeDeviceClass(int type, pointer *class) +{ + if (!(*class)) + return; + + switch(type) + { + case KeyClass: + { + KeyClassPtr* k = (KeyClassPtr*)class; + if ((*k)->xkbInfo) + { + XkbFreeInfo((*k)->xkbInfo); + (*k)->xkbInfo = NULL; + } + free((*k)); + break; + } + case ButtonClass: + { + ButtonClassPtr *b = (ButtonClassPtr*)class; + free((*b)->xkb_acts); + free((*b)); + break; + } + case ValuatorClass: + { + ValuatorClassPtr *v = (ValuatorClassPtr*)class; + + free((*v)->motion); + free((*v)); + break; + } + case FocusClass: + { + FocusClassPtr *f = (FocusClassPtr*)class; + free((*f)->trace); + free((*f)); + break; + } + case ProximityClass: + { + ProximityClassPtr *p = (ProximityClassPtr*)class; + free((*p)); + break; + } + } + *class = NULL; +} + +static void +FreeFeedbackClass(int type, pointer *class) +{ + if (!(*class)) + return; + + switch(type) + { + case KbdFeedbackClass: + { + KbdFeedbackPtr *kbdfeed = (KbdFeedbackPtr*)class; + KbdFeedbackPtr k, knext; + for (k = (*kbdfeed); k; k = knext) { + knext = k->next; + if (k->xkb_sli) + XkbFreeSrvLedInfo(k->xkb_sli); + free(k); + } + break; + } + case PtrFeedbackClass: + { + PtrFeedbackPtr *ptrfeed = (PtrFeedbackPtr*)class; + PtrFeedbackPtr p, pnext; + + for (p = (*ptrfeed); p; p = pnext) { + pnext = p->next; + free(p); + } + break; + } + case IntegerFeedbackClass: + { + IntegerFeedbackPtr *intfeed = (IntegerFeedbackPtr*)class; + IntegerFeedbackPtr i, inext; + + for (i = (*intfeed); i; i = inext) { + inext = i->next; + free(i); + } + break; + } + case StringFeedbackClass: + { + StringFeedbackPtr *stringfeed = (StringFeedbackPtr*)class; + StringFeedbackPtr s, snext; + + for (s = (*stringfeed); s; s = snext) { + snext = s->next; + free(s->ctrl.symbols_supported); + free(s->ctrl.symbols_displayed); + free(s); + } + break; + } + case BellFeedbackClass: + { + BellFeedbackPtr *bell = (BellFeedbackPtr*)class; + BellFeedbackPtr b, bnext; + + for (b = (*bell); b; b = bnext) { + bnext = b->next; + free(b); + } + break; + } + case LedFeedbackClass: + { + LedFeedbackPtr *leds = (LedFeedbackPtr*)class; + LedFeedbackPtr l, lnext; + + for (l = (*leds); l; l = lnext) { + lnext = l->next; + if (l->xkb_sli) + XkbFreeSrvLedInfo(l->xkb_sli); + free(l); + } + break; + } + } + *class = NULL; +} + +static void +FreeAllDeviceClasses(ClassesPtr classes) +{ + if (!classes) + return; + + FreeDeviceClass(KeyClass, (pointer)&classes->key); + FreeDeviceClass(ValuatorClass, (pointer)&classes->valuator); + FreeDeviceClass(ButtonClass, (pointer)&classes->button); + FreeDeviceClass(FocusClass, (pointer)&classes->focus); + FreeDeviceClass(ProximityClass, (pointer)&classes->proximity); + + FreeFeedbackClass(KbdFeedbackClass, (pointer)&classes->kbdfeed); + FreeFeedbackClass(PtrFeedbackClass, (pointer)&classes->ptrfeed); + FreeFeedbackClass(IntegerFeedbackClass, (pointer)&classes->intfeed); + FreeFeedbackClass(StringFeedbackClass, (pointer)&classes->stringfeed); + FreeFeedbackClass(BellFeedbackClass, (pointer)&classes->bell); + FreeFeedbackClass(LedFeedbackClass, (pointer)&classes->leds); + +} + +/** + * Close down a device and free all resources. + * Once closed down, the driver will probably not expect you that you'll ever + * enable it again and free associated structs. If you want the device to just + * be disabled, DisableDevice(). + * Don't call this function directly, use RemoveDevice() instead. + */ +static void +CloseDevice(DeviceIntPtr dev) +{ + ScreenPtr screen = screenInfo.screens[0]; + ClassesPtr classes; + int j; + + if (!dev) + return; + + XIDeleteAllDeviceProperties(dev); + + if (dev->inited) + (void)(*dev->deviceProc)(dev, DEVICE_CLOSE); + + /* free sprite memory */ + if (IsMaster(dev) && dev->spriteInfo->sprite) + screen->DeviceCursorCleanup(dev, screen); + + /* free acceleration info */ + if(dev->valuator && dev->valuator->accelScheme.AccelCleanupProc) + dev->valuator->accelScheme.AccelCleanupProc(dev); + + while (dev->xkb_interest) + XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource); + + free(dev->name); + + classes = (ClassesPtr)&dev->key; + FreeAllDeviceClasses(classes); + + if (IsMaster(dev)) + { + classes = dev->unused_classes; + FreeAllDeviceClasses(classes); + free(classes); + } + + if (DevHasCursor(dev) && dev->spriteInfo->sprite) { + if (dev->spriteInfo->sprite->current) + FreeCursor(dev->spriteInfo->sprite->current, None); + free(dev->spriteInfo->sprite->spriteTrace); + free(dev->spriteInfo->sprite); + } + + /* a client may have the device set as client pointer */ + for (j = 0; j < currentMaxClients; j++) + { + if (clients[j] && clients[j]->clientPtr == dev) + { + clients[j]->clientPtr = NULL; + clients[j]->clientPtr = PickPointer(clients[j]); + } + } + + free(dev->deviceGrab.sync.event); + dixFreeObjectWithPrivates(dev, PRIVATE_DEVICE); +} + +/** + * Shut down all devices of one list and free all resources. + */ +static +void +CloseDeviceList(DeviceIntPtr *listHead) +{ + /* Used to mark devices that we tried to free */ + Bool freedIds[MAXDEVICES]; + DeviceIntPtr dev; + int i; + + if (listHead == NULL) + return; + + for (i = 0; i < MAXDEVICES; i++) + freedIds[i] = FALSE; + + dev = *listHead; + while (dev != NULL) + { + freedIds[dev->id] = TRUE; + DeleteInputDeviceRequest(dev); + + dev = *listHead; + while (dev != NULL && freedIds[dev->id]) + dev = dev->next; + } +} + +/** + * Shut down all devices, free all resources, etc. + * Only useful if you're shutting down the server! + */ +void +CloseDownDevices(void) +{ + DeviceIntPtr dev; + + /* Float all SDs before closing them. Note that at this point resources + * (e.g. cursors) have been freed already, so we can't just call + * AttachDevice(NULL, dev, NULL). Instead, we have to forcibly set master + * to NULL and pretend nothing happened. + */ + for (dev = inputInfo.devices; dev; dev = dev->next) + { + if (!IsMaster(dev) && dev->u.master) + dev->u.master = NULL; + } + + CloseDeviceList(&inputInfo.devices); + CloseDeviceList(&inputInfo.off_devices); + + CloseDevice(inputInfo.pointer); + CloseDevice(inputInfo.keyboard); + + inputInfo.devices = NULL; + inputInfo.off_devices = NULL; + inputInfo.keyboard = NULL; + inputInfo.pointer = NULL; + XkbDeleteRulesDflts(); +} + +/** + * Remove the cursor sprite for all devices. This needs to be done before any + * resources are freed or any device is deleted. + */ +void +UndisplayDevices(void) +{ + DeviceIntPtr dev; + ScreenPtr screen = screenInfo.screens[0]; + + for (dev = inputInfo.devices; dev; dev = dev->next) + screen->DisplayCursor(dev, screen, NullCursor); +} + +/** + * Remove a device from the device list, closes it and thus frees all + * resources. + * Removes both enabled and disabled devices and notifies all devices about + * the removal of the device. + * + * No PresenceNotify is sent for device that the client never saw. This can + * happen if a malloc fails during the addition of master devices. If + * dev->init is FALSE it means the client never received a DeviceAdded event, + * so let's not send a DeviceRemoved event either. + * + * @param sendevent True if an XI2 event should be sent. + */ +int +RemoveDevice(DeviceIntPtr dev, BOOL sendevent) +{ + DeviceIntPtr prev,tmp,next; + int ret = BadMatch; + ScreenPtr screen = screenInfo.screens[0]; + int deviceid; + int initialized; + int flags[MAXDEVICES] = {0}; + + DebugF("(dix) removing device %d\n", dev->id); + + if (!dev || dev == inputInfo.keyboard || dev == inputInfo.pointer) + return BadImplementation; + + initialized = dev->inited; + deviceid = dev->id; + + if (initialized) + { + if (DevHasCursor(dev)) + screen->DisplayCursor(dev, screen, NullCursor); + + DisableDevice(dev, sendevent); + flags[dev->id] = XIDeviceDisabled; + } + + prev = NULL; + for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) { + next = tmp->next; + if (tmp == dev) { + + if (prev==NULL) + inputInfo.devices = next; + else + prev->next = next; + + flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved; + CloseDevice(tmp); + ret = Success; + } + } + + prev = NULL; + for (tmp = inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) { + next = tmp->next; + if (tmp == dev) { + flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved; + CloseDevice(tmp); + + if (prev == NULL) + inputInfo.off_devices = next; + else + prev->next = next; + + ret = Success; + } + } + + if (ret == Success && initialized) { + inputInfo.numDevices--; + SendDevicePresenceEvent(deviceid, DeviceRemoved); + if (sendevent) + XISendDeviceHierarchyEvent(flags); + } + + return ret; +} + +int +NumMotionEvents(void) +{ + /* only called to fill data in initial connection reply. + * VCP is ok here, it is the only fixed device we have. */ + return inputInfo.pointer->valuator->numMotionEvents; +} + +int +dixLookupDevice(DeviceIntPtr *pDev, int id, ClientPtr client, Mask access_mode) +{ + DeviceIntPtr dev; + int rc; + *pDev = NULL; + + for (dev=inputInfo.devices; dev; dev=dev->next) { + if (dev->id == id) + goto found; + } + for (dev=inputInfo.off_devices; dev; dev=dev->next) { + if (dev->id == id) + goto found; + } + return BadDevice; + +found: + rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode); + if (rc == Success) + *pDev = dev; + return rc; +} + +void +QueryMinMaxKeyCodes(KeyCode *minCode, KeyCode *maxCode) +{ + if (inputInfo.keyboard) { + *minCode = inputInfo.keyboard->key->xkbInfo->desc->min_key_code; + *maxCode = inputInfo.keyboard->key->xkbInfo->desc->max_key_code; + } +} + +/* Notably, this function does not expand the destination's keycode range, or + * notify clients. */ +Bool +SetKeySymsMap(KeySymsPtr dst, KeySymsPtr src) +{ + int i, j; + KeySym *tmp; + int rowDif = src->minKeyCode - dst->minKeyCode; + + /* if keysym map size changes, grow map first */ + if (src->mapWidth < dst->mapWidth) { + for (i = src->minKeyCode; i <= src->maxKeyCode; i++) { +#define SI(r, c) (((r - src->minKeyCode) * src->mapWidth) + (c)) +#define DI(r, c) (((r - dst->minKeyCode) * dst->mapWidth) + (c)) + for (j = 0; j < src->mapWidth; j++) + dst->map[DI(i, j)] = src->map[SI(i, j)]; + for (j = src->mapWidth; j < dst->mapWidth; j++) + dst->map[DI(i, j)] = NoSymbol; +#undef SI +#undef DI + } + return TRUE; + } + else if (src->mapWidth > dst->mapWidth) { + i = sizeof(KeySym) * src->mapWidth * + (dst->maxKeyCode - dst->minKeyCode + 1); + tmp = calloc(sizeof(KeySym), i); + if (!tmp) + return FALSE; + + if (dst->map) { + for (i = 0; i <= dst->maxKeyCode-dst->minKeyCode; i++) + memmove(&tmp[i * src->mapWidth], &dst->map[i * dst->mapWidth], + dst->mapWidth * sizeof(KeySym)); + free(dst->map); + } + dst->mapWidth = src->mapWidth; + dst->map = tmp; + } + else if (!dst->map) { + i = sizeof(KeySym) * src->mapWidth * + (dst->maxKeyCode - dst->minKeyCode + 1); + tmp = calloc(sizeof(KeySym), i); + if (!tmp) + return FALSE; + + dst->map = tmp; + dst->mapWidth = src->mapWidth; + } + + memmove(&dst->map[rowDif * dst->mapWidth], src->map, + (src->maxKeyCode - src->minKeyCode + 1) * + dst->mapWidth * sizeof(KeySym)); + + return TRUE; +} + +Bool +InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom* labels, + CARD8 *map) +{ + ButtonClassPtr butc; + int i; + + butc = calloc(1, sizeof(ButtonClassRec)); + if (!butc) + return FALSE; + butc->numButtons = numButtons; + butc->sourceid = dev->id; + for (i = 1; i <= numButtons; i++) + butc->map[i] = map[i]; + for (i = numButtons + 1; i < MAP_LENGTH; i++) + butc->map[i] = i; + memcpy(butc->labels, labels, numButtons * sizeof(Atom)); + dev->button = butc; + return TRUE; +} + +Bool +InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels, + int numMotionEvents, int mode) +{ + int i; + ValuatorClassPtr valc; + union align_u { ValuatorClassRec valc; double d; } *align; + + if (!dev) + return FALSE; + + if (numAxes > MAX_VALUATORS) + { + LogMessage(X_WARNING, + "Device '%s' has %d axes, only using first %d.\n", + dev->name, numAxes, MAX_VALUATORS); + numAxes = MAX_VALUATORS; + } + + align = (union align_u *) calloc(1, sizeof(union align_u) + + numAxes * sizeof(double) + + numAxes * sizeof(AxisInfo)); + if (!align) + return FALSE; + + valc = &align->valc; + valc->sourceid = dev->id; + valc->motion = NULL; + valc->first_motion = 0; + valc->last_motion = 0; + + valc->numMotionEvents = numMotionEvents; + valc->motionHintWindow = NullWindow; + valc->numAxes = numAxes; + valc->axisVal = (double *)(align + 1); + valc->axes = (AxisInfoPtr)(valc->axisVal + numAxes); + + if (mode & OutOfProximity) + InitProximityClassDeviceStruct(dev); + + dev->valuator = valc; + + AllocateMotionHistory(dev); + + for (i=0; i<numAxes; i++) { + InitValuatorAxisStruct(dev, i, labels[i], NO_AXIS_LIMITS, NO_AXIS_LIMITS, + 0, 0, 0, mode); + valc->axisVal[i]=0; + } + + dev->last.numValuators = numAxes; + + if (IsMaster(dev) || /* do not accelerate master or xtest devices */ + IsXTestDevice(dev, NULL)) + InitPointerAccelerationScheme(dev, PtrAccelNoOp); + else + InitPointerAccelerationScheme(dev, PtrAccelDefault); + return TRUE; +} + +/* global list of acceleration schemes */ +ValuatorAccelerationRec pointerAccelerationScheme[] = { + {PtrAccelNoOp, NULL, NULL, NULL}, + {PtrAccelPredictable, acceleratePointerPredictable, NULL, AccelerationDefaultCleanup}, + {PtrAccelLightweight, acceleratePointerLightweight, NULL, NULL}, + {-1, NULL, NULL, NULL} /* terminator */ +}; + +/** + * install an acceleration scheme. returns TRUE on success, and should not + * change anything if unsuccessful. + */ +Bool +InitPointerAccelerationScheme(DeviceIntPtr dev, + int scheme) +{ + int x, i = -1; + void* data = NULL; + ValuatorClassPtr val; + + val = dev->valuator; + + if(!val) + return FALSE; + + if(IsMaster(dev) && scheme != PtrAccelNoOp) + return FALSE; + + for(x = 0; pointerAccelerationScheme[x].number >= 0; x++) { + if(pointerAccelerationScheme[x].number == scheme){ + i = x; + break; + } + } + + if(-1 == i) + return FALSE; + + if (val->accelScheme.AccelCleanupProc) + val->accelScheme.AccelCleanupProc(dev); + + /* init scheme-specific data */ + switch(scheme){ + case PtrAccelPredictable: + { + DeviceVelocityPtr s; + s = malloc(sizeof(DeviceVelocityRec)); + if(!s) + return FALSE; + InitVelocityData(s); + data = s; + break; + } + default: + break; + } + + val->accelScheme = pointerAccelerationScheme[i]; + val->accelScheme.accelData = data; + + /* post-init scheme */ + switch(scheme){ + case PtrAccelPredictable: + InitializePredictableAccelerationProperties(dev); + break; + + default: + break; + } + + return TRUE; +} + +Bool +InitAbsoluteClassDeviceStruct(DeviceIntPtr dev) +{ + AbsoluteClassPtr abs; + + abs = malloc(sizeof(AbsoluteClassRec)); + if (!abs) + return FALSE; + + /* we don't do anything sensible with these, but should */ + abs->min_x = NO_AXIS_LIMITS; + abs->min_y = NO_AXIS_LIMITS; + abs->max_x = NO_AXIS_LIMITS; + abs->max_y = NO_AXIS_LIMITS; + abs->flip_x = 0; + abs->flip_y = 0; + abs->rotation = 0; + abs->button_threshold = 0; + + abs->offset_x = 0; + abs->offset_y = 0; + abs->width = NO_AXIS_LIMITS; + abs->height = NO_AXIS_LIMITS; + abs->following = 0; + abs->screen = 0; + + abs->sourceid = dev->id; + + dev->absolute = abs; + + return TRUE; +} + +Bool +InitFocusClassDeviceStruct(DeviceIntPtr dev) +{ + FocusClassPtr focc; + + focc = malloc(sizeof(FocusClassRec)); + if (!focc) + return FALSE; + focc->win = PointerRootWin; + focc->revert = None; + focc->time = currentTime; + focc->trace = (WindowPtr *)NULL; + focc->traceSize = 0; + focc->traceGood = 0; + focc->sourceid = dev->id; + dev->focus = focc; + return TRUE; +} + +Bool +InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc) +{ + PtrFeedbackPtr feedc; + + feedc = malloc(sizeof(PtrFeedbackClassRec)); + if (!feedc) + return FALSE; + feedc->CtrlProc = controlProc; + feedc->ctrl = defaultPointerControl; + feedc->ctrl.id = 0; + if ( (feedc->next = dev->ptrfeed) ) + feedc->ctrl.id = dev->ptrfeed->ctrl.id + 1; + dev->ptrfeed = feedc; + (*controlProc)(dev, &feedc->ctrl); + return TRUE; +} + + +static LedCtrl defaultLedControl = { + DEFAULT_LEDS, DEFAULT_LEDS_MASK, 0}; + +static BellCtrl defaultBellControl = { + DEFAULT_BELL, + DEFAULT_BELL_PITCH, + DEFAULT_BELL_DURATION, + 0}; + +static IntegerCtrl defaultIntegerControl = { + DEFAULT_INT_RESOLUTION, + DEFAULT_INT_MIN_VALUE, + DEFAULT_INT_MAX_VALUE, + DEFAULT_INT_DISPLAYED, + 0}; + +Bool +InitStringFeedbackClassDeviceStruct ( + DeviceIntPtr dev, StringCtrlProcPtr controlProc, + int max_symbols, int num_symbols_supported, KeySym *symbols) +{ + int i; + StringFeedbackPtr feedc; + + feedc = malloc(sizeof(StringFeedbackClassRec)); + if (!feedc) + return FALSE; + feedc->CtrlProc = controlProc; + feedc->ctrl.num_symbols_supported = num_symbols_supported; + feedc->ctrl.num_symbols_displayed = 0; + feedc->ctrl.max_symbols = max_symbols; + feedc->ctrl.symbols_supported = malloc(sizeof (KeySym) * num_symbols_supported); + feedc->ctrl.symbols_displayed = malloc(sizeof (KeySym) * max_symbols); + if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed) + { + free(feedc->ctrl.symbols_supported); + free(feedc->ctrl.symbols_displayed); + free(feedc); + return FALSE; + } + for (i=0; i<num_symbols_supported; i++) + *(feedc->ctrl.symbols_supported+i) = *symbols++; + for (i=0; i<max_symbols; i++) + *(feedc->ctrl.symbols_displayed+i) = (KeySym) 0; + feedc->ctrl.id = 0; + if ( (feedc->next = dev->stringfeed) ) + feedc->ctrl.id = dev->stringfeed->ctrl.id + 1; + dev->stringfeed = feedc; + (*controlProc)(dev, &feedc->ctrl); + return TRUE; +} + +Bool +InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc, + BellCtrlProcPtr controlProc) +{ + BellFeedbackPtr feedc; + + feedc = malloc(sizeof(BellFeedbackClassRec)); + if (!feedc) + return FALSE; + feedc->CtrlProc = controlProc; + feedc->BellProc = bellProc; + feedc->ctrl = defaultBellControl; + feedc->ctrl.id = 0; + if ( (feedc->next = dev->bell) ) + feedc->ctrl.id = dev->bell->ctrl.id + 1; + dev->bell = feedc; + (*controlProc)(dev, &feedc->ctrl); + return TRUE; +} + +Bool +InitLedFeedbackClassDeviceStruct (DeviceIntPtr dev, LedCtrlProcPtr controlProc) +{ + LedFeedbackPtr feedc; + + feedc = malloc(sizeof(LedFeedbackClassRec)); + if (!feedc) + return FALSE; + feedc->CtrlProc = controlProc; + feedc->ctrl = defaultLedControl; + feedc->ctrl.id = 0; + if ( (feedc->next = dev->leds) ) + feedc->ctrl.id = dev->leds->ctrl.id + 1; + feedc->xkb_sli= NULL; + dev->leds = feedc; + (*controlProc)(dev, &feedc->ctrl); + return TRUE; +} + +Bool +InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr controlProc) +{ + IntegerFeedbackPtr feedc; + + feedc = malloc(sizeof(IntegerFeedbackClassRec)); + if (!feedc) + return FALSE; + feedc->CtrlProc = controlProc; + feedc->ctrl = defaultIntegerControl; + feedc->ctrl.id = 0; + if ( (feedc->next = dev->intfeed) ) + feedc->ctrl.id = dev->intfeed->ctrl.id + 1; + dev->intfeed = feedc; + (*controlProc)(dev, &feedc->ctrl); + return TRUE; +} + +Bool +InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons, Atom* btn_labels, + PtrCtrlProcPtr controlProc, int numMotionEvents, + int numAxes, Atom *axes_labels) +{ + DeviceIntPtr dev = (DeviceIntPtr)device; + + return(InitButtonClassDeviceStruct(dev, numButtons, btn_labels, map) && + InitValuatorClassDeviceStruct(dev, numAxes, axes_labels, + numMotionEvents, Relative) && + InitPtrFeedbackClassDeviceStruct(dev, controlProc)); +} + +/* + * Check if the given buffer contains elements between low (inclusive) and + * high (inclusive) only. + * + * @return TRUE if the device map is invalid, FALSE otherwise. + */ +Bool +BadDeviceMap(BYTE *buff, int length, unsigned low, unsigned high, XID *errval) +{ + int i; + + for (i = 0; i < length; i++) + if (buff[i]) /* only check non-zero elements */ + { + if ((low > buff[i]) || (high < buff[i])) + { + *errval = buff[i]; + return TRUE; + } + } + return FALSE; +} + +int +ProcSetModifierMapping(ClientPtr client) +{ + xSetModifierMappingReply rep; + int rc; + REQUEST(xSetModifierMappingReq); + REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq); + + if (client->req_len != ((stuff->numKeyPerModifier << 1) + + bytes_to_int32(sizeof(xSetModifierMappingReq)))) + return BadLength; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rc = change_modmap(client, PickKeyboard(client), (KeyCode *)&stuff[1], + stuff->numKeyPerModifier); + if (rc == MappingFailed || rc == -1) + return BadValue; + if (rc != Success && rc != MappingSuccess && rc != MappingFailed && + rc != MappingBusy) + return rc; + + rep.success = rc; + + WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep); + return Success; +} + +int +ProcGetModifierMapping(ClientPtr client) +{ + xGetModifierMappingReply rep; + int max_keys_per_mod = 0; + KeyCode *modkeymap = NULL; + REQUEST_SIZE_MATCH(xReq); + + generate_modkeymap(client, PickKeyboard(client), &modkeymap, + &max_keys_per_mod); + + memset(&rep, 0, sizeof(xGetModifierMappingReply)); + rep.type = X_Reply; + rep.numKeyPerModifier = max_keys_per_mod; + rep.sequenceNumber = client->sequence; + /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */ + rep.length = max_keys_per_mod << 1; + + WriteReplyToClient(client, sizeof(xGetModifierMappingReply), &rep); + (void)WriteToClient(client, max_keys_per_mod * 8, (char *) modkeymap); + + free(modkeymap); + + return Success; +} + +int +ProcChangeKeyboardMapping(ClientPtr client) +{ + REQUEST(xChangeKeyboardMappingReq); + unsigned len; + KeySymsRec keysyms; + DeviceIntPtr pDev, tmp; + int rc; + REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); + + len = client->req_len - bytes_to_int32(sizeof(xChangeKeyboardMappingReq)); + if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode)) + return BadLength; + + pDev = PickKeyboard(client); + + if ((stuff->firstKeyCode < pDev->key->xkbInfo->desc->min_key_code) || + (stuff->firstKeyCode > pDev->key->xkbInfo->desc->max_key_code)) { + client->errorValue = stuff->firstKeyCode; + return BadValue; + + } + if (((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) > + pDev->key->xkbInfo->desc->max_key_code) || + (stuff->keySymsPerKeyCode == 0)) { + client->errorValue = stuff->keySymsPerKeyCode; + return BadValue; + } + + keysyms.minKeyCode = stuff->firstKeyCode; + keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1; + keysyms.mapWidth = stuff->keySymsPerKeyCode; + keysyms.map = (KeySym *) &stuff[1]; + + rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); + if (rc != Success) + return rc; + + XkbApplyMappingChange(pDev, &keysyms, stuff->firstKeyCode, + stuff->keyCodes, NULL, client); + + for (tmp = inputInfo.devices; tmp; tmp = tmp->next) { + if (IsMaster(tmp) || tmp->u.master != pDev) + continue; + if (!tmp->key) + continue; + + rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); + if (rc != Success) + continue; + + XkbApplyMappingChange(tmp, &keysyms, stuff->firstKeyCode, + stuff->keyCodes, NULL, client); + } + + return Success; +} + +int +ProcSetPointerMapping(ClientPtr client) +{ + BYTE *map; + int ret; + int i, j; + DeviceIntPtr ptr = PickPointer(client); + xSetPointerMappingReply rep; + REQUEST(xSetPointerMappingReq); + REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq); + + if (client->req_len != + bytes_to_int32(sizeof(xSetPointerMappingReq) + stuff->nElts)) + return BadLength; + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.success = MappingSuccess; + map = (BYTE *)&stuff[1]; + + /* So we're bounded here by the number of core buttons. This check + * probably wants disabling through XFixes. */ + /* MPX: With ClientPointer, we can return the right number of buttons. + * Let's just hope nobody changed ClientPointer between GetPointerMapping + * and SetPointerMapping + */ + if (stuff->nElts != ptr->button->numButtons) { + client->errorValue = stuff->nElts; + return BadValue; + } + + /* Core protocol specs don't allow for duplicate mappings; this check + * almost certainly wants disabling through XFixes too. */ + for (i = 0; i < stuff->nElts; i++) { + for (j = i + 1; j < stuff->nElts; j++) { + if (map[i] && map[i] == map[j]) { + client->errorValue = map[i]; + return BadValue; + } + } + } + + ret = ApplyPointerMapping(ptr, map, stuff->nElts, client); + if (ret == MappingBusy) + rep.success = ret; + else if (ret == -1) + return BadValue; + else if (ret != Success) + return ret; + + WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); + return Success; +} + +int +ProcGetKeyboardMapping(ClientPtr client) +{ + xGetKeyboardMappingReply rep; + DeviceIntPtr kbd = PickKeyboard(client); + XkbDescPtr xkb; + KeySymsPtr syms; + int rc; + REQUEST(xGetKeyboardMappingReq); + REQUEST_SIZE_MATCH(xGetKeyboardMappingReq); + + rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess); + if (rc != Success) + return rc; + + xkb = kbd->key->xkbInfo->desc; + + if ((stuff->firstKeyCode < xkb->min_key_code) || + (stuff->firstKeyCode > xkb->max_key_code)) { + client->errorValue = stuff->firstKeyCode; + return BadValue; + } + if (stuff->firstKeyCode + stuff->count > xkb->max_key_code + 1) { + client->errorValue = stuff->count; + return BadValue; + } + + syms = XkbGetCoreMap(kbd); + if (!syms) + return BadAlloc; + + memset(&rep, 0, sizeof(xGetKeyboardMappingReply)); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.keySymsPerKeyCode = syms->mapWidth; + /* length is a count of 4 byte quantities and KeySyms are 4 bytes */ + rep.length = syms->mapWidth * stuff->count; + WriteReplyToClient(client, sizeof(xGetKeyboardMappingReply), &rep); + client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; + WriteSwappedDataToClient(client, + syms->mapWidth * stuff->count * sizeof(KeySym), + &syms->map[syms->mapWidth * (stuff->firstKeyCode - + syms->minKeyCode)]); + free(syms->map); + free(syms); + + return Success; +} + +int +ProcGetPointerMapping(ClientPtr client) +{ + xGetPointerMappingReply rep; + /* Apps may get different values each time they call GetPointerMapping as + * the ClientPointer could change. */ + DeviceIntPtr ptr = PickPointer(client); + ButtonClassPtr butc = ptr->button; + int rc; + REQUEST_SIZE_MATCH(xReq); + + rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.nElts = (butc) ? butc->numButtons : 0; + rep.length = ((unsigned)rep.nElts + (4-1))/4; + WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep); + if (butc) + WriteToClient(client, (int)rep.nElts, (char *)&butc->map[1]); + return Success; +} + +void +NoteLedState(DeviceIntPtr keybd, int led, Bool on) +{ + KeybdCtrl *ctrl = &keybd->kbdfeed->ctrl; + if (on) + ctrl->leds |= ((Leds)1 << (led - 1)); + else + ctrl->leds &= ~((Leds)1 << (led - 1)); +} + +int +Ones(unsigned long mask) /* HACKMEM 169 */ +{ + unsigned long y; + + y = (mask >> 1) &033333333333; + y = mask - y - ((y >>1) & 033333333333); + return (((y + (y >> 3)) & 030707070707) % 077); +} + +static int +DoChangeKeyboardControl (ClientPtr client, DeviceIntPtr keybd, XID *vlist, + BITS32 vmask) +{ +#define DO_ALL (-1) + KeybdCtrl ctrl; + int t; + int led = DO_ALL; + int key = DO_ALL; + BITS32 index2; + int mask = vmask, i; + XkbEventCauseRec cause; + + ctrl = keybd->kbdfeed->ctrl; + while (vmask) { + index2 = (BITS32) lowbit (vmask); + vmask &= ~index2; + switch (index2) { + case KBKeyClickPercent: + t = (INT8)*vlist; + vlist++; + if (t == -1) { + t = defaultKeyboardControl.click; + } + else if (t < 0 || t > 100) { + client->errorValue = t; + return BadValue; + } + ctrl.click = t; + break; + case KBBellPercent: + t = (INT8)*vlist; + vlist++; + if (t == -1) { + t = defaultKeyboardControl.bell; + } + else if (t < 0 || t > 100) { + client->errorValue = t; + return BadValue; + } + ctrl.bell = t; + break; + case KBBellPitch: + t = (INT16)*vlist; + vlist++; + if (t == -1) { + t = defaultKeyboardControl.bell_pitch; + } + else if (t < 0) { + client->errorValue = t; + return BadValue; + } + ctrl.bell_pitch = t; + break; + case KBBellDuration: + t = (INT16)*vlist; + vlist++; + if (t == -1) + t = defaultKeyboardControl.bell_duration; + else if (t < 0) { + client->errorValue = t; + return BadValue; + } + ctrl.bell_duration = t; + break; + case KBLed: + led = (CARD8)*vlist; + vlist++; + if (led < 1 || led > 32) { + client->errorValue = led; + return BadValue; + } + if (!(mask & KBLedMode)) + return BadMatch; + break; + case KBLedMode: + t = (CARD8)*vlist; + vlist++; + if (t == LedModeOff) { + if (led == DO_ALL) + ctrl.leds = 0x0; + else + ctrl.leds &= ~(((Leds)(1)) << (led - 1)); + } + else if (t == LedModeOn) { + if (led == DO_ALL) + ctrl.leds = ~0L; + else + ctrl.leds |= (((Leds)(1)) << (led - 1)); + } + else { + client->errorValue = t; + return BadValue; + } + + XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client); + XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))), + ctrl.leds, &cause); + ctrl.leds = keybd->kbdfeed->ctrl.leds; + + break; + case KBKey: + key = (KeyCode)*vlist; + vlist++; + if ((KeyCode)key < keybd->key->xkbInfo->desc->min_key_code || + (KeyCode)key > keybd->key->xkbInfo->desc->max_key_code) { + client->errorValue = key; + return BadValue; + } + if (!(mask & KBAutoRepeatMode)) + return BadMatch; + break; + case KBAutoRepeatMode: + i = (key >> 3); + mask = (1 << (key & 7)); + t = (CARD8)*vlist; + vlist++; + if (key != DO_ALL) + XkbDisableComputedAutoRepeats(keybd,key); + if (t == AutoRepeatModeOff) { + if (key == DO_ALL) + ctrl.autoRepeat = FALSE; + else + ctrl.autoRepeats[i] &= ~mask; + } + else if (t == AutoRepeatModeOn) { + if (key == DO_ALL) + ctrl.autoRepeat = TRUE; + else + ctrl.autoRepeats[i] |= mask; + } + else if (t == AutoRepeatModeDefault) { + if (key == DO_ALL) + ctrl.autoRepeat = defaultKeyboardControl.autoRepeat; + else + ctrl.autoRepeats[i] = + (ctrl.autoRepeats[i] & ~mask) | + (defaultKeyboardControl.autoRepeats[i] & mask); + } + else { + client->errorValue = t; + return BadValue; + } + break; + default: + client->errorValue = mask; + return BadValue; + } + } + keybd->kbdfeed->ctrl = ctrl; + + /* The XKB RepeatKeys control and core protocol global autorepeat */ + /* value are linked */ + XkbSetRepeatKeys(keybd, key, keybd->kbdfeed->ctrl.autoRepeat); + + return Success; + +#undef DO_ALL +} + +/** + * Changes kbd control on the ClientPointer and all attached SDs. + */ +int +ProcChangeKeyboardControl (ClientPtr client) +{ + XID *vlist; + BITS32 vmask; + int ret = Success, error = Success; + DeviceIntPtr pDev = NULL, keyboard; + REQUEST(xChangeKeyboardControlReq); + + REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq); + + vmask = stuff->mask; + vlist = (XID *)&stuff[1]; + + if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask)) + return BadLength; + + keyboard = PickKeyboard(client); + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { + if ((pDev == keyboard || + (!IsMaster(pDev) && GetMaster(pDev, MASTER_KEYBOARD) == keyboard)) + && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { + ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); + if (ret != Success) + return ret; + } + } + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { + if ((pDev == keyboard || + (!IsMaster(pDev) && GetMaster(pDev, MASTER_KEYBOARD) == keyboard)) + && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { + ret = DoChangeKeyboardControl(client, pDev, vlist, vmask); + if (ret != Success) + error = ret; + } + } + + return error; +} + +int +ProcGetKeyboardControl (ClientPtr client) +{ + int rc, i; + DeviceIntPtr kbd = PickKeyboard(client); + KeybdCtrl *ctrl = &kbd->kbdfeed->ctrl; + xGetKeyboardControlReply rep; + REQUEST_SIZE_MATCH(xReq); + + rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 5; + rep.sequenceNumber = client->sequence; + rep.globalAutoRepeat = ctrl->autoRepeat; + rep.keyClickPercent = ctrl->click; + rep.bellPercent = ctrl->bell; + rep.bellPitch = ctrl->bell_pitch; + rep.bellDuration = ctrl->bell_duration; + rep.ledMask = ctrl->leds; + for (i = 0; i < 32; i++) + rep.map[i] = ctrl->autoRepeats[i]; + WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep); + return Success; +} + +int +ProcBell(ClientPtr client) +{ + DeviceIntPtr dev, keybd = PickKeyboard(client); + int base = keybd->kbdfeed->ctrl.bell; + int newpercent; + int rc; + REQUEST(xBellReq); + REQUEST_SIZE_MATCH(xBellReq); + + if (stuff->percent < -100 || stuff->percent > 100) { + client->errorValue = stuff->percent; + return BadValue; + } + + newpercent = (base * stuff->percent) / 100; + if (stuff->percent < 0) + newpercent = base + newpercent; + else + newpercent = base - newpercent + stuff->percent; + + for (dev = inputInfo.devices; dev; dev = dev->next) { + if ((dev == keybd || + (!IsMaster(dev) && GetMaster(dev, MASTER_KEYBOARD) == keybd)) && + dev->kbdfeed && dev->kbdfeed->BellProc) { + + rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixBellAccess); + if (rc != Success) + return rc; + XkbHandleBell(FALSE, FALSE, dev, newpercent, + &dev->kbdfeed->ctrl, 0, None, NULL, client); + } + } + + return Success; +} + +int +ProcChangePointerControl(ClientPtr client) +{ + DeviceIntPtr dev, mouse = PickPointer(client); + PtrCtrl ctrl; /* might get BadValue part way through */ + int rc; + REQUEST(xChangePointerControlReq); + REQUEST_SIZE_MATCH(xChangePointerControlReq); + + ctrl = mouse->ptrfeed->ctrl; + if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) { + client->errorValue = stuff->doAccel; + return BadValue; + } + if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) { + client->errorValue = stuff->doThresh; + return BadValue; + } + if (stuff->doAccel) { + if (stuff->accelNum == -1) { + ctrl.num = defaultPointerControl.num; + } + else if (stuff->accelNum < 0) { + client->errorValue = stuff->accelNum; + return BadValue; + } + else { + ctrl.num = stuff->accelNum; + } + + if (stuff->accelDenum == -1) { + ctrl.den = defaultPointerControl.den; + } + else if (stuff->accelDenum <= 0) { + client->errorValue = stuff->accelDenum; + return BadValue; + } + else { + ctrl.den = stuff->accelDenum; + } + } + if (stuff->doThresh) { + if (stuff->threshold == -1) { + ctrl.threshold = defaultPointerControl.threshold; + } + else if (stuff->threshold < 0) { + client->errorValue = stuff->threshold; + return BadValue; + } + else { + ctrl.threshold = stuff->threshold; + } + } + + for (dev = inputInfo.devices; dev; dev = dev->next) { + if ((dev == mouse || + (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) == mouse)) && + dev->ptrfeed) { + rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixManageAccess); + if (rc != Success) + return rc; + } + } + + for (dev = inputInfo.devices; dev; dev = dev->next) { + if ((dev == mouse || + (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) == mouse)) && + dev->ptrfeed) { + dev->ptrfeed->ctrl = ctrl; + } + } + + return Success; +} + +int +ProcGetPointerControl(ClientPtr client) +{ + DeviceIntPtr ptr = PickPointer(client); + PtrCtrl *ctrl = &ptr->ptrfeed->ctrl; + xGetPointerControlReply rep; + int rc; + REQUEST_SIZE_MATCH(xReq); + + rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.threshold = ctrl->threshold; + rep.accelNumerator = ctrl->num; + rep.accelDenominator = ctrl->den; + WriteReplyToClient(client, sizeof(xGenericReply), &rep); + return Success; +} + +void +MaybeStopHint(DeviceIntPtr dev, ClientPtr client) +{ + GrabPtr grab = dev->deviceGrab.grab; + + if ((grab && SameClient(grab, client) && + ((grab->eventMask & PointerMotionHintMask) || + (grab->ownerEvents && + (EventMaskForClient(dev->valuator->motionHintWindow, client) & + PointerMotionHintMask)))) || + (!grab && + (EventMaskForClient(dev->valuator->motionHintWindow, client) & + PointerMotionHintMask))) + dev->valuator->motionHintWindow = NullWindow; +} + +int +ProcGetMotionEvents(ClientPtr client) +{ + WindowPtr pWin; + xTimecoord * coords = (xTimecoord *) NULL; + xGetMotionEventsReply rep; + int i, count, xmin, xmax, ymin, ymax, rc; + unsigned long nEvents; + DeviceIntPtr mouse = PickPointer(client); + TimeStamp start, stop; + REQUEST(xGetMotionEventsReq); + REQUEST_SIZE_MATCH(xGetMotionEventsReq); + + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess); + if (rc != Success) + return rc; + + if (mouse->valuator->motionHintWindow) + MaybeStopHint(mouse, client); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + nEvents = 0; + start = ClientTimeToServerTime(stuff->start); + stop = ClientTimeToServerTime(stuff->stop); + if ((CompareTimeStamps(start, stop) != LATER) && + (CompareTimeStamps(start, currentTime) != LATER) && + mouse->valuator->numMotionEvents) + { + if (CompareTimeStamps(stop, currentTime) == LATER) + stop = currentTime; + count = GetMotionHistory(mouse, &coords, start.milliseconds, + stop.milliseconds, pWin->drawable.pScreen, + TRUE); + xmin = pWin->drawable.x - wBorderWidth (pWin); + xmax = pWin->drawable.x + (int)pWin->drawable.width + + wBorderWidth (pWin); + ymin = pWin->drawable.y - wBorderWidth (pWin); + ymax = pWin->drawable.y + (int)pWin->drawable.height + + wBorderWidth (pWin); + for (i = 0; i < count; i++) + if ((xmin <= coords[i].x) && (coords[i].x < xmax) && + (ymin <= coords[i].y) && (coords[i].y < ymax)) + { + coords[nEvents].time = coords[i].time; + coords[nEvents].x = coords[i].x - pWin->drawable.x; + coords[nEvents].y = coords[i].y - pWin->drawable.y; + nEvents++; + } + } + rep.length = nEvents * bytes_to_int32(sizeof(xTimecoord)); + rep.nEvents = nEvents; + WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep); + if (nEvents) + { + client->pSwapReplyFunc = (ReplySwapPtr) SwapTimeCoordWrite; + WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord), + (char *)coords); + } + free(coords); + return Success; +} + +int +ProcQueryKeymap(ClientPtr client) +{ + xQueryKeymapReply rep; + int rc, i; + DeviceIntPtr keybd = PickKeyboard(client); + CARD8 *down = keybd->key->down; + + REQUEST_SIZE_MATCH(xReq); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 2; + + rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess); + if (rc != Success && rc != BadAccess) + return rc; + + for (i = 0; i<32; i++) + rep.map[i] = down[i]; + + if (rc == BadAccess) + memset(rep.map, 0, 32); + + WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep); + + return Success; +} + + +/** + * Recalculate the number of buttons for the master device. The number of + * buttons on the master device is equal to the number of buttons on the + * slave device with the highest number of buttons. + */ +static void +RecalculateMasterButtons(DeviceIntPtr slave) +{ + DeviceIntPtr dev, master; + int maxbuttons = 0; + + if (!slave->button || IsMaster(slave)) + return; + + master = GetMaster(slave, MASTER_POINTER); + if (!master) + return; + + for (dev = inputInfo.devices; dev; dev = dev->next) + { + if (IsMaster(dev) || + dev->u.master != master || + !dev->button) + continue; + + maxbuttons = max(maxbuttons, dev->button->numButtons); + } + + if (master->button && master->button->numButtons != maxbuttons) + { + int i; + DeviceChangedEvent event; + + memset(&event, 0, sizeof(event)); + + master->button->numButtons = maxbuttons; + + event.header = ET_Internal; + event.type = ET_DeviceChanged; + event.time = GetTimeInMillis(); + event.deviceid = master->id; + event.flags = DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE; + event.buttons.num_buttons = maxbuttons; + memcpy(&event.buttons.names, master->button->labels, maxbuttons * + sizeof(Atom)); + + if (master->valuator) + { + event.num_valuators = master->valuator->numAxes; + for (i = 0; i < event.num_valuators; i++) + { + event.valuators[i].min = master->valuator->axes[i].min_value; + event.valuators[i].max = master->valuator->axes[i].max_value; + event.valuators[i].resolution = master->valuator->axes[i].resolution; + event.valuators[i].mode = master->valuator->axes[i].mode; + event.valuators[i].name = master->valuator->axes[i].label; + } + } + + if (master->key) + { + event.keys.min_keycode = master->key->xkbInfo->desc->min_key_code; + event.keys.max_keycode = master->key->xkbInfo->desc->max_key_code; + } + + XISendDeviceChangedEvent(master, master, &event); + } +} + +/** + * Attach device 'dev' to device 'master'. + * Client is set to the client that issued the request, or NULL if it comes + * from some internal automatic pairing. + * + * Master may be NULL to set the device floating. + * + * We don't allow multi-layer hierarchies right now. You can't attach a slave + * to another slave. + */ +int +AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) +{ + ScreenPtr screen; + DeviceIntPtr oldmaster; + if (!dev || IsMaster(dev)) + return BadDevice; + + if (master && !IsMaster(master)) /* can't attach to slaves */ + return BadDevice; + + /* set from floating to floating? */ + if (!dev->u.master && !master && dev->enabled) + return Success; + + /* free the existing sprite. */ + if (!dev->u.master && dev->spriteInfo->paired == dev) + { + screen = miPointerGetScreen(dev); + screen->DeviceCursorCleanup(dev, screen); + free(dev->spriteInfo->sprite); + } + + oldmaster = dev->u.master; + dev->u.master = master; + + /* If device is set to floating, we need to create a sprite for it, + * otherwise things go bad. However, we don't want to render the cursor, + * so we reset spriteOwner. + * Sprite has to be forced to NULL first, otherwise InitializeSprite won't + * alloc new memory but overwrite the previous one. + */ + if (!master) + { + WindowPtr currentRoot; + + if (dev->spriteInfo->sprite) + currentRoot = GetCurrentRootWindow(dev); + else /* new device auto-set to floating */ + currentRoot = screenInfo.screens[0]->root; + + /* we need to init a fake sprite */ + screen = currentRoot->drawable.pScreen; + screen->DeviceCursorInitialize(dev, screen); + dev->spriteInfo->sprite = NULL; + InitializeSprite(dev, currentRoot); + dev->spriteInfo->spriteOwner = FALSE; + dev->spriteInfo->paired = dev; + } else + { + dev->spriteInfo->sprite = master->spriteInfo->sprite; + dev->spriteInfo->paired = master; + dev->spriteInfo->spriteOwner = FALSE; + + RecalculateMasterButtons(master); + } + + /* XXX: in theory, the MD should change back to its old, original + * classes when the last SD is detached. Thanks to the XTEST devices, + * we'll always have an SD attached until the MD is removed. + * So let's not worry about that. + */ + + return Success; +} + +/** + * Return the device paired with the given device or NULL. + * Returns the device paired with the parent master if the given device is a + * slave device. + */ +DeviceIntPtr +GetPairedDevice(DeviceIntPtr dev) +{ + if (!IsMaster(dev) && dev->u.master) + dev = dev->u.master; + + return dev->spriteInfo->paired; +} + + +/** + * Returns the right master for the type of event needed. If the event is a + * keyboard event. + * This function may be called with a master device as argument. If so, the + * returned master is either the device itself or the paired master device. + * If dev is a floating slave device, NULL is returned. + * + * @type ::MASTER_KEYBOARD or ::MASTER_POINTER + */ +DeviceIntPtr +GetMaster(DeviceIntPtr dev, int which) +{ + DeviceIntPtr master; + + if (IsMaster(dev)) + master = dev; + else + master = dev->u.master; + + if (master) + { + if (which == MASTER_KEYBOARD) + { + if (master->type != MASTER_KEYBOARD) + master = GetPairedDevice(master); + } else + { + if (master->type != MASTER_POINTER) + master = GetPairedDevice(master); + } + } + + return master; +} + +/** + * Create a new device pair (== one pointer, one keyboard device). + * Only allocates the devices, you will need to call ActivateDevice() and + * EnableDevice() manually. + * Either a master or a slave device can be created depending on + * the value for master. + */ +int +AllocDevicePair (ClientPtr client, char* name, + DeviceIntPtr* ptr, + DeviceIntPtr* keybd, + DeviceProc ptr_proc, + DeviceProc keybd_proc, + Bool master) +{ + DeviceIntPtr pointer; + DeviceIntPtr keyboard; + *ptr = *keybd = NULL; + + pointer = AddInputDevice(client, ptr_proc, TRUE); + if (!pointer) + return BadAlloc; + + if (asprintf(&pointer->name, "%s pointer", name) == -1) { + pointer->name = NULL; + RemoveDevice(pointer, FALSE); + return BadAlloc; + } + + pointer->public.processInputProc = ProcessOtherEvent; + pointer->public.realInputProc = ProcessOtherEvent; + XkbSetExtension(pointer, ProcessPointerEvent); + pointer->deviceGrab.ActivateGrab = ActivatePointerGrab; + pointer->deviceGrab.DeactivateGrab = DeactivatePointerGrab; + pointer->coreEvents = TRUE; + pointer->spriteInfo->spriteOwner = TRUE; + + pointer->u.lastSlave = NULL; + pointer->last.slave = NULL; + pointer->type = (master) ? MASTER_POINTER : SLAVE; + + keyboard = AddInputDevice(client, keybd_proc, TRUE); + if (!keyboard) + { + RemoveDevice(pointer, FALSE); + return BadAlloc; + } + + if (asprintf(&keyboard->name, "%s keyboard", name) == -1) { + keyboard->name = NULL; + RemoveDevice(keyboard, FALSE); + RemoveDevice(pointer, FALSE); + return BadAlloc; + } + + keyboard->public.processInputProc = ProcessOtherEvent; + keyboard->public.realInputProc = ProcessOtherEvent; + XkbSetExtension(keyboard, ProcessKeyboardEvent); + keyboard->deviceGrab.ActivateGrab = ActivateKeyboardGrab; + keyboard->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab; + keyboard->coreEvents = TRUE; + keyboard->spriteInfo->spriteOwner = FALSE; + + keyboard->u.lastSlave = NULL; + keyboard->last.slave = NULL; + keyboard->type = (master) ? MASTER_KEYBOARD : SLAVE; + + /* The ClassesRec stores the device classes currently not used. */ + pointer->unused_classes = calloc(1, sizeof(ClassesRec)); + keyboard->unused_classes = calloc(1, sizeof(ClassesRec)); + + *ptr = pointer; + *keybd = keyboard; + + return Success; +} + +/** + * Return Relative or Absolute for the device. + */ +int valuator_get_mode(DeviceIntPtr dev, int axis) +{ + return (dev->valuator->axes[axis].mode & DeviceMode); +} + +/** + * Set the given mode for the axis. If axis is VALUATOR_MODE_ALL_AXES, then + * set the mode for all axes. + */ +void valuator_set_mode(DeviceIntPtr dev, int axis, int mode) +{ + if (axis != VALUATOR_MODE_ALL_AXES) + dev->valuator->axes[axis].mode = mode; + else { + int i; + for (i = 0; i < dev->valuator->numAxes; i++) + dev->valuator->axes[i].mode = mode; + } +} diff --git a/xorg-server/hw/dmx/doc/Makefile.am b/xorg-server/hw/dmx/doc/Makefile.am index 4bbc8bf88..8e7360288 100644 --- a/xorg-server/hw/dmx/doc/Makefile.am +++ b/xorg-server/hw/dmx/doc/Makefile.am @@ -24,34 +24,14 @@ doc_sources = dmx.xml scaled.xml # Developer's documentation is not installed if ENABLE_DEVEL_DOCS include $(top_srcdir)/doc/xml/xmlrules-noinst.in - -if HAVE_DOXYGEN - -DOXYGEN_SRC=doxygen.head doxygen.foot doxygen.css doxygen.conf - -all-local: html/annotated.html - -dist-local: html/annotated.html - -html/annotated.html: $(DOXYGEN_SRC) - $(DOXYGEN) $(srcdir)/doxygen.conf - -maintainer-clean-local: - rm -rf html/ -endif endif ENABLE_DEVEL_DOCS -EXTRA_DIST = \ - $(XML_FILES) \ - DMXSpec.txt \ - DMXSpec-v1.txt \ +DOXYGEN_HEAD=\ + html/annotated.html + +DOXYGEN_REST= \ dmx.txt \ - doxygen.conf \ - doxygen.css \ - doxygen.foot \ - doxygen.head \ scaled.txt \ - html/annotated.html \ html/ChkNotMaskEv_8c.html \ html/ChkNotMaskEv_8h.html \ html/ChkNotMaskEv_8h_source.html \ @@ -254,6 +234,41 @@ EXTRA_DIST = \ html/usb-private_8h.html \ html/usb-private_8h_source.html +DOXYGEN_FILES=$(DOXYGEN_HEAD) $(DOXYGEN_REST) + +EXTRA_DIST = \ + $(XML_FILES) \ + DMXSpec.txt \ + DMXSpec-v1.txt \ + doxygen.conf \ + doxygen.css \ + doxygen.foot \ + doxygen.head \ + $(DOXYGEN_FILES) + +if ENABLE_DEVEL_DOCS +if HAVE_DOXYGEN + +DOXYGEN_SRC=doxygen.head doxygen.foot doxygen.css doxygen.conf + +all-local: $(DOXYGEN_FILES) + +dist-local: $(DOXYGEN_FILES) + +$(DOXYGEN_HEAD): $(DOXYGEN_SRC) + $(DOXYGEN) doxygen.conf + +$(DOXYGEN_REST): $(DOXYGEN_HEAD) + +maintainer-clean-local: + rm -rf html/ scaled.txt dmx.txt + +distclean-local: + rm -rf html/ scaled.txt dmx.txt + +endif HAVE_DOXYGEN +endif ENABLE_DEVEL_DOCS + $(builddir)/doxygen.head: $(LN_S) $(srcdir)/doxygen.head $@ diff --git a/xorg-server/hw/dmx/doc/doxygen.conf b/xorg-server/hw/dmx/doc/doxygen.conf.in index f7a541f90..f886a436f 100644 --- a/xorg-server/hw/dmx/doc/doxygen.conf +++ b/xorg-server/hw/dmx/doc/doxygen.conf.in @@ -344,9 +344,9 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = .. \ - ../input \ - ../config +INPUT = @srcdir@/.. \ + @srcdir@/../input \ + @srcdir@/../config # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp @@ -367,9 +367,9 @@ RECURSIVE = NO # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = ../config/parser.c \ - ../config/parser.h \ - ../config/scanner.c +EXCLUDE = @srcdir@/../config/parser.c \ + @srcdir@/../config/parser.h \ + @srcdir@/../config/scanner.c # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories # that are symbolic links (a Unix filesystem feature) are excluded from the input. @@ -510,20 +510,20 @@ HTML_FILE_EXTENSION = .html # each generated HTML page. If it is left blank doxygen will generate a # standard header. -HTML_HEADER = doxygen.head +HTML_HEADER = @srcdir@/doxygen.head # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = doxygen.foot +HTML_FOOTER = @srcdir@/doxygen.foot # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet -HTML_STYLESHEET = doxygen.css +HTML_STYLESHEET = @srcdir@/doxygen.css # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to diff --git a/xorg-server/hw/xfree86/loader/Makefile.am b/xorg-server/hw/xfree86/loader/Makefile.am index acacda650..7f386ccc0 100644 --- a/xorg-server/hw/xfree86/loader/Makefile.am +++ b/xorg-server/hw/xfree86/loader/Makefile.am @@ -1,29 +1,30 @@ -noinst_LTLIBRARIES = libloader.la
-
-INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(top_srcdir)/miext/cw \
- -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes \
- -I$(srcdir)/../ramdac
-
-#AM_LDFLAGS = -r
-AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
-
-EXTRA_DIST = \
- loader.h \
- loaderProcs.h \
- sdksyms.sh
-
-libloader_la_SOURCES = \
- loader.c \
- loaderProcs.h \
- loadext.c \
- loadmod.c \
- os.c \
- sdksyms.c
-libloader_la_LIBADD = $(DLOPEN_LIBS)
-
-CLEANFILES = sdksyms.c sdksyms.dep
-
-sdksyms.dep sdksyms.c: sdksyms.sh
- CPP='$(CPP)' AWK='$(AWK)' $(srcdir)/sdksyms.sh $(top_srcdir) $(AM_CFLAGS) $(CFLAGS) $(INCLUDES)
-
-sinclude sdksyms.dep
+noinst_LTLIBRARIES = libloader.la + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(top_srcdir)/miext/cw \ + -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes \ + -I$(srcdir)/../ramdac + +#AM_LDFLAGS = -r +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +EXTRA_DIST = \ + loader.h \ + loaderProcs.h \ + sdksyms.sh + +libloader_la_SOURCES = \ + loader.c \ + loaderProcs.h \ + loadext.c \ + loadmod.c \ + os.c \ + sdksyms.c +libloader_la_LIBADD = $(DLOPEN_LIBS) + +CLEANFILES = sdksyms.c sdksyms.dep + +sdksyms.dep sdksyms.c: sdksyms.sh + CPP='$(CPP)' AWK='$(AWK)' $(srcdir)/sdksyms.sh $(top_srcdir) $(AM_CFLAGS) $(CFLAGS) $(INCLUDES) + +SDKSYMS_DEP = sdksyms.dep +include $(SDKSYMS_DEP) diff --git a/xorg-server/hw/xwin/glx/Makefile.am b/xorg-server/hw/xwin/glx/Makefile.am index dae58bf89..303ff53f2 100644 --- a/xorg-server/hw/xwin/glx/Makefile.am +++ b/xorg-server/hw/xwin/glx/Makefile.am @@ -1,60 +1,60 @@ -noinst_LTLIBRARIES = libXwinGLX.la
-
-libXwinGLX_la_SOURCES = \
- winpriv.c \
- winpriv.h \
- glwindows.h \
- glwrap.c \
- indirect.c \
- wgl_ext_api.c
-
-if XWIN_MULTIWINDOW
-DEFS_MULTIWINDOW = -DXWIN_MULTIWINDOW
-endif
-
-if XWIN_MULTIWINDOWEXTWM
-DEFS_MULTIWINDOWEXTWM = -DXWIN_MULTIWINDOWEXTWM
-endif
-
-DEFS = $(DEFS_MULTIWINDOW) $(DEFS_MULTIWINDOWEXTWM)
-
-INCLUDES = -I$(top_srcdir)/miext/rootless
-
-AM_CFLAGS = -DHAVE_XWIN_CONFIG_H $(DIX_CFLAGS) \
- $(XWINMODULES_CFLAGS) \
- -I$(top_srcdir) \
- -I$(top_srcdir)/hw/xwin/
-
-glwrap.c: generated_gl_wrappers.c
-wgl_ext_api.c: generated_wgl_wrappers.c wglext.h
-wgl_ext_api.h: wglext.h
-indirect.c: wgl_ext_api.h
-
-SPEC_FILES = gl.spec gl.tm wglext.spec wgl.tm
-
-gl.spec:
- wget http://www.opengl.org/registry/api/gl.spec
-
-gl.tm:
- wget http://www.opengl.org/registry/api/gl.tm
-
-wglext.spec:
- wget http://www.opengl.org/registry/api/wglext.spec
-
-wgl.tm:
- wget http://www.opengl.org/registry/api/wgl.tm
-
-generated_gl_wrappers.c: gen_gl_wrappers.py gl.spec gl.tm
- $(srcdir)/gen_gl_wrappers.py --spec=$(srcdir)/gl.spec --typemap=$(srcdir)/gl.tm --dispatch-header=$(top_srcdir)/glx/dispatch.h --staticwrappers >generated_gl_wrappers.c
-
-generated_wgl_wrappers.c: gen_gl_wrappers.py wglext.spec wgl.tm
- $(srcdir)/gen_gl_wrappers.py --spec=$(srcdir)/wglext.spec --typemap=$(srcdir)/wgl.tm --prefix=wgl --preresolve >generated_wgl_wrappers.c
-
-wglext.h:
- wget http://www.opengl.org/registry/api/wglext.h
-
-BUILT_SOURCES = generated_gl_wrappers.c generated_wgl_wrappers.c
-CLEANFILES = $(BUILT_SOURCES)
-DISTCLEANFILES = $(SPEC_FILES) wglext.h
-
-EXTRA_DIST = gen_gl_wrappers.py $(SPEC_FILES) wglext.h
+noinst_LTLIBRARIES = libXwinGLX.la + +libXwinGLX_la_SOURCES = \ + winpriv.c \ + winpriv.h \ + glwindows.h \ + glwrap.c \ + indirect.c \ + wgl_ext_api.c + +if XWIN_MULTIWINDOW +DEFS_MULTIWINDOW = -DXWIN_MULTIWINDOW +endif + +if XWIN_MULTIWINDOWEXTWM +DEFS_MULTIWINDOWEXTWM = -DXWIN_MULTIWINDOWEXTWM +endif + +DEFS = $(DEFS_MULTIWINDOW) $(DEFS_MULTIWINDOWEXTWM) + +INCLUDES = -I$(top_srcdir)/miext/rootless + +AM_CFLAGS = -DHAVE_XWIN_CONFIG_H $(DIX_CFLAGS) \ + $(XWINMODULES_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/hw/xwin/ + +glwrap.c: generated_gl_wrappers.c +wgl_ext_api.c: generated_wgl_wrappers.c wglext.h +wgl_ext_api.h: wglext.h +indirect.c: wgl_ext_api.h + +SPEC_FILES = gl.spec gl.tm wglext.spec wgl.tm + +gl.spec: + wget http://www.opengl.org/registry/api/gl.spec + +gl.tm: + wget http://www.opengl.org/registry/api/gl.tm + +wglext.spec: + wget http://www.opengl.org/registry/api/wglext.spec + +wgl.tm: + wget http://www.opengl.org/registry/api/wgl.tm + +generated_gl_wrappers.c: gen_gl_wrappers.py gl.spec gl.tm + $(srcdir)/gen_gl_wrappers.py --spec=`test -e gl.spec || echo $(srcdir)/`gl.spec --typemap=`test -e gl.tm || echo $(srcdir)/`gl.tm --dispatch-header=$(top_srcdir)/glx/dispatch.h --staticwrappers >generated_gl_wrappers.c + +generated_wgl_wrappers.c: gen_gl_wrappers.py wglext.spec wgl.tm + $(srcdir)/gen_gl_wrappers.py --spec=`test -e wglext.spec || echo $(srcdir)/`wglext.spec --typemap=`test -e wgl.tm || echo $(srcdir)/`wgl.tm --prefix=wgl --preresolve >generated_wgl_wrappers.c + +wglext.h: + wget http://www.opengl.org/registry/api/wglext.h + +BUILT_SOURCES = generated_gl_wrappers.c generated_wgl_wrappers.c +CLEANFILES = $(BUILT_SOURCES) +DISTCLEANFILES = $(SPEC_FILES) wglext.h + +EXTRA_DIST = gen_gl_wrappers.py $(SPEC_FILES) wglext.h diff --git a/xorg-server/xkeyboard-config/rules/base.o_s.part b/xorg-server/xkeyboard-config/rules/base.o_s.part index 00634858d..3e23396da 100644 --- a/xorg-server/xkeyboard-config/rules/base.o_s.part +++ b/xorg-server/xkeyboard-config/rules/base.o_s.part @@ -1,142 +1,143 @@ - altwin:menu = +altwin(menu)
- altwin:meta_alt = +altwin(meta_alt)
- altwin:ctrl_win = +altwin(ctrl_win)
- altwin:ctrl_alt_win = +altwin(ctrl_alt_win)
- altwin:meta_win = +altwin(meta_win)
- altwin:left_meta_win = +altwin(left_meta_win)
- altwin:hyper_win = +altwin(hyper_win)
- altwin:alt_super_win = +altwin(alt_super_win)
- altwin:swap_lalt_lwin = +altwin(swap_lalt_lwin)
- grp:switch = +group(switch)
- grp:lswitch = +group(lswitch)
- grp:win_switch = +group(win_switch)
- grp:lwin_switch = +group(lwin_switch)
- grp:rwin_switch = +group(rwin_switch)
- grp:toggle = +group(toggle)
- grp:shifts_toggle = +group(shifts_toggle)
- grp:ctrls_toggle = +group(ctrls_toggle)
- grp:alts_toggle = +group(alts_toggle)
- grp:ctrl_shift_toggle = +group(ctrl_shift_toggle)
- grp:lctrl_lshift_toggle = +group(lctrl_lshift_toggle)
- grp:rctrl_rshift_toggle = +group(rctrl_rshift_toggle)
- grp:caps_toggle = +capslock(grouplock)
- grp:caps_switch = +capslock(groupshift)
- grp:shift_caps_toggle = +group(shift_caps_toggle)
- grp:shift_caps_switch = +group(shift_caps_switch)
- grp:win_menu_switch = +group(win_menu_switch)
- grp:alt_caps_toggle = +group(alt_caps_toggle)
- grp:ctrl_alt_toggle = +group(ctrl_alt_toggle)
- grp:alt_shift_toggle = +group(alt_shift_toggle)
- grp:alt_space_toggle = +group(alt_space_toggle)
- grp:menu_toggle = +group(menu_toggle)
- grp:lwin_toggle = +group(lwin_toggle)
- grp:rwin_toggle = +group(rwin_toggle)
- grp:lshift_toggle = +group(lshift_toggle)
- grp:rshift_toggle = +group(rshift_toggle)
- grp:rctrl_switch = +group(rctrl_switch)
- grp:lctrl_toggle = +group(lctrl_toggle)
- grp:rctrl_toggle = +group(rctrl_toggle)
- grp:lalt_toggle = +group(lalt_toggle)
- grp:sclk_toggle = +group(sclk_toggle)
- grp:lctrl_rctrl_switch = +group(lctrl_rctrl_switch)
- grp:lctrl_lwin_rctrl_menu = +group(lctrl_lwin_rctrl_menu)
- lv3:switch = +level3(switch)
- lv3:ralt_switch = +level3(ralt_switch)
- lv3:ralt_switch_multikey = +level3(ralt_switch_multikey)
- lv3:ralt_alt = +level3(ralt_alt)
- lv3:lalt_switch = +level3(lalt_switch)
- lv3:alt_switch = +level3(alt_switch)
- lv3:menu_switch = +level3(menu_switch)
- lv3:win_switch = +level3(win_switch)
- lv3:lwin_switch = +level3(lwin_switch)
- lv3:rwin_switch = +level3(rwin_switch)
- lv3:enter_switch = +level3(enter_switch)
- caps:capslock = +capslock(capslock)
- caps:numlock = +capslock(numlock)
- caps:shiftlock = +capslock(shiftlock)
- caps:swapescape = +capslock(swapescape)
- caps:escape = +capslock(escape)
- caps:backspace = +capslock(backspace)
- caps:super = +capslock(super)
- caps:hyper = +capslock(hyper)
- caps:none = +capslock(none)
- ctrl:nocaps = +ctrl(nocaps)
- ctrl:lctrl_meta = +ctrl(lctrl_meta)
- ctrl:swapcaps = +ctrl(swapcaps)
- ctrl:ctrl_ac = +ctrl(ctrl_ac)
- ctrl:ctrl_aa = +ctrl(ctrl_aa)
- ctrl:ctrl_ra = +ctrl(ctrl_ra)
- ctrl:ctrl_menu = +ctrl(ctrl_menu)
- compose:ralt = +compose(ralt)
- compose:lwin = +compose(lwin)
- compose:rwin = +compose(rwin)
- compose:menu = +compose(menu)
- compose:lctrl = +compose(lctrl)
- compose:rctrl = +compose(rctrl)
- compose:caps = +compose(caps)
- compose:102 = +compose(102)
- compose:paus = +compose(paus)
- compose:prsc = +compose(prsc)
- compose:sclk = +compose(sclk)
- srvrkeys:none = +srvr_ctrl(no_srvr_keys)
- eurosign:e = +eurosign(e)
- eurosign:2 = +eurosign(2)
- eurosign:4 = +eurosign(4)
- eurosign:5 = +eurosign(5)
- rupeesign:4 = +rupeesign(4)
- keypad:oss = +keypad(oss)
- keypad:legacy = +keypad(legacy)
- keypad:legacy_wang = +keypad(legacy_wang)
- keypad:oss_wang = +keypad(oss_wang)
- keypad:future = +keypad(future)
- keypad:future_wang = +keypad(future_wang)
- keypad:hex = +keypad(ops)+keypad(hex)
- keypad:atm = +keypad(ops)+keypad(hex)+keypad(atm)
- nbsp:none = +nbsp(none)
- nbsp:level2 = +nbsp(level2)
- nbsp:level3 = +nbsp(level3)
- nbsp:level3s = +nbsp(level3s)
- nbsp:level3n = +nbsp(level3n)
- nbsp:level4 = +nbsp(level4)
- nbsp:level4n = +nbsp(level4n)
- nbsp:level4nl = +nbsp(level4nl)
- japan:nicola_f_bs = +jp(nicola_f_bs)
- kpdl:dot = +kpdl(dot)
- kpdl:comma = +kpdl(comma)
- kpdl:dotoss = +kpdl(dotoss)
- kpdl:dotoss_latin9 = +kpdl(dotoss_latin9)
- kpdl:commaoss = +kpdl(commaoss)
- kpdl:momayyezoss = +kpdl(momayyezoss)
- kpdl:kposs = +kpdl(kposs)
- kpdl:semi = +kpdl(semi)
- shift:breaks_caps = +shift(breaks_caps)
- esperanto:qwerty = +epo(qwerty)
- esperanto:dvorak = +epo(dvorak)
- terminate:ctrl_alt_bksp = +terminate(ctrl_alt_bksp)
- keypad:pointerkeys = +keypad(pointerkeys)
- apple:alupckeys = +macintosh_vndr/apple(alupckeys)
- shift:both_capslock = +shift(both_capslock)
- shift:lshift_both_capslock = +shift(lshift_both_capslock)
- shift:rshift_both_capslock = +shift(rshift_both_capslock)
- shift:both_capslock_cancel = +shift(both_capslock_cancel)
- shift:lshift_both_capslock_cancel = +shift(lshift_both_capslock_cancel)
- shift:rshift_both_capslock_cancel = +shift(rshift_both_capslock_cancel)
- shift:both_shiftlock = +shift(both_shiftlock)
- shift:lshift_both_shiftlock = +shift(lshift_both_shiftlock)
- shift:rshift_both_shiftlock = +shift(rshift_both_shiftlock)
- lv3:caps_switch = +level3(caps_switch)
- lv3:bksl_switch = +level3(bksl_switch)
- lv3:lsgt_switch = +level3(lsgt_switch)
- lv3:caps_switch_latch = +level3(caps_switch_latch)
- lv3:bksl_switch_latch = +level3(bksl_switch_latch)
- lv3:lsgt_switch_latch = +level3(lsgt_switch_latch)
- lv5:lsgt_switch_lock = +level5(lsgt_switch_lock)
- lv5:ralt_switch_lock = +level5(ralt_switch_lock)
- lv5:lwin_switch_lock = +level5(lwin_switch_lock)
- lv5:rwin_switch_lock = +level5(rwin_switch_lock)
- lv5:lsgt_switch_lock_cancel = +level5(lsgt_switch_lock_cancel)
- lv5:ralt_switch_lock_cancel = +level5(ralt_switch_lock_cancel)
- lv5:lwin_switch_lock_cancel = +level5(lwin_switch_lock_cancel)
- lv5:rwin_switch_lock_cancel = +level5(rwin_switch_lock_cancel)
-
-
+ altwin:menu = +altwin(menu) + altwin:meta_alt = +altwin(meta_alt) + altwin:ctrl_win = +altwin(ctrl_win) + altwin:ctrl_alt_win = +altwin(ctrl_alt_win) + altwin:meta_win = +altwin(meta_win) + altwin:left_meta_win = +altwin(left_meta_win) + altwin:hyper_win = +altwin(hyper_win) + altwin:alt_super_win = +altwin(alt_super_win) + altwin:swap_lalt_lwin = +altwin(swap_lalt_lwin) + grp:switch = +group(switch) + grp:lswitch = +group(lswitch) + grp:win_switch = +group(win_switch) + grp:lwin_switch = +group(lwin_switch) + grp:rwin_switch = +group(rwin_switch) + grp:toggle = +group(toggle) + grp:shifts_toggle = +group(shifts_toggle) + grp:ctrls_toggle = +group(ctrls_toggle) + grp:alts_toggle = +group(alts_toggle) + grp:ctrl_shift_toggle = +group(ctrl_shift_toggle) + grp:lctrl_lshift_toggle = +group(lctrl_lshift_toggle) + grp:rctrl_rshift_toggle = +group(rctrl_rshift_toggle) + grp:caps_toggle = +capslock(grouplock) + grp:caps_switch = +capslock(groupshift) + grp:shift_caps_toggle = +group(shift_caps_toggle) + grp:shift_caps_switch = +group(shift_caps_switch) + grp:win_menu_switch = +group(win_menu_switch) + grp:alt_caps_toggle = +group(alt_caps_toggle) + grp:ctrl_alt_toggle = +group(ctrl_alt_toggle) + grp:alt_shift_toggle = +group(alt_shift_toggle) + grp:alt_space_toggle = +group(alt_space_toggle) + grp:menu_toggle = +group(menu_toggle) + grp:lwin_toggle = +group(lwin_toggle) + grp:rwin_toggle = +group(rwin_toggle) + grp:lshift_toggle = +group(lshift_toggle) + grp:rshift_toggle = +group(rshift_toggle) + grp:rctrl_switch = +group(rctrl_switch) + grp:lctrl_toggle = +group(lctrl_toggle) + grp:rctrl_toggle = +group(rctrl_toggle) + grp:lalt_toggle = +group(lalt_toggle) + grp:sclk_toggle = +group(sclk_toggle) + grp:lctrl_rctrl_switch = +group(lctrl_rctrl_switch) + grp:lctrl_lwin_rctrl_menu = +group(lctrl_lwin_rctrl_menu) + lv3:switch = +level3(switch) + lv3:ralt_switch = +level3(ralt_switch) + lv3:ralt_switch_multikey = +level3(ralt_switch_multikey) + lv3:ralt_alt = +level3(ralt_alt) + lv3:lalt_switch = +level3(lalt_switch) + lv3:alt_switch = +level3(alt_switch) + lv3:menu_switch = +level3(menu_switch) + lv3:win_switch = +level3(win_switch) + lv3:lwin_switch = +level3(lwin_switch) + lv3:rwin_switch = +level3(rwin_switch) + lv3:enter_switch = +level3(enter_switch) + caps:capslock = +capslock(capslock) + caps:numlock = +capslock(numlock) + caps:shiftlock = +capslock(shiftlock) + caps:swapescape = +capslock(swapescape) + caps:escape = +capslock(escape) + caps:backspace = +capslock(backspace) + caps:super = +capslock(super) + caps:hyper = +capslock(hyper) + caps:none = +capslock(none) + caps:ctrl_modifier = +capslock(ctrl_modifier) + ctrl:nocaps = +ctrl(nocaps) + ctrl:lctrl_meta = +ctrl(lctrl_meta) + ctrl:swapcaps = +ctrl(swapcaps) + ctrl:ctrl_ac = +ctrl(ctrl_ac) + ctrl:ctrl_aa = +ctrl(ctrl_aa) + ctrl:ctrl_ra = +ctrl(ctrl_ra) + ctrl:ctrl_menu = +ctrl(ctrl_menu) + compose:ralt = +compose(ralt) + compose:lwin = +compose(lwin) + compose:rwin = +compose(rwin) + compose:menu = +compose(menu) + compose:lctrl = +compose(lctrl) + compose:rctrl = +compose(rctrl) + compose:caps = +compose(caps) + compose:102 = +compose(102) + compose:paus = +compose(paus) + compose:prsc = +compose(prsc) + compose:sclk = +compose(sclk) + srvrkeys:none = +srvr_ctrl(no_srvr_keys) + eurosign:e = +eurosign(e) + eurosign:2 = +eurosign(2) + eurosign:4 = +eurosign(4) + eurosign:5 = +eurosign(5) + rupeesign:4 = +rupeesign(4) + keypad:oss = +keypad(oss) + keypad:legacy = +keypad(legacy) + keypad:legacy_wang = +keypad(legacy_wang) + keypad:oss_wang = +keypad(oss_wang) + keypad:future = +keypad(future) + keypad:future_wang = +keypad(future_wang) + keypad:hex = +keypad(ops)+keypad(hex) + keypad:atm = +keypad(ops)+keypad(hex)+keypad(atm) + nbsp:none = +nbsp(none) + nbsp:level2 = +nbsp(level2) + nbsp:level3 = +nbsp(level3) + nbsp:level3s = +nbsp(level3s) + nbsp:level3n = +nbsp(level3n) + nbsp:level4 = +nbsp(level4) + nbsp:level4n = +nbsp(level4n) + nbsp:level4nl = +nbsp(level4nl) + japan:nicola_f_bs = +jp(nicola_f_bs) + kpdl:dot = +kpdl(dot) + kpdl:comma = +kpdl(comma) + kpdl:dotoss = +kpdl(dotoss) + kpdl:dotoss_latin9 = +kpdl(dotoss_latin9) + kpdl:commaoss = +kpdl(commaoss) + kpdl:momayyezoss = +kpdl(momayyezoss) + kpdl:kposs = +kpdl(kposs) + kpdl:semi = +kpdl(semi) + shift:breaks_caps = +shift(breaks_caps) + esperanto:qwerty = +epo(qwerty) + esperanto:dvorak = +epo(dvorak) + terminate:ctrl_alt_bksp = +terminate(ctrl_alt_bksp) + keypad:pointerkeys = +keypad(pointerkeys) + apple:alupckeys = +macintosh_vndr/apple(alupckeys) + shift:both_capslock = +shift(both_capslock) + shift:lshift_both_capslock = +shift(lshift_both_capslock) + shift:rshift_both_capslock = +shift(rshift_both_capslock) + shift:both_capslock_cancel = +shift(both_capslock_cancel) + shift:lshift_both_capslock_cancel = +shift(lshift_both_capslock_cancel) + shift:rshift_both_capslock_cancel = +shift(rshift_both_capslock_cancel) + shift:both_shiftlock = +shift(both_shiftlock) + shift:lshift_both_shiftlock = +shift(lshift_both_shiftlock) + shift:rshift_both_shiftlock = +shift(rshift_both_shiftlock) + lv3:caps_switch = +level3(caps_switch) + lv3:bksl_switch = +level3(bksl_switch) + lv3:lsgt_switch = +level3(lsgt_switch) + lv3:caps_switch_latch = +level3(caps_switch_latch) + lv3:bksl_switch_latch = +level3(bksl_switch_latch) + lv3:lsgt_switch_latch = +level3(lsgt_switch_latch) + lv5:lsgt_switch_lock = +level5(lsgt_switch_lock) + lv5:ralt_switch_lock = +level5(ralt_switch_lock) + lv5:lwin_switch_lock = +level5(lwin_switch_lock) + lv5:rwin_switch_lock = +level5(rwin_switch_lock) + lv5:lsgt_switch_lock_cancel = +level5(lsgt_switch_lock_cancel) + lv5:ralt_switch_lock_cancel = +level5(ralt_switch_lock_cancel) + lv5:lwin_switch_lock_cancel = +level5(lwin_switch_lock_cancel) + lv5:rwin_switch_lock_cancel = +level5(rwin_switch_lock_cancel) + + diff --git a/xorg-server/xkeyboard-config/rules/base.xml.in b/xorg-server/xkeyboard-config/rules/base.xml.in index 3578100ee..ef97ab8d2 100644 --- a/xorg-server/xkeyboard-config/rules/base.xml.in +++ b/xorg-server/xkeyboard-config/rules/base.xml.in @@ -1394,14 +1394,14 @@ </variant> <variant> <configItem> - <name>olpc-fa</name> + <name>fa-olpc</name> <_description>OLPC Dari</_description> <!-- No ISO code in ISO639-2, only draft ISO693-3 --> </configItem> </variant> <variant> <configItem> - <name>olpc-uz</name> + <name>uz-olpc</name> <_description>OLPC Southern Uzbek</_description> <languageList><iso639Id>uzb</iso639Id></languageList> </configItem> @@ -5295,6 +5295,12 @@ <_description>Caps Lock is disabled</_description> </configItem> </option> + <option> + <configItem> + <name>caps:ctrl_modifier</name> + <_description>Make Caps Lock an additional Control but keep the Caps_Lock keysym</_description> + </configItem> + </option> </group> <group allowMultipleSelection="false"> <!-- Using special PC keys (Win, Menu) to work as standard X keys (Super, Hyper, etc.) --> diff --git a/xorg-server/xkeyboard-config/symbols/af b/xorg-server/xkeyboard-config/symbols/af index 90bfe127d..d7d866d34 100644 --- a/xorg-server/xkeyboard-config/symbols/af +++ b/xorg-server/xkeyboard-config/symbols/af @@ -1,397 +1,397 @@ -//
-// Keymap for the Afghan dari keybord layout
-// Based on the specification "Computer Locale Requirements for
-// Afghanstan" [1] from the "United Nations Development Programme
-// Afghanistan" and the "Afghan Transitional Islamic
-// Administration Ministry of Communications".
-// [1] http://www.evertype.com/standards/af/
-// For a MINI HOWTO see [2].
-// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php
-//
-// 2006-02-15 file created by M. Emal Alekozai <memala@gmx.net>
-
-partial default alphanumeric_keys
-xkb_symbols "basic" {
- //name[Group1]= "Afghanistan Dari";
- name[Group1]= "Afghanistan";
-
- key <TLDE> { [ 0x100200d, 0x10000f7, dead_tilde ] };
- key <AE01> { [ 0x10006f1, exclam, 0x1000060 ] };
- key <AE02> { [ 0x10006f2, 0x100066c, 0x1000040 ] };
- key <AE03> { [ 0x10006f3, 0x100066b, numbersign ] };
- key <AE04> { [ 0x10006f4, 0x100e60b, 0x1000024] };
- key <AE05> { [ 0x10006f5, 0x100066a, 0x1000025 ] };
- key <AE06> { [ 0x10006f6, multiply, 0x100005e ] };
- key <AE07> { [ 0x10006f7, Arabic_comma, 0x1000026 ] };
- key <AE08> { [ 0x10006f8, asterisk, 0x1002022 ] };
- key <AE09> { [ 0x10006f9, 0x1000029, 0x100200e ] };
- key <AE10> { [ 0x10006f0, 0x1000028, 0x100200f ] };
- key <AE11> { [ minus, Arabic_tatweel, 0x100005f ] };
- key <AE12> { [ plus, equal ] };
-
- key <AD01> { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] };
- key <AD02> { [ Arabic_sad, Arabic_dammatan ] };
- key <AD03> { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] };
- key <AD04> { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] };
- key <AD05> { [ Arabic_feh, Arabic_damma, 0x100fd3f ] };
- key <AD06> { [ Arabic_ghain, Arabic_kasra, 0x100e656] };
- key <AD07> { [ Arabic_ain, Arabic_fatha, 0x100e659] };
- key <AD08> { [ Arabic_heh, Arabic_shadda, 0x1000655] };
- key <AD09> { [ Arabic_khah, bracketright, 0x1000027] };
- key <AD10> { [ Arabic_hah, bracketleft, 0x1000022] };
- key <AD11> { [ Arabic_jeem, braceright, 0x1000681 ] };
- key <AD12> { [ 0x1000686, braceleft, 0x1000685 ] };
-
- key <AC01> { [ Arabic_sheen, Arabic_hamzaonwaw, 0x100069a ] };
- key <AC02> { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006cd ] };
- key <AC03> { [ 0x10006cc, Arabic_yeh, 0x1000649 ] };
- key <AC04> { [ Arabic_beh, Arabic_hamzaunderalef, 0x10006d0 ] };
- key <AC05> { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] };
- key <AC06> { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] };
- key <AC07> { [ Arabic_teh, Arabic_tehmarbuta, 0x100067c ] };
- key <AC08> { [ Arabic_noon, 0x10000bb, 0x10006bc ] };
- key <AC09> { [ Arabic_meem, 0x10000ab, 0x10006ba ] };
- key <AC10> { [ 0x10006a9, colon, 0x100003b ] };
- key <AC11> { [ 0x10006af, Arabic_semicolon, 0x10006ab ] };
-
- key <BKSL> { [ backslash, bar, 0x100003f ] };
-
- key <AB01> { [ Arabic_zah, Arabic_kaf, 0x10006d2] };
- key <AB02> { [ Arabic_tah, 0x1000653 , 0x1000691 ] };
- key <AB03> { [ Arabic_zain, 0x1000698, 0x1000696 ] };
- key <AB04> { [ Arabic_ra, 0x1000670 , 0x1000693 ] };
- key <AB05> { [ Arabic_thal, 0x100200c, 0x1000688 ] };
- key <AB06> { [ Arabic_dal, 0x1000654, 0x1000689 ] };
- key <AB07> { [ 0x100067e, Arabic_hamza, 0x1000679 ] };
- key <AB08> { [ Arabic_waw, greater, 0x100002c ] };
- key <AB09> { [ period, less, 0x10006c7 ] };
- key <AB10> { [ slash, Arabic_question_mark, 0x10006c9 ] };
-
- include "nbsp(zwnj2nb3)"
- include "level3(ralt_switch)"
-};
-
-// Keymap for the Afghan pashto keybord layout
-// Based on the specification "Computer Locale Requirements for
-// Afghanstan" [1] from the "United Nations Development Programme
-// Afghanistan"" and the "Afghan Transitional Islamic
-// Administration Ministry of Communications".
-// [1] http://www.evertype.com/standards/af/
-// For a MINI HOWTO see [2].
-// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php
-//
-// 2006-02-15 file created by M. Emal Alekozai <memala@gmx.net>
-
-partial alphanumeric_keys
-xkb_symbols "ps" {
- name[Group1]= "Afghanistan - Pashto";
-
- key <TLDE> { [ 0x100200d, 0x10000f7, dead_tilde ] };
- key <AE01> { [ 0x10006f1, exclam, 0x1000060 ] };
- key <AE02> { [ 0x10006f2, 0x100066c, 0x1000040 ] };
- key <AE03> { [ 0x10006f3, 0x100066b, numbersign ] };
- key <AE04> { [ 0x10006f4, 0x100e60b, 0x1000024] };
- key <AE05> { [ 0x10006f5, 0x100066a, 0x1000025 ] };
- key <AE06> { [ 0x10006f6, multiply, 0x100005e ] };
- key <AE07> { [ 0x10006f7, 0x10000bb, 0x1000026 ] };
- key <AE08> { [ 0x10006f8, 0x10000ab, 0x1002022 ] };
- key <AE09> { [ 0x10006f9, 0x1000029, 0x100200e ] };
- key <AE10> { [ 0x10006f0, 0x1000028, 0x100200f ] };
- key <AE11> { [ minus, Arabic_tatweel, 0x100005f ] };
- key <AE12> { [ plus, equal ] };
-
- key <AD01> { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] };
- key <AD02> { [ Arabic_sad, Arabic_dammatan, 0x1000653 ] };
- key <AD03> { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] };
- key <AD04> { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] };
- key <AD05> { [ Arabic_feh, Arabic_damma, 0x100fd3f ] };
- key <AD06> { [ Arabic_ghain, Arabic_kasra, 0x100e656] };
- key <AD07> { [ Arabic_ain, Arabic_fatha, 0x100e659] };
- key <AD08> { [ Arabic_heh, Arabic_shadda, 0x1000670] };
- key <AD09> { [ Arabic_khah, 0x1000681, 0x1000027] };
- key <AD10> { [ Arabic_hah, 0x1000685, 0x1000022] };
- key <AD11> { [ Arabic_jeem, 0x100005d, 0x100007d ] };
- key <AD12> { [ 0x1000686, 0x100005b, 0x100007b ] };
-
- key <AC01> { [ Arabic_sheen, 0x100069a ] };
- key <AC02> { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006d2 ] };
- key <AC03> { [ 0x10006cc, Arabic_yeh, 0x1000649 ] };
- key <AC04> { [ Arabic_beh, 0x100067e, 0x10006ba ] };
- key <AC05> { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] };
- key <AC06> { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] };
- key <AC07> { [ Arabic_teh, 0x100067c, 0x1000679 ] };
- key <AC08> { [ Arabic_noon, 0x10006bc, 0x100003e ] };
- key <AC09> { [ Arabic_meem, 0x1000629, 0x100003c ] };
- key <AC10> { [ 0x10006a9, colon, 0x1000643 ] };
- key <AC11> { [ 0x10006ab, Arabic_semicolon, 0x10006af ] };
-
- key <BKSL> { [ backslash, 0x100002a, 0x100007c ] };
-
- key <AB01> { [ 0x10006cd, 0x1000638, 0x100003f] };
- key <AB02> { [ 0x10006d0, 0x1000637, 0x100003b ] };
- key <AB03> { [ Arabic_zain, 0x1000698, 0x1000655 ] };
- key <AB04> { [ Arabic_ra, 0x1000621, 0x1000654 ] };
- key <AB05> { [ Arabic_thal, 0x100200c, 0x1000625 ] };
- key <AB06> { [ Arabic_dal, 0x1000689, 0x1000688 ] };
- key <AB07> { [ 0x1000693, 0x1000624, 0x1000691 ] };
- key <AB08> { [ Arabic_waw, 0x100060c, 0x100002c ] };
- key <AB09> { [ 0x1000696, 0x100002e, 0x10006c7 ] };
- key <AB10> { [ slash, Arabic_question_mark, 0x10006c9 ] };
-
- include "nbsp(zwnj2nb3)"
- include "level3(ralt_switch)"
-};
-
-// Keymap for the Afghan southern uzbek keybord layout
-// Based on the specification "Computer Locale Requirements for
-// Afghanstan" [1] from the "United Nations Development Programme
-// Afghanistan"" and the "Afghan Transitional Islamic
-// Administration Ministry of Communications".
-// [1] http://www.evertype.com/standards/af/
-// For a MINI HOWTO see [2].
-// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php
-//
-// 2006-02-15 file created by M. Emal Alekozai <memala@gmx.net>
-
-partial alphanumeric_keys
-xkb_symbols "uz" {
- name[Group1]= "Afghanistan - Southern Uzbek";
-
- key <TLDE> { [ 0x100200d, 0x10000f7, dead_tilde ] };
- key <AE01> { [ 0x10006f1, exclam, 0x1000060 ] };
- key <AE02> { [ 0x10006f2, 0x100066c, 0x1000040 ] };
- key <AE03> { [ 0x10006f3, 0x100066b, numbersign ] };
- key <AE04> { [ 0x10006f4, 0x100e60b, 0x1000024] };
- key <AE05> { [ 0x10006f5, 0x100066a, 0x1000025 ] };
- key <AE06> { [ 0x10006f6, multiply, 0x100005e ] };
- key <AE07> { [ 0x10006f7, Arabic_comma, 0x1000026 ] };
- key <AE08> { [ 0x10006f8, asterisk, 0x1002022 ] };
- key <AE09> { [ 0x10006f9, 0x1000029, 0x100200e ] };
- key <AE10> { [ 0x10006f0, 0x1000028, 0x100200f ] };
- key <AE11> { [ minus, Arabic_tatweel, 0x100005f ] };
- key <AE12> { [ plus, equal ] };
-
- key <AD01> { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] };
- key <AD02> { [ Arabic_sad, Arabic_dammatan, 0x1000653 ] };
- key <AD03> { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] };
- key <AD04> { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] };
- key <AD05> { [ Arabic_feh, Arabic_damma, 0x100fd3f ] };
- key <AD06> { [ Arabic_ghain, Arabic_kasra, 0x100e656] };
- key <AD07> { [ Arabic_ain, Arabic_fatha, 0x100e659] };
- key <AD08> { [ Arabic_heh, Arabic_shadda, 0x1000670] };
- key <AD09> { [ Arabic_khah, bracketright, 0x1000027] };
- key <AD10> { [ Arabic_hah, bracketleft, 0x1000022] };
- key <AD11> { [ Arabic_jeem, braceright, 0x1000681 ] };
- key <AD12> { [ 0x1000686, braceleft, 0x1000685 ] };
-
- key <AC01> { [ Arabic_sheen, Arabic_hamzaonwaw, 0x100069a ] };
- key <AC02> { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006cd ] };
- key <AC03> { [ 0x10006cc, Arabic_yeh, 0x1000649 ] };
- key <AC04> { [ Arabic_beh, 0x10006d0, 0x1000643 ] };
- key <AC05> { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] };
- key <AC06> { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] };
- key <AC07> { [ Arabic_teh, Arabic_tehmarbuta, 0x100067c ] };
- key <AC08> { [ Arabic_noon, 0x10000bb, 0x10006bc ] };
- key <AC09> { [ Arabic_meem, 0x10000ab, 0x10006ba ] };
- key <AC10> { [ 0x10006a9, colon, 0x100003b ] };
- key <AC11> { [ 0x10006af, Arabic_semicolon, 0x10006ab ] };
-
- key <BKSL> { [ backslash, bar, 0x100003f ] };
-
- key <AB01> { [ Arabic_zah, 0x10006c9, 0x10006d2] };
- key <AB02> { [ Arabic_tah, 0x10006c7, 0x1000691 ] };
- key <AB03> { [ Arabic_zain, 0x1000698, 0x1000696 ] };
- key <AB04> { [ Arabic_ra, 0x1000625, 0x1000693 ] };
- key <AB05> { [ Arabic_thal, 0x100200c, 0x1000688 ] };
- key <AB06> { [ Arabic_dal, 0x1000654, 0x1000689 ] };
- key <AB07> { [ 0x100067e, Arabic_hamza, 0x1000679 ] };
- key <AB08> { [ Arabic_waw, greater, 0x100002c ] };
- key <AB09> { [ period, less ] };
- key <AB10> { [ slash, Arabic_question_mark, 0x1000655 ] };
-
- include "nbsp(zwnj2nb3)"
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc-ps" {
-
- name[Group1]= "Afghanistan - OLPC Pashto";
-
- key <TLDE> { [ 0x100200D, 0x1000654, grave ] }; // zero width joiner, Arabic hamza above
- key <AE01> { [ 0x10006F1, exclam, asciitilde ] }; // Arabic one
- key <AE02> { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator
- key <AE03> { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator
- key <AE04> { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign
- key <AE05> { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign
- key <AE06> { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six
- key <AE07> { [ 0x10006F7, guillemotright, ampersand ] }; // Arabic seven
- key <AE08> { [ 0x10006F8, guillemotleft, 0x100066D ] }; // Arabic eight, Arabic five-pointed star
- key <AE09> { [ 0x10006F9, parenright, enfilledcircbullet ] }; // Arabic nine
- key <AE10> { [ 0x10006F0, parenleft, degree ] }; // Arabic zero
- key <AE11> { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel
- key <AE12> { [ plus, equal, division ] };
-
- key <AD01> { [ 0x1000636, 0x1000652, EuroSign ] }; // Arabic dad, Arabic sukun
- key <AD02> { [ 0x1000635, 0x100064C, 0x1000671 ] }; // Arabic sad, Arabic dammatan, Arabic alef walsa
- key <AD03> { [ 0x100062B, 0x100064D, 0x1000649 ] }; // Arabic theh, Arabic kasratan, Arabic alef maksura initial form
- key <AD04> { [ 0x1000642, 0x100064B, 0x100200E ] }; // Arabic qaf, Arabic fathatan, left-to-right mark
- key <AD05> { [ 0x1000641, 0x100064F, 0x100200F ] }; // Arabic feh, Arabic damma, right-to-left mark
- key <AD06> { [ 0x100063A, 0x1000650, 0x100e653 ] }; // Arabic ghain, Arabic kasra, Arabic alef with madda above
- key <AD07> { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay
- key <AD08> { [ 0x1000647, 0x1000651, 0x1000670 ] }; // Arabic heh, Arabic shadda, Arabic superscript alef
- key <AD09> { [ 0x100062E, 0x1000681, apostrophe ] }; // Arabic khah, Arabic hah with hamza above,
- key <AD10> { [ 0x100062D, 0x1000685, quotedbl ] }; // Arabic hah, Arabic hah with three dots above
- key <AD11> { [ 0x100062C, bracketright, braceleft ] }; // Arabic jeem
- key <AD12> { [ 0x1000686, bracketleft, braceright ] }; // Arabic tcheh
-
- key <AC01> { [ 0x1000634, 0x100069A ] }; // Arabic sheen, Arabic seen with dot below and dot above
- key <AC02> { [ 0x1000633, 0x10006CD ] }; // Arabic seen, Arabic yeh with tail
- key <AC03> { [ 0x10006CC, 0x100064A, 0x10006D2 ] }; // Farsi yeh, Arabic yeh, Arabic yeh barree
- key <AC04> { [ 0x1000628, 0x100067E, 0x10006BA ] }; // Arabic beh, Arabic peh, Arabic noon ghunna
- key <AC05> { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above
- key <AC06> { [ 0x1000627, 0x1000622, 0x1000625 ] }; // Arabic alef, Arabic madda on alef, Arabic alef with hamza below
- key <AC07> { [ 0x100062A, 0x100067C, 0x1000679 ] }; // Arabic teh, Arabic teh with ring, Arabic tteh
- key <AC08> { [ 0x1000646, 0x10006BC, greater ] }; // Arabic noon, Arabic noon with ring
- key <AC09> { [ 0x1000645, 0x1000629, less ] }; // Arabic meem, Arabic teh marbuta
- key <AC10> { [ 0x10006A9, colon, 0x1000643 ] }; // Arabic keheh, Arabic kaf
- key <AC11> { [ 0x10006AB, 0x100061B, 0x10006AF ] }; // Arabic kaf with ring, Arabic semicolon, Arabic gaf
-
- key <BKSL> { [ backslash, asterisk, bar ] };
-
- key <AB01> { [ 0x1000638, 0x1000626, question] }; // Arabic zah, Arabic yeh with hamza above
- key <AB02> { [ 0x10006D0, 0x1000637, semicolon ] }; // Arabic tah, Arabic E
- key <AB03> { [ 0x1000632, 0x1000698 ] }; // Arabic zain, Arabic jeh
- key <AB04> { [ 0x1000631, 0x1000621 ] }; // Arabic_ra (reh?), Arabic hamza
- key <AB05> { [ 0x1000630, 0x100200C ] }; // Arabic_thal, zero width non-joiner
- key <AB06> { [ 0x100062F, 0x1000689, 0x1000688 ] }; // Arabic_dal, Arabic dal with ring, Arabic ddal
- key <AB07> { [ 0x1000693, 0x1000624, 0x1000691 ] }; // Arabic reh with ring, Arabic waw with hamza above, Arabic rreh
- key <AB08> { [ 0x1000648, period, comma ] }; // Arabic_waw, Arabic comma
- key <AB09> { [ 0x1000696, 0x100002E, 0x10006C7 ] }; // Arabic reh with dot below and dot above, full stop, Arabic letter U
- key <AB10> { [ slash, 0x100061F, 0x10006C9 ] }; // Arabic question mark, Arabic kirghiz yu
-
- include "nbsp(zwnj2nb3)"
- include "group(olpc)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc-fa" {
-
- name[Group1]= "Afghanistan - OLPC Dari";
-
- key <TLDE> { [ 0x100200D, division, asciitilde ] }; // zero width joiner
- key <AE01> { [ 0x10006F1, exclam, grave ] }; // Arabic one
- key <AE02> { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator
- key <AE03> { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator
- key <AE04> { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign
- key <AE05> { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign
- key <AE06> { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six
- key <AE07> { [ 0x10006F7, 0x100060C, ampersand ] }; // Arabic seven, Arabic comma
- key <AE08> { [ 0x10006F8, asterisk, enfilledcircbullet ] }; // Arabic eight,
- key <AE09> { [ 0x10006F9, parenright, 0x100200E ] }; // Arabic nine, left-to-right mark
- key <AE10> { [ 0x10006F0, parenleft, 0x100200F ] }; // Arabic zero, right-to-left mark
- key <AE11> { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel
- key <AE12> { [ plus, equal ] };
-
- key <AD01> { [ 0x1000636, 0x1000652, degree ] }; // Arabic dad, Arabic sukun
- key <AD02> { [ 0x1000635, 0x100064C ] }; // Arabic sad, Arabic dammatan
- key <AD03> { [ 0x100062B, 0x100064D, EuroSign ] }; // Arabic theh, Arabic kasratan
- key <AD04> { [ 0x1000642, 0x100064B, 0x100FD3E ] }; // Arabic qaf, Arabic fathatan, ornate left paren
- key <AD05> { [ 0x1000641, 0x100064F, 0x100FD3F ] }; // Arabic feh, Arabic damma, ornate right paren
- key <AD06> { [ 0x100063A, 0x1000650, 0x1000656 ] }; // Arabic ghain, Arabic kasra, Arabic subscript alef
- key <AD07> { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay
- key <AD08> { [ 0x1000647, 0x1000651, 0x1000655 ] }; // Arabic heh, Arabic shadda, Arabic hamza below
- key <AD09> { [ 0x100062E, bracketright, apostrophe ] }; // Arabic khah
- key <AD10> { [ 0x100062D, bracketleft, quotedbl ] }; // Arabic hah
- key <AD11> { [ 0x100062C, braceright, 0x1000681 ] }; // Arabic jeem, Arabic hah with hamza above
- key <AD12> { [ 0x1000686, braceleft, 0x1000685 ] }; // Arabic tcheh, Arabic hah with three dots above
-
- key <AC01> { [ 0x1000634, 0x1000624, 0x100069A ] }; // Arabic sheen, Arabic waw with hamza above, Arabic seen with dot below and dot above
- key <AC02> { [ 0x1000633, 0x1000626, 0x10006CD ] }; // Arabic seen, Arabic yeh with hamza above, Arabic yeh with tail
- key <AC03> { [ 0x10006CC, 0x100064A, 0x1000649 ] }; // Farsi yeh, Arabic yeh, Arabic alef maksura
- key <AC04> { [ 0x1000628, 0x1000625, 0x10006D0 ] }; // Arabic beh, Arabic alef with hamza below, Arabic e
- key <AC05> { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above
- key <AC06> { [ 0x1000627, 0x1000622, 0x1000671 ] }; // Arabic alef, Arabic madda on alef, Arabic alef wasla
- key <AC07> { [ 0x100062A, 0x1000629, 0x100067C ] }; // Arabic teh, Arabic teh marbuta, Arabic tteh
- key <AC08> { [ 0x1000646, guillemotright, 0x10006BC ] }; // Arabic noon, Arabic noon with ring
- key <AC09> { [ 0x1000645, guillemotleft, 0x10006BA ] }; // Arabic meem, Arabic noon ghunna
- key <AC10> { [ 0x10006A9, colon, semicolon ] }; // Arabic keheh,
- key <AC11> { [ 0x10006AF, 0x100061B, 0x10006AB ] }; // Arabic gaf, Arabic semicolon, Arabic kaf with ring
-
- key <BKSL> { [ backslash, bar, question ] };
-
- key <AB01> { [ 0x1000638, 0x1000643, 0x10006D2 ] }; // Arabic zah, Arabic kaf, Arabic yeh barree
- key <AB02> { [ 0x1000637, 0x1000653, 0x1000691 ] }; // Arabic tah, Arabic maddah above, Arabic rreh
- key <AB03> { [ 0x1000632, 0x1000698, 0x1000696 ] }; // Arabic zain, Arabic jeh, Arabic reh with dot below and dot above
- key <AB04> { [ 0x1000631, 0x1000670, 0x1000693 ] }; // Arabic_ra (reh?), Arabic superscript alef, Arabic reh with ring
- key <AB05> { [ 0x1000630, 0x100200C, 0x1000688 ] }; // Arabic_thal, zero width non-joiner, Arabic ddal
- key <AB06> { [ 0x100062F, 0x1000654, 0x1000689 ] }; // Arabic dal, Arabic hamza above, Arabic dal with ring
- key <AB07> { [ 0x100067E, 0x1000621, 0x1000679 ] }; // Arabic peh, Arabic hamza, Arabic tteh
- key <AB08> { [ 0x1000648, greater, comma ] }; // Arabic_waw
- key <AB09> { [ period, less, 0x10006C7 ] }; // Arabic u
- key <AB10> { [ slash, 0x100061F, 0x10006C9 ] }; // Arabic question mark, Arabic kirghiz yu
-
- include "nbsp(zwnj2nb3)"
- include "group(olpc)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc-uz" {
-
- name[Group1]= "Afghanistan - OLPC Southern Uzbek";
-
- key <TLDE> { [ 0x100200D, division, asciitilde ] }; // zero width joiner
- key <AE01> { [ 0x10006F1, exclam, grave ] }; // Arabic one
- key <AE02> { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator
- key <AE03> { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator
- key <AE04> { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign
- key <AE05> { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign
- key <AE06> { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six
- key <AE07> { [ 0x10006F7, 0x100060C, ampersand ] }; // Arabic seven, Arabic comma
- key <AE08> { [ 0x10006F8, asterisk, enfilledcircbullet ] }; // Arabic eight,
- key <AE09> { [ 0x10006F9, parenright, 0x100200E ] }; // Arabic nine, left-to-right mark
- key <AE10> { [ 0x10006F0, parenleft, 0x100200F ] }; // Arabic zero, right-to-left mark
- key <AE11> { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel
- key <AE12> { [ plus, equal ] };
-
- key <AD01> { [ 0x1000636, 0x1000652, degree ] }; // Arabic dad, Arabic sukun
- key <AD02> { [ 0x1000635, 0x100064C, 0x1000653 ] }; // Arabic sad, Arabic dammatan, Arabic maddah above
- key <AD03> { [ 0x100062B, 0x100064D, EuroSign ] }; // Arabic theh, Arabic kasratan
- key <AD04> { [ 0x1000642, 0x100064B, 0x100FD3E ] }; // Arabic qaf, Arabic fathatan, ornate left paren
- key <AD05> { [ 0x1000641, 0x100064F, 0x100FD3F ] }; // Arabic feh, Arabic damma, ornate right paren
- key <AD06> { [ 0x100063A, 0x1000650, 0x1000656 ] }; // Arabic ghain, Arabic kasra, Arabic subscript alef
- key <AD07> { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay
- key <AD08> { [ 0x1000647, 0x1000651, 0x1000670 ] }; // Arabic heh, Arabic shadda, Arabic superscript alef
- key <AD09> { [ 0x100062E, bracketright, apostrophe ] }; // Arabic khah
- key <AD10> { [ 0x100062D, bracketleft, quotedbl ] }; // Arabic hah
- key <AD11> { [ 0x100062C, braceright, 0x1000681 ] }; // Arabic jeem, Arabic hah with hamza above
- key <AD12> { [ 0x1000686, braceleft, 0x1000685 ] }; // Arabic tcheh, Arabic hah with three dots above
-
- key <AC01> { [ 0x1000634, 0x1000624, 0x100069A ] }; // Arabic sheen, Arabic waw with hamza above, Arabic seen with dot below and dot above
- key <AC02> { [ 0x1000633, 0x1000626, 0x10006CD ] }; // Arabic seen, Arabic yeh with hamza above, Arabic yeh with tail
- key <AC03> { [ 0x10006CC, 0x100064A, 0x1000649 ] }; // Farsi yeh, Arabic yeh, Arabic alef maksura
- key <AC04> { [ 0x1000628, 0x10006D0, 0x1000643 ] }; // Arabic beh, Arabic e, Arabic kaf
- key <AC05> { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above
- key <AC06> { [ 0x1000627, 0x1000622, 0x1000671 ] }; // Arabic alef, Arabic madda on alef, Arabic alef wasla
- key <AC07> { [ 0x100062A, 0x1000629, 0x100067C ] }; // Arabic teh, Arabic teh marbuta, Arabic tteh
- key <AC08> { [ 0x1000646, guillemotright, 0x10006BC ] }; // Arabic noon, Arabic noon with ring
- key <AC09> { [ 0x1000645, guillemotleft, 0x10006BA ] }; // Arabic meem, Arabic noon ghunna
- key <AC10> { [ 0x10006A9, colon, semicolon ] }; // Arabic keheh,
- key <AC11> { [ 0x10006AF, 0x100061B, 0x10006AB ] }; // Arabic gaf, Arabic semicolon, Arabic kaf with ring
-
- key <BKSL> { [ backslash, bar, question ] };
-
- key <AB01> { [ 0x1000638, 0x10006C9, 0x10006D2 ] }; // Arabic zah, Arabic kirghiz yu, Arabic yeh barree
- key <AB02> { [ 0x1000637, 0x10006C7, 0x1000691 ] }; // Arabic tah, Arabic u, Arabic rreh
- key <AB03> { [ 0x1000632, 0x1000698, 0x1000696 ] }; // Arabic zain, Arabic jeh, Arabic reh with dot below and dot above
- key <AB04> { [ 0x1000631, 0x1000625, 0x1000693 ] }; // Arabic_ra (reh?), Arabic alef with hamza below, Arabic reh with ring
- key <AB05> { [ 0x1000630, 0x100200C, 0x1000688 ] }; // Arabic_thal, zero width non-joiner, Arabic ddal
- key <AB06> { [ 0x100062F, 0x1000654, 0x1000689 ] }; // Arabic dal, Arabic hamza above, Arabic dal with ring
- key <AB07> { [ 0x100067E, 0x1000621, 0x1000679 ] }; // Arabic peh, Arabic hamza, Arabic tteh
- key <AB08> { [ 0x1000648, greater, comma ] }; // Arabic_waw
- key <AB09> { [ period, less ] };
- key <AB10> { [ slash, 0x100061F, 0x1000655 ] }; // Arabic question mark, Arabic hamza below
-
- include "nbsp(zwnj2nb3)"
- include "group(olpc)"
-};
+// +// Keymap for the Afghan dari keybord layout +// Based on the specification "Computer Locale Requirements for +// Afghanstan" [1] from the "United Nations Development Programme +// Afghanistan" and the "Afghan Transitional Islamic +// Administration Ministry of Communications". +// [1] http://www.evertype.com/standards/af/ +// For a MINI HOWTO see [2]. +// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php +// +// 2006-02-15 file created by M. Emal Alekozai <memala@gmx.net> + +partial default alphanumeric_keys +xkb_symbols "basic" { + //name[Group1]= "Afghanistan Dari"; + name[Group1]= "Afghanistan"; + + key <TLDE> { [ 0x100200d, 0x10000f7, dead_tilde ] }; + key <AE01> { [ 0x10006f1, exclam, 0x1000060 ] }; + key <AE02> { [ 0x10006f2, 0x100066c, 0x1000040 ] }; + key <AE03> { [ 0x10006f3, 0x100066b, numbersign ] }; + key <AE04> { [ 0x10006f4, 0x100e60b, 0x1000024] }; + key <AE05> { [ 0x10006f5, 0x100066a, 0x1000025 ] }; + key <AE06> { [ 0x10006f6, multiply, 0x100005e ] }; + key <AE07> { [ 0x10006f7, Arabic_comma, 0x1000026 ] }; + key <AE08> { [ 0x10006f8, asterisk, 0x1002022 ] }; + key <AE09> { [ 0x10006f9, 0x1000029, 0x100200e ] }; + key <AE10> { [ 0x10006f0, 0x1000028, 0x100200f ] }; + key <AE11> { [ minus, Arabic_tatweel, 0x100005f ] }; + key <AE12> { [ plus, equal ] }; + + key <AD01> { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] }; + key <AD02> { [ Arabic_sad, Arabic_dammatan ] }; + key <AD03> { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] }; + key <AD04> { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] }; + key <AD05> { [ Arabic_feh, Arabic_damma, 0x100fd3f ] }; + key <AD06> { [ Arabic_ghain, Arabic_kasra, 0x100e656] }; + key <AD07> { [ Arabic_ain, Arabic_fatha, 0x100e659] }; + key <AD08> { [ Arabic_heh, Arabic_shadda, 0x1000655] }; + key <AD09> { [ Arabic_khah, bracketright, 0x1000027] }; + key <AD10> { [ Arabic_hah, bracketleft, 0x1000022] }; + key <AD11> { [ Arabic_jeem, braceright, 0x1000681 ] }; + key <AD12> { [ 0x1000686, braceleft, 0x1000685 ] }; + + key <AC01> { [ Arabic_sheen, Arabic_hamzaonwaw, 0x100069a ] }; + key <AC02> { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006cd ] }; + key <AC03> { [ 0x10006cc, Arabic_yeh, 0x1000649 ] }; + key <AC04> { [ Arabic_beh, Arabic_hamzaunderalef, 0x10006d0 ] }; + key <AC05> { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] }; + key <AC06> { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] }; + key <AC07> { [ Arabic_teh, Arabic_tehmarbuta, 0x100067c ] }; + key <AC08> { [ Arabic_noon, 0x10000bb, 0x10006bc ] }; + key <AC09> { [ Arabic_meem, 0x10000ab, 0x10006ba ] }; + key <AC10> { [ 0x10006a9, colon, 0x100003b ] }; + key <AC11> { [ 0x10006af, Arabic_semicolon, 0x10006ab ] }; + + key <BKSL> { [ backslash, bar, 0x100003f ] }; + + key <AB01> { [ Arabic_zah, Arabic_kaf, 0x10006d2] }; + key <AB02> { [ Arabic_tah, 0x1000653 , 0x1000691 ] }; + key <AB03> { [ Arabic_zain, 0x1000698, 0x1000696 ] }; + key <AB04> { [ Arabic_ra, 0x1000670 , 0x1000693 ] }; + key <AB05> { [ Arabic_thal, 0x100200c, 0x1000688 ] }; + key <AB06> { [ Arabic_dal, 0x1000654, 0x1000689 ] }; + key <AB07> { [ 0x100067e, Arabic_hamza, 0x1000679 ] }; + key <AB08> { [ Arabic_waw, greater, 0x100002c ] }; + key <AB09> { [ period, less, 0x10006c7 ] }; + key <AB10> { [ slash, Arabic_question_mark, 0x10006c9 ] }; + + include "nbsp(zwnj2nb3)" + include "level3(ralt_switch)" +}; + +// Keymap for the Afghan pashto keybord layout +// Based on the specification "Computer Locale Requirements for +// Afghanstan" [1] from the "United Nations Development Programme +// Afghanistan"" and the "Afghan Transitional Islamic +// Administration Ministry of Communications". +// [1] http://www.evertype.com/standards/af/ +// For a MINI HOWTO see [2]. +// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php +// +// 2006-02-15 file created by M. Emal Alekozai <memala@gmx.net> + +partial alphanumeric_keys +xkb_symbols "ps" { + name[Group1]= "Afghanistan - Pashto"; + + key <TLDE> { [ 0x100200d, 0x10000f7, dead_tilde ] }; + key <AE01> { [ 0x10006f1, exclam, 0x1000060 ] }; + key <AE02> { [ 0x10006f2, 0x100066c, 0x1000040 ] }; + key <AE03> { [ 0x10006f3, 0x100066b, numbersign ] }; + key <AE04> { [ 0x10006f4, 0x100e60b, 0x1000024] }; + key <AE05> { [ 0x10006f5, 0x100066a, 0x1000025 ] }; + key <AE06> { [ 0x10006f6, multiply, 0x100005e ] }; + key <AE07> { [ 0x10006f7, 0x10000bb, 0x1000026 ] }; + key <AE08> { [ 0x10006f8, 0x10000ab, 0x1002022 ] }; + key <AE09> { [ 0x10006f9, 0x1000029, 0x100200e ] }; + key <AE10> { [ 0x10006f0, 0x1000028, 0x100200f ] }; + key <AE11> { [ minus, Arabic_tatweel, 0x100005f ] }; + key <AE12> { [ plus, equal ] }; + + key <AD01> { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] }; + key <AD02> { [ Arabic_sad, Arabic_dammatan, 0x1000653 ] }; + key <AD03> { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] }; + key <AD04> { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] }; + key <AD05> { [ Arabic_feh, Arabic_damma, 0x100fd3f ] }; + key <AD06> { [ Arabic_ghain, Arabic_kasra, 0x100e656] }; + key <AD07> { [ Arabic_ain, Arabic_fatha, 0x100e659] }; + key <AD08> { [ Arabic_heh, Arabic_shadda, 0x1000670] }; + key <AD09> { [ Arabic_khah, 0x1000681, 0x1000027] }; + key <AD10> { [ Arabic_hah, 0x1000685, 0x1000022] }; + key <AD11> { [ Arabic_jeem, 0x100005d, 0x100007d ] }; + key <AD12> { [ 0x1000686, 0x100005b, 0x100007b ] }; + + key <AC01> { [ Arabic_sheen, 0x100069a ] }; + key <AC02> { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006d2 ] }; + key <AC03> { [ 0x10006cc, Arabic_yeh, 0x1000649 ] }; + key <AC04> { [ Arabic_beh, 0x100067e, 0x10006ba ] }; + key <AC05> { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] }; + key <AC06> { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] }; + key <AC07> { [ Arabic_teh, 0x100067c, 0x1000679 ] }; + key <AC08> { [ Arabic_noon, 0x10006bc, 0x100003e ] }; + key <AC09> { [ Arabic_meem, 0x1000629, 0x100003c ] }; + key <AC10> { [ 0x10006a9, colon, 0x1000643 ] }; + key <AC11> { [ 0x10006ab, Arabic_semicolon, 0x10006af ] }; + + key <BKSL> { [ backslash, 0x100002a, 0x100007c ] }; + + key <AB01> { [ 0x10006cd, 0x1000638, 0x100003f] }; + key <AB02> { [ 0x10006d0, 0x1000637, 0x100003b ] }; + key <AB03> { [ Arabic_zain, 0x1000698, 0x1000655 ] }; + key <AB04> { [ Arabic_ra, 0x1000621, 0x1000654 ] }; + key <AB05> { [ Arabic_thal, 0x100200c, 0x1000625 ] }; + key <AB06> { [ Arabic_dal, 0x1000689, 0x1000688 ] }; + key <AB07> { [ 0x1000693, 0x1000624, 0x1000691 ] }; + key <AB08> { [ Arabic_waw, 0x100060c, 0x100002c ] }; + key <AB09> { [ 0x1000696, 0x100002e, 0x10006c7 ] }; + key <AB10> { [ slash, Arabic_question_mark, 0x10006c9 ] }; + + include "nbsp(zwnj2nb3)" + include "level3(ralt_switch)" +}; + +// Keymap for the Afghan southern uzbek keybord layout +// Based on the specification "Computer Locale Requirements for +// Afghanstan" [1] from the "United Nations Development Programme +// Afghanistan"" and the "Afghan Transitional Islamic +// Administration Ministry of Communications". +// [1] http://www.evertype.com/standards/af/ +// For a MINI HOWTO see [2]. +// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php +// +// 2006-02-15 file created by M. Emal Alekozai <memala@gmx.net> + +partial alphanumeric_keys +xkb_symbols "uz" { + name[Group1]= "Afghanistan - Southern Uzbek"; + + key <TLDE> { [ 0x100200d, 0x10000f7, dead_tilde ] }; + key <AE01> { [ 0x10006f1, exclam, 0x1000060 ] }; + key <AE02> { [ 0x10006f2, 0x100066c, 0x1000040 ] }; + key <AE03> { [ 0x10006f3, 0x100066b, numbersign ] }; + key <AE04> { [ 0x10006f4, 0x100e60b, 0x1000024] }; + key <AE05> { [ 0x10006f5, 0x100066a, 0x1000025 ] }; + key <AE06> { [ 0x10006f6, multiply, 0x100005e ] }; + key <AE07> { [ 0x10006f7, Arabic_comma, 0x1000026 ] }; + key <AE08> { [ 0x10006f8, asterisk, 0x1002022 ] }; + key <AE09> { [ 0x10006f9, 0x1000029, 0x100200e ] }; + key <AE10> { [ 0x10006f0, 0x1000028, 0x100200f ] }; + key <AE11> { [ minus, Arabic_tatweel, 0x100005f ] }; + key <AE12> { [ plus, equal ] }; + + key <AD01> { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] }; + key <AD02> { [ Arabic_sad, Arabic_dammatan, 0x1000653 ] }; + key <AD03> { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] }; + key <AD04> { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] }; + key <AD05> { [ Arabic_feh, Arabic_damma, 0x100fd3f ] }; + key <AD06> { [ Arabic_ghain, Arabic_kasra, 0x100e656] }; + key <AD07> { [ Arabic_ain, Arabic_fatha, 0x100e659] }; + key <AD08> { [ Arabic_heh, Arabic_shadda, 0x1000670] }; + key <AD09> { [ Arabic_khah, bracketright, 0x1000027] }; + key <AD10> { [ Arabic_hah, bracketleft, 0x1000022] }; + key <AD11> { [ Arabic_jeem, braceright, 0x1000681 ] }; + key <AD12> { [ 0x1000686, braceleft, 0x1000685 ] }; + + key <AC01> { [ Arabic_sheen, Arabic_hamzaonwaw, 0x100069a ] }; + key <AC02> { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006cd ] }; + key <AC03> { [ 0x10006cc, Arabic_yeh, 0x1000649 ] }; + key <AC04> { [ Arabic_beh, 0x10006d0, 0x1000643 ] }; + key <AC05> { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] }; + key <AC06> { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] }; + key <AC07> { [ Arabic_teh, Arabic_tehmarbuta, 0x100067c ] }; + key <AC08> { [ Arabic_noon, 0x10000bb, 0x10006bc ] }; + key <AC09> { [ Arabic_meem, 0x10000ab, 0x10006ba ] }; + key <AC10> { [ 0x10006a9, colon, 0x100003b ] }; + key <AC11> { [ 0x10006af, Arabic_semicolon, 0x10006ab ] }; + + key <BKSL> { [ backslash, bar, 0x100003f ] }; + + key <AB01> { [ Arabic_zah, 0x10006c9, 0x10006d2] }; + key <AB02> { [ Arabic_tah, 0x10006c7, 0x1000691 ] }; + key <AB03> { [ Arabic_zain, 0x1000698, 0x1000696 ] }; + key <AB04> { [ Arabic_ra, 0x1000625, 0x1000693 ] }; + key <AB05> { [ Arabic_thal, 0x100200c, 0x1000688 ] }; + key <AB06> { [ Arabic_dal, 0x1000654, 0x1000689 ] }; + key <AB07> { [ 0x100067e, Arabic_hamza, 0x1000679 ] }; + key <AB08> { [ Arabic_waw, greater, 0x100002c ] }; + key <AB09> { [ period, less ] }; + key <AB10> { [ slash, Arabic_question_mark, 0x1000655 ] }; + + include "nbsp(zwnj2nb3)" + include "level3(ralt_switch)" +}; + +partial alphanumeric_keys +xkb_symbols "olpc-ps" { + + name[Group1]= "Afghanistan - OLPC Pashto"; + + key <TLDE> { [ 0x100200D, 0x1000654, grave ] }; // zero width joiner, Arabic hamza above + key <AE01> { [ 0x10006F1, exclam, asciitilde ] }; // Arabic one + key <AE02> { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator + key <AE03> { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator + key <AE04> { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign + key <AE05> { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign + key <AE06> { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six + key <AE07> { [ 0x10006F7, guillemotright, ampersand ] }; // Arabic seven + key <AE08> { [ 0x10006F8, guillemotleft, 0x100066D ] }; // Arabic eight, Arabic five-pointed star + key <AE09> { [ 0x10006F9, parenright, enfilledcircbullet ] }; // Arabic nine + key <AE10> { [ 0x10006F0, parenleft, degree ] }; // Arabic zero + key <AE11> { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel + key <AE12> { [ plus, equal, division ] }; + + key <AD01> { [ 0x1000636, 0x1000652, EuroSign ] }; // Arabic dad, Arabic sukun + key <AD02> { [ 0x1000635, 0x100064C, 0x1000671 ] }; // Arabic sad, Arabic dammatan, Arabic alef walsa + key <AD03> { [ 0x100062B, 0x100064D, 0x1000649 ] }; // Arabic theh, Arabic kasratan, Arabic alef maksura initial form + key <AD04> { [ 0x1000642, 0x100064B, 0x100200E ] }; // Arabic qaf, Arabic fathatan, left-to-right mark + key <AD05> { [ 0x1000641, 0x100064F, 0x100200F ] }; // Arabic feh, Arabic damma, right-to-left mark + key <AD06> { [ 0x100063A, 0x1000650, 0x100e653 ] }; // Arabic ghain, Arabic kasra, Arabic alef with madda above + key <AD07> { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay + key <AD08> { [ 0x1000647, 0x1000651, 0x1000670 ] }; // Arabic heh, Arabic shadda, Arabic superscript alef + key <AD09> { [ 0x100062E, 0x1000681, apostrophe ] }; // Arabic khah, Arabic hah with hamza above, + key <AD10> { [ 0x100062D, 0x1000685, quotedbl ] }; // Arabic hah, Arabic hah with three dots above + key <AD11> { [ 0x100062C, bracketright, braceleft ] }; // Arabic jeem + key <AD12> { [ 0x1000686, bracketleft, braceright ] }; // Arabic tcheh + + key <AC01> { [ 0x1000634, 0x100069A ] }; // Arabic sheen, Arabic seen with dot below and dot above + key <AC02> { [ 0x1000633, 0x10006CD ] }; // Arabic seen, Arabic yeh with tail + key <AC03> { [ 0x10006CC, 0x100064A, 0x10006D2 ] }; // Farsi yeh, Arabic yeh, Arabic yeh barree + key <AC04> { [ 0x1000628, 0x100067E, 0x10006BA ] }; // Arabic beh, Arabic peh, Arabic noon ghunna + key <AC05> { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above + key <AC06> { [ 0x1000627, 0x1000622, 0x1000625 ] }; // Arabic alef, Arabic madda on alef, Arabic alef with hamza below + key <AC07> { [ 0x100062A, 0x100067C, 0x1000679 ] }; // Arabic teh, Arabic teh with ring, Arabic tteh + key <AC08> { [ 0x1000646, 0x10006BC, greater ] }; // Arabic noon, Arabic noon with ring + key <AC09> { [ 0x1000645, 0x1000629, less ] }; // Arabic meem, Arabic teh marbuta + key <AC10> { [ 0x10006A9, colon, 0x1000643 ] }; // Arabic keheh, Arabic kaf + key <AC11> { [ 0x10006AB, 0x100061B, 0x10006AF ] }; // Arabic kaf with ring, Arabic semicolon, Arabic gaf + + key <BKSL> { [ backslash, asterisk, bar ] }; + + key <AB01> { [ 0x1000638, 0x1000626, question] }; // Arabic zah, Arabic yeh with hamza above + key <AB02> { [ 0x10006D0, 0x1000637, semicolon ] }; // Arabic tah, Arabic E + key <AB03> { [ 0x1000632, 0x1000698 ] }; // Arabic zain, Arabic jeh + key <AB04> { [ 0x1000631, 0x1000621 ] }; // Arabic_ra (reh?), Arabic hamza + key <AB05> { [ 0x1000630, 0x100200C ] }; // Arabic_thal, zero width non-joiner + key <AB06> { [ 0x100062F, 0x1000689, 0x1000688 ] }; // Arabic_dal, Arabic dal with ring, Arabic ddal + key <AB07> { [ 0x1000693, 0x1000624, 0x1000691 ] }; // Arabic reh with ring, Arabic waw with hamza above, Arabic rreh + key <AB08> { [ 0x1000648, period, comma ] }; // Arabic_waw, Arabic comma + key <AB09> { [ 0x1000696, 0x100002E, 0x10006C7 ] }; // Arabic reh with dot below and dot above, full stop, Arabic letter U + key <AB10> { [ slash, 0x100061F, 0x10006C9 ] }; // Arabic question mark, Arabic kirghiz yu + + include "nbsp(zwnj2nb3)" + include "group(olpc)" +}; + +partial alphanumeric_keys +xkb_symbols "fa-olpc" { + + name[Group1]= "Afghanistan - OLPC Dari"; + + key <TLDE> { [ 0x100200D, division, asciitilde ] }; // zero width joiner + key <AE01> { [ 0x10006F1, exclam, grave ] }; // Arabic one + key <AE02> { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator + key <AE03> { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator + key <AE04> { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign + key <AE05> { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign + key <AE06> { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six + key <AE07> { [ 0x10006F7, 0x100060C, ampersand ] }; // Arabic seven, Arabic comma + key <AE08> { [ 0x10006F8, asterisk, enfilledcircbullet ] }; // Arabic eight, + key <AE09> { [ 0x10006F9, parenright, 0x100200E ] }; // Arabic nine, left-to-right mark + key <AE10> { [ 0x10006F0, parenleft, 0x100200F ] }; // Arabic zero, right-to-left mark + key <AE11> { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel + key <AE12> { [ plus, equal ] }; + + key <AD01> { [ 0x1000636, 0x1000652, degree ] }; // Arabic dad, Arabic sukun + key <AD02> { [ 0x1000635, 0x100064C ] }; // Arabic sad, Arabic dammatan + key <AD03> { [ 0x100062B, 0x100064D, EuroSign ] }; // Arabic theh, Arabic kasratan + key <AD04> { [ 0x1000642, 0x100064B, 0x100FD3E ] }; // Arabic qaf, Arabic fathatan, ornate left paren + key <AD05> { [ 0x1000641, 0x100064F, 0x100FD3F ] }; // Arabic feh, Arabic damma, ornate right paren + key <AD06> { [ 0x100063A, 0x1000650, 0x1000656 ] }; // Arabic ghain, Arabic kasra, Arabic subscript alef + key <AD07> { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay + key <AD08> { [ 0x1000647, 0x1000651, 0x1000655 ] }; // Arabic heh, Arabic shadda, Arabic hamza below + key <AD09> { [ 0x100062E, bracketright, apostrophe ] }; // Arabic khah + key <AD10> { [ 0x100062D, bracketleft, quotedbl ] }; // Arabic hah + key <AD11> { [ 0x100062C, braceright, 0x1000681 ] }; // Arabic jeem, Arabic hah with hamza above + key <AD12> { [ 0x1000686, braceleft, 0x1000685 ] }; // Arabic tcheh, Arabic hah with three dots above + + key <AC01> { [ 0x1000634, 0x1000624, 0x100069A ] }; // Arabic sheen, Arabic waw with hamza above, Arabic seen with dot below and dot above + key <AC02> { [ 0x1000633, 0x1000626, 0x10006CD ] }; // Arabic seen, Arabic yeh with hamza above, Arabic yeh with tail + key <AC03> { [ 0x10006CC, 0x100064A, 0x1000649 ] }; // Farsi yeh, Arabic yeh, Arabic alef maksura + key <AC04> { [ 0x1000628, 0x1000625, 0x10006D0 ] }; // Arabic beh, Arabic alef with hamza below, Arabic e + key <AC05> { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above + key <AC06> { [ 0x1000627, 0x1000622, 0x1000671 ] }; // Arabic alef, Arabic madda on alef, Arabic alef wasla + key <AC07> { [ 0x100062A, 0x1000629, 0x100067C ] }; // Arabic teh, Arabic teh marbuta, Arabic tteh + key <AC08> { [ 0x1000646, guillemotright, 0x10006BC ] }; // Arabic noon, Arabic noon with ring + key <AC09> { [ 0x1000645, guillemotleft, 0x10006BA ] }; // Arabic meem, Arabic noon ghunna + key <AC10> { [ 0x10006A9, colon, semicolon ] }; // Arabic keheh, + key <AC11> { [ 0x10006AF, 0x100061B, 0x10006AB ] }; // Arabic gaf, Arabic semicolon, Arabic kaf with ring + + key <BKSL> { [ backslash, bar, question ] }; + + key <AB01> { [ 0x1000638, 0x1000643, 0x10006D2 ] }; // Arabic zah, Arabic kaf, Arabic yeh barree + key <AB02> { [ 0x1000637, 0x1000653, 0x1000691 ] }; // Arabic tah, Arabic maddah above, Arabic rreh + key <AB03> { [ 0x1000632, 0x1000698, 0x1000696 ] }; // Arabic zain, Arabic jeh, Arabic reh with dot below and dot above + key <AB04> { [ 0x1000631, 0x1000670, 0x1000693 ] }; // Arabic_ra (reh?), Arabic superscript alef, Arabic reh with ring + key <AB05> { [ 0x1000630, 0x100200C, 0x1000688 ] }; // Arabic_thal, zero width non-joiner, Arabic ddal + key <AB06> { [ 0x100062F, 0x1000654, 0x1000689 ] }; // Arabic dal, Arabic hamza above, Arabic dal with ring + key <AB07> { [ 0x100067E, 0x1000621, 0x1000679 ] }; // Arabic peh, Arabic hamza, Arabic tteh + key <AB08> { [ 0x1000648, greater, comma ] }; // Arabic_waw + key <AB09> { [ period, less, 0x10006C7 ] }; // Arabic u + key <AB10> { [ slash, 0x100061F, 0x10006C9 ] }; // Arabic question mark, Arabic kirghiz yu + + include "nbsp(zwnj2nb3)" + include "group(olpc)" +}; + +partial alphanumeric_keys +xkb_symbols "uz-olpc" { + + name[Group1]= "Afghanistan - OLPC Southern Uzbek"; + + key <TLDE> { [ 0x100200D, division, asciitilde ] }; // zero width joiner + key <AE01> { [ 0x10006F1, exclam, grave ] }; // Arabic one + key <AE02> { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator + key <AE03> { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator + key <AE04> { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign + key <AE05> { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign + key <AE06> { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six + key <AE07> { [ 0x10006F7, 0x100060C, ampersand ] }; // Arabic seven, Arabic comma + key <AE08> { [ 0x10006F8, asterisk, enfilledcircbullet ] }; // Arabic eight, + key <AE09> { [ 0x10006F9, parenright, 0x100200E ] }; // Arabic nine, left-to-right mark + key <AE10> { [ 0x10006F0, parenleft, 0x100200F ] }; // Arabic zero, right-to-left mark + key <AE11> { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel + key <AE12> { [ plus, equal ] }; + + key <AD01> { [ 0x1000636, 0x1000652, degree ] }; // Arabic dad, Arabic sukun + key <AD02> { [ 0x1000635, 0x100064C, 0x1000653 ] }; // Arabic sad, Arabic dammatan, Arabic maddah above + key <AD03> { [ 0x100062B, 0x100064D, EuroSign ] }; // Arabic theh, Arabic kasratan + key <AD04> { [ 0x1000642, 0x100064B, 0x100FD3E ] }; // Arabic qaf, Arabic fathatan, ornate left paren + key <AD05> { [ 0x1000641, 0x100064F, 0x100FD3F ] }; // Arabic feh, Arabic damma, ornate right paren + key <AD06> { [ 0x100063A, 0x1000650, 0x1000656 ] }; // Arabic ghain, Arabic kasra, Arabic subscript alef + key <AD07> { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay + key <AD08> { [ 0x1000647, 0x1000651, 0x1000670 ] }; // Arabic heh, Arabic shadda, Arabic superscript alef + key <AD09> { [ 0x100062E, bracketright, apostrophe ] }; // Arabic khah + key <AD10> { [ 0x100062D, bracketleft, quotedbl ] }; // Arabic hah + key <AD11> { [ 0x100062C, braceright, 0x1000681 ] }; // Arabic jeem, Arabic hah with hamza above + key <AD12> { [ 0x1000686, braceleft, 0x1000685 ] }; // Arabic tcheh, Arabic hah with three dots above + + key <AC01> { [ 0x1000634, 0x1000624, 0x100069A ] }; // Arabic sheen, Arabic waw with hamza above, Arabic seen with dot below and dot above + key <AC02> { [ 0x1000633, 0x1000626, 0x10006CD ] }; // Arabic seen, Arabic yeh with hamza above, Arabic yeh with tail + key <AC03> { [ 0x10006CC, 0x100064A, 0x1000649 ] }; // Farsi yeh, Arabic yeh, Arabic alef maksura + key <AC04> { [ 0x1000628, 0x10006D0, 0x1000643 ] }; // Arabic beh, Arabic e, Arabic kaf + key <AC05> { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above + key <AC06> { [ 0x1000627, 0x1000622, 0x1000671 ] }; // Arabic alef, Arabic madda on alef, Arabic alef wasla + key <AC07> { [ 0x100062A, 0x1000629, 0x100067C ] }; // Arabic teh, Arabic teh marbuta, Arabic tteh + key <AC08> { [ 0x1000646, guillemotright, 0x10006BC ] }; // Arabic noon, Arabic noon with ring + key <AC09> { [ 0x1000645, guillemotleft, 0x10006BA ] }; // Arabic meem, Arabic noon ghunna + key <AC10> { [ 0x10006A9, colon, semicolon ] }; // Arabic keheh, + key <AC11> { [ 0x10006AF, 0x100061B, 0x10006AB ] }; // Arabic gaf, Arabic semicolon, Arabic kaf with ring + + key <BKSL> { [ backslash, bar, question ] }; + + key <AB01> { [ 0x1000638, 0x10006C9, 0x10006D2 ] }; // Arabic zah, Arabic kirghiz yu, Arabic yeh barree + key <AB02> { [ 0x1000637, 0x10006C7, 0x1000691 ] }; // Arabic tah, Arabic u, Arabic rreh + key <AB03> { [ 0x1000632, 0x1000698, 0x1000696 ] }; // Arabic zain, Arabic jeh, Arabic reh with dot below and dot above + key <AB04> { [ 0x1000631, 0x1000625, 0x1000693 ] }; // Arabic_ra (reh?), Arabic alef with hamza below, Arabic reh with ring + key <AB05> { [ 0x1000630, 0x100200C, 0x1000688 ] }; // Arabic_thal, zero width non-joiner, Arabic ddal + key <AB06> { [ 0x100062F, 0x1000654, 0x1000689 ] }; // Arabic dal, Arabic hamza above, Arabic dal with ring + key <AB07> { [ 0x100067E, 0x1000621, 0x1000679 ] }; // Arabic peh, Arabic hamza, Arabic tteh + key <AB08> { [ 0x1000648, greater, comma ] }; // Arabic_waw + key <AB09> { [ period, less ] }; + key <AB10> { [ slash, 0x100061F, 0x1000655 ] }; // Arabic question mark, Arabic hamza below + + include "nbsp(zwnj2nb3)" + include "group(olpc)" +}; diff --git a/xorg-server/xkeyboard-config/symbols/capslock b/xorg-server/xkeyboard-config/symbols/capslock index 288a1d293..3e0880573 100644 --- a/xorg-server/xkeyboard-config/symbols/capslock +++ b/xorg-server/xkeyboard-config/symbols/capslock @@ -1,62 +1,74 @@ -default partial hidden modifier_keys
-xkb_symbols "capslock" {
- replace key <CAPS> { [ Caps_Lock ] };
- modifier_map Lock { Caps_Lock };
-};
-
-partial hidden modifier_keys
-xkb_symbols "shiftlock" {
- replace key <CAPS> { [ Shift_Lock ] };
- modifier_map Shift { Shift_Lock };
-};
-
-partial hidden modifier_keys
-xkb_symbols "grouplock" {
- replace key <CAPS> { [ ISO_Next_Group, Caps_Lock ] };
-};
-
-partial hidden modifier_keys
-xkb_symbols "swapescape" {
- key <CAPS> { [ Escape ] };
- key <ESC> { [ Caps_Lock ] };
-};
-
-partial hidden modifier_keys
-xkb_symbols "groupshift" {
- key <CAPS> {
- type[Group1]="PC_ALT_LEVEL2",
- [ Mode_switch, Caps_Lock ]
- };
-};
-
-partial hidden modifier_keys
-xkb_symbols "escape" {
- key <CAPS> { [ Escape ] };
-};
-
-partial hidden modifier_keys
-xkb_symbols "backspace" {
- key <CAPS> { [ BackSpace ] };
-};
-
-partial hidden modifier_keys
-xkb_symbols "super" {
- key <CAPS> { [ Super_L ] };
- modifier_map Mod4 { <CAPS> };
-};
-
-partial hidden modifier_keys
-xkb_symbols "hyper" {
- key <CAPS> { [ Hyper_L ] };
- modifier_map Mod4 { <CAPS> };
-};
-
-partial hidden modifier_keys
-xkb_symbols "none" {
- key <CAPS> { [ VoidSymbol ] };
-};
-
-partial hidden modifier_keys
-xkb_symbols "numlock" {
- key <CAPS> { [ Num_Lock ] };
-};
+default partial hidden modifier_keys +xkb_symbols "capslock" { + replace key <CAPS> { [ Caps_Lock ] }; + modifier_map Lock { Caps_Lock }; +}; + +partial hidden modifier_keys +xkb_symbols "shiftlock" { + replace key <CAPS> { [ Shift_Lock ] }; + modifier_map Shift { Shift_Lock }; +}; + +partial hidden modifier_keys +xkb_symbols "grouplock" { + replace key <CAPS> { [ ISO_Next_Group, Caps_Lock ] }; +}; + +partial hidden modifier_keys +xkb_symbols "swapescape" { + key <CAPS> { [ Escape ] }; + key <ESC> { [ Caps_Lock ] }; +}; + +partial hidden modifier_keys +xkb_symbols "groupshift" { + key <CAPS> { + type[Group1]="PC_ALT_LEVEL2", + [ Mode_switch, Caps_Lock ] + }; +}; + +partial hidden modifier_keys +xkb_symbols "escape" { + key <CAPS> { [ Escape ] }; +}; + +partial hidden modifier_keys +xkb_symbols "backspace" { + key <CAPS> { [ BackSpace ] }; +}; + +partial hidden modifier_keys +xkb_symbols "super" { + key <CAPS> { [ Super_L ] }; + modifier_map Mod4 { <CAPS> }; +}; + +partial hidden modifier_keys +xkb_symbols "hyper" { + key <CAPS> { [ Hyper_L ] }; + modifier_map Mod4 { <CAPS> }; +}; + +partial hidden modifier_keys +xkb_symbols "none" { + key <CAPS> { [ VoidSymbol ] }; +}; + +partial hidden modifier_keys +xkb_symbols "numlock" { + key <CAPS> { [ Num_Lock ] }; +}; + +// This changes the modifier behavior of the <CAPS> key. +// The keysym will be reset to Caps_Lock +partial hidden modifier_keys +xkb_symbols "ctrl_modifier" { + replace key <CAPS> { + type[Group1] = "ONE_LEVEL", + symbols[Group1] = [ Caps_Lock ], + actions[Group1] = [ SetMods(modifiers=Control) ] + }; + modifier_map Control { <CAPS> }; +}; diff --git a/xorg-server/xkeyboard-config/symbols/et b/xorg-server/xkeyboard-config/symbols/et index 6f71b2f97..7d15967e2 100644 --- a/xorg-server/xkeyboard-config/symbols/et +++ b/xorg-server/xkeyboard-config/symbols/et @@ -1,73 +1,73 @@ -//
-// Ethiopia
-// Designed as a part of OLPC project
-//
-// 2007 Sergey Udaltsov <svu@gnome.org>
-//
-
-partial default alphanumeric_keys
-xkb_symbols "basic" {
- include "et(olpc)"
- name[Group1]="Ethiopia";
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc" {
-
- name[Group1]="Ethiopia";
-
- key <AE01> { [ 0x01001369, 0x01001372 ] }; // 1
- key <AE02> { [ 0x0100136a, 0x01001373 ] }; // 2
- key <AE03> { [ 0x0100136b, 0x01001374 ] }; // 3
- key <AE04> { [ 0x0100136c, 0x01001375 ] }; // 4
- key <AE05> { [ 0x0100136d, 0x01001376 ] }; // 5
- key <AE06> { [ 0x0100136e, 0x01001377 ] }; // 6
- key <AE07> { [ 0x0100136f, 0x01001378 ] }; // 7
- key <AE08> { [ 0x01001370, 0x01001379 ] }; // 8
- key <AE09> { [ 0x01001371, 0x0100137a ] }; // 9
- key <AE10> { [ 0x0100137b, 0x0100137c ] }; // 0
- key <AE11> { [ minus, underscore ] }; // -_
- key <AE12> { [ equal, plus ] }; // =+
-
- key <AD01> { [ 0x01001240, 0x01001250 ] }; // q
- key <AD02> { [ 0x010012C8, VoidSymbol ] }; // w
- key <AD03> { [ e, E ] }; // e
- key <AD04> { [ 0x01001228, VoidSymbol ] }; // r
- key <AD05> { [ 0x01001270, 0x01001320 ] }; // t
- key <AD06> { [ 0x010012E8, VoidSymbol ] }; // y
- key <AD07> { [ u, U ] }; // u
- key <AD08> { [ i, I ] }; // i
- key <AD09> { [ o, O ] }; // o
- key <AD10> { [ 0x01001350, 0x01001330 ] }; // p
- key <AD11> { [ 0x01001340, 0x01001338 ] }; // [
- key <AD12> { [ 0x01001328, 0x01001280 ] }; // ]
-
- key <AC01> { [ a, A ] }; // a
- key <AC02> { [ 0x01001230, 0x01001220 ] }; // s
- key <AC03> { [ 0x010012F0, 0x010012F8 ] }; // d
- key <AC04> { [ 0x01001348, VoidSymbol ] }; // f
- key <AC05> { [ 0x01001308, 0x01001318 ] }; // g
- key <AC06> { [ 0x01001200, 0x01001210 ] }; // h
- key <AC07> { [ 0x01001300, VoidSymbol ] }; // j
- key <AC08> { [ 0x010012A8, 0x010012B8 ] }; // k
- key <AC09> { [ 0x01001208, VoidSymbol ] }; // l
-
- key <AC10> { [ 0x01001362, 0x01001361 ] }; // :;
- key <AC11> { [ 0x01001366, 0x01001365 ] }; // '"
-
- key <AB01> { [ 0x010012D8, 0x010012E0 ] }; // z
- key <AB02> { [ 0x010012A0, 0x010012D0 ] }; // x
- key <AB03> { [ 0x01001278, VoidSymbol ] }; // c
- key <AB04> { [ 0x01001238, 0x01001268 ] }; // v
- key <AB05> { [ 0x01001260, VoidSymbol ] }; // b
- key <AB06> { [ 0x01001290, 0x01001298 ] }; // n
- key <AB07> { [ 0x01001218, VoidSymbol ] }; // m
-
- key <AB08> { [ 0x01001363, VoidSymbol ] }; // <
- key <AB09> { [ 0x01001364, VoidSymbol ] }; // >
- key <AB10> { [ 0x01001367, VoidSymbol ] }; // ?
-
- key <BKSL> { [ VoidSymbol, 0x01002010 ] }; // bksl
-
- include "group(olpc)"
-};
+// +// Ethiopia +// Designed as a part of OLPC project +// +// 2007 Sergey Udaltsov <svu@gnome.org> +// + +partial default alphanumeric_keys +xkb_symbols "basic" { + include "et(olpc)" + name[Group1]="Ethiopia"; +}; + +partial alphanumeric_keys +xkb_symbols "olpc" { + + name[Group1]="Ethiopia"; + + key <AE01> { [ 0x01001369, 0x01001372 ] }; // 1 + key <AE02> { [ 0x0100136a, 0x01001373 ] }; // 2 + key <AE03> { [ 0x0100136b, 0x01001374 ] }; // 3 + key <AE04> { [ 0x0100136c, 0x01001375 ] }; // 4 + key <AE05> { [ 0x0100136d, 0x01001376 ] }; // 5 + key <AE06> { [ 0x0100136e, 0x01001377 ] }; // 6 + key <AE07> { [ 0x0100136f, 0x01001378 ] }; // 7 + key <AE08> { [ 0x01001370, 0x01001379 ] }; // 8 + key <AE09> { [ 0x01001371, 0x0100137a ] }; // 9 + key <AE10> { [ 0x0100137b, 0x0100137c ] }; // 0 + key <AE11> { [ minus, underscore ] }; // -_ + key <AE12> { [ equal, plus ] }; // =+ + + key <AD01> { [ 0x01001240, 0x01001250 ] }; // q + key <AD02> { [ 0x010012C8, VoidSymbol ] }; // w + key <AD03> { [ 0x0100FE69, 0x0100FE70 ] }; // dead e + key <AD04> { [ 0x01001228, VoidSymbol ] }; // r + key <AD05> { [ 0x01001270, 0x01001320 ] }; // t + key <AD06> { [ 0x010012E8, VoidSymbol ] }; // y + key <AD07> { [ 0x0100FE75, 0x0100FE76 ] }; // dead u + key <AD08> { [ 0x0100FE71, 0x0100FE72 ] }; // dead i + key <AD09> { [ 0x0100FE73, 0x0100FE74 ] }; // dead o + key <AD10> { [ 0x01001350, 0x01001330 ] }; // p + key <AD11> { [ 0x01001340, 0x01001338 ] }; // [ + key <AD12> { [ 0x01001328, 0x01001280 ] }; // ] + + key <AC01> { [ 0x0100FE67, 0x0100FE68 ] }; // dead a + key <AC02> { [ 0x01001230, 0x01001220 ] }; // s + key <AC03> { [ 0x010012F0, 0x010012F8 ] }; // d + key <AC04> { [ 0x01001348, VoidSymbol ] }; // f + key <AC05> { [ 0x01001308, 0x01001318 ] }; // g + key <AC06> { [ 0x01001200, 0x01001210 ] }; // h + key <AC07> { [ 0x01001300, VoidSymbol ] }; // j + key <AC08> { [ 0x010012A8, 0x010012B8 ] }; // k + key <AC09> { [ 0x01001208, VoidSymbol ] }; // l + + key <AC10> { [ 0x01001362, 0x01001361 ] }; // :; + key <AC11> { [ 0x01001366, 0x01001365 ] }; // '" + + key <AB01> { [ 0x010012D8, 0x010012E0 ] }; // z + key <AB02> { [ 0x010012A0, 0x010012D0 ] }; // x + key <AB03> { [ 0x01001278, 0x0100FE78 ] }; // c + key <AB04> { [ 0x01001238, 0x01001268 ] }; // v + key <AB05> { [ 0x01001260, VoidSymbol ] }; // b + key <AB06> { [ 0x01001290, 0x01001298 ] }; // n + key <AB07> { [ 0x01001218, VoidSymbol ] }; // m + + key <AB08> { [ 0x01001363, VoidSymbol ] }; // < + key <AB09> { [ 0x01001364, VoidSymbol ] }; // > + key <AB10> { [ 0x01001367, question ] }; // ? + + key <BKSL> { [ VoidSymbol, 0x01002010 ] }; // bksl + + include "group(olpc)" +}; diff --git a/xorg-server/xkeyboard-config/symbols/mn b/xorg-server/xkeyboard-config/symbols/mn index 44e5e4e67..a838bd5e0 100644 --- a/xorg-server/xkeyboard-config/symbols/mn +++ b/xorg-server/xkeyboard-config/symbols/mn @@ -1,80 +1,82 @@ -// based on:
-// Mongolian standard keyboard
-// Author Sanlig Badral <badral@chinggis.com>
-// 2002/12/7 Version 1.0
-
-partial default alphanumeric_keys
-xkb_symbols "basic" {
-
- name[Group1]= "Mongolia";
-
- key <TLDE> { [ equal, plus, degree ] };
- key <AE01> { [ 1, numerosign, multiply ] };
- key <AE02> { [ 2, minus, division ] };
- key <AE03> { [ 3, quotedbl, plusminus ] };
- key <AE04> { [ 4, U20ae, notsign ] }; // Tugrik sign
- key <AE05> { [ 5, colon, NoSymbol ] };
- key <AE06> { [ 6, period, notequal ] };
- key <AE07> { [ 7, underscore, ampersand ] };
- key <AE08> { [ 8, comma, asterisk ] };
- key <AE09> { [ 9, percent, bracketleft ] };
- key <AE10> { [ 0, question, bracketright ] };
- key <AE11> { [ Cyrillic_ie, Cyrillic_IE, X ] };
- key <AE12> { [ Cyrillic_shcha, Cyrillic_SHCHA, L ] };
-
- key <AD01> { [ Cyrillic_ef, Cyrillic_EF, apostrophe ] };
- key <AD02> { [ Cyrillic_tse, Cyrillic_TSE, grave ] };
- key <AD03> { [ Cyrillic_u, Cyrillic_U, EuroSign ] };
- key <AD04> { [ Cyrillic_zhe, Cyrillic_ZHE, registered ] };
- key <AD05> { [ Cyrillic_e, Cyrillic_E, trademark ] };
- key <AD06> { [ Cyrillic_en, Cyrillic_EN, yen ] };
- key <AD07> { [ Cyrillic_ghe, Cyrillic_GHE, doublelowquotemark ] };
- key <AD08> { [ Cyrillic_sha, Cyrillic_SHA, leftdoublequotemark ] };
- key <AD09> { [ Cyrillic_u_straight,Cyrillic_U_straight,rightdoublequotemark] };
- key <AD10> { [ Cyrillic_ze, Cyrillic_ZE, NoSymbol ] };
- key <AD11> { [ Cyrillic_ka, Cyrillic_KA, braceleft ] };
- key <AD12> { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, braceright ] };
-
- key <AC01> { [ Cyrillic_shorti, Cyrillic_SHORTI, mu ] };
- key <AC02> { [ Cyrillic_yeru, Cyrillic_YERU, sterling ] };
- key <AC03> { [ Cyrillic_be, Cyrillic_BE, dollar ] };
- key <AC04> { [ Cyrillic_o_bar, Cyrillic_O_bar, rightdoublequotemark ] };
- key <AC05> { [ Cyrillic_a, Cyrillic_A, Cyrillic_yeru ] };
- key <AC06> { [ Cyrillic_ha, Cyrillic_HA, Cyrillic_YERU ] };
- key <AC07> { [ Cyrillic_er, Cyrillic_ER, Cyrillic_e ] };
- key <AC08> { [ Cyrillic_o, Cyrillic_O, Cyrillic_E ] };
- key <AC09> { [ Cyrillic_el, Cyrillic_EL, numerosign ] };
- key <AC10> { [ Cyrillic_de, Cyrillic_DE, section ] };
- key <AC11> { [ Cyrillic_pe, Cyrillic_PE, ellipsis ] };
- key <BKSL> { [ exclam, bar, bar ] };
-
- key <LSGT> { [ parenleft, parenright, NoSymbol ] };
- key <AB01> { [ Cyrillic_ya, Cyrillic_YA, emdash ] };
- key <AB02> { [ Cyrillic_che, Cyrillic_CHE, endash ] };
- key <AB03> { [ Cyrillic_io, Cyrillic_IO, copyright ] };
- key <AB04> { [ Cyrillic_es, Cyrillic_ES, NoSymbol ] };
- key <AB05> { [ Cyrillic_em, Cyrillic_EM, NoSymbol ] };
- key <AB06> { [ Cyrillic_i, Cyrillic_I, less ] };
- key <AB07> { [ Cyrillic_te, Cyrillic_TE, greater ] };
- key <AB08> { [ Cyrillic_softsign, Cyrillic_SOFTSIGN, guillemotleft ] };
- key <AB09> { [ Cyrillic_ve, Cyrillic_VE, guillemotright ] };
- key <AB10> { [ Cyrillic_yu, Cyrillic_YU, backslash ] };
-
- // End alphanumeric section
-
- key <SPCE> { [ space, space, nobreakspace ] };
-
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc" {
-
-// Contact: Walter Bender <walter@laptop.org>
-
- include "mn(basic)"
-
- key <BKSL> { [ backslash, bar, exclam ] };
-
- include "group(olpc)"
-};
+// based on: +// Mongolian standard keyboard +// Author Sanlig Badral <badral@chinggis.com> +// 2002/12/7 Version 1.0 + +partial default alphanumeric_keys +xkb_symbols "basic" { + + name[Group1]= "Mongolia"; + + key <TLDE> { [ equal, plus, degree ] }; + key <AE01> { [ 1, numerosign, multiply ] }; + key <AE02> { [ 2, minus, division ] }; + key <AE03> { [ 3, quotedbl, plusminus ] }; + key <AE04> { [ 4, U20ae, notsign ] }; // Tugrik sign + key <AE05> { [ 5, colon, NoSymbol ] }; + key <AE06> { [ 6, period, notequal ] }; + key <AE07> { [ 7, underscore, ampersand ] }; + key <AE08> { [ 8, comma, asterisk ] }; + key <AE09> { [ 9, percent, bracketleft ] }; + key <AE10> { [ 0, question, bracketright ] }; + key <AE11> { [ Cyrillic_ie, Cyrillic_IE, X ] }; + key <AE12> { [ Cyrillic_shcha, Cyrillic_SHCHA, L ] }; + + key <AD01> { [ Cyrillic_ef, Cyrillic_EF, apostrophe ] }; + key <AD02> { [ Cyrillic_tse, Cyrillic_TSE, grave ] }; + key <AD03> { [ Cyrillic_u, Cyrillic_U, EuroSign ] }; + key <AD04> { [ Cyrillic_zhe, Cyrillic_ZHE, registered ] }; + key <AD05> { [ Cyrillic_e, Cyrillic_E, trademark ] }; + key <AD06> { [ Cyrillic_en, Cyrillic_EN, yen ] }; + key <AD07> { [ Cyrillic_ghe, Cyrillic_GHE, doublelowquotemark ] }; + key <AD08> { [ Cyrillic_sha, Cyrillic_SHA, leftdoublequotemark ] }; + key <AD09> { [ Cyrillic_u_straight,Cyrillic_U_straight,rightdoublequotemark] }; + key <AD10> { [ Cyrillic_ze, Cyrillic_ZE, NoSymbol ] }; + key <AD11> { [ Cyrillic_ka, Cyrillic_KA, braceleft ] }; + key <AD12> { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, braceright ] }; + + key <AC01> { [ Cyrillic_shorti, Cyrillic_SHORTI, mu ] }; + key <AC02> { [ Cyrillic_yeru, Cyrillic_YERU, sterling ] }; + key <AC03> { [ Cyrillic_be, Cyrillic_BE, dollar ] }; + key <AC04> { [ Cyrillic_o_bar, Cyrillic_O_bar, rightdoublequotemark ] }; + key <AC05> { [ Cyrillic_a, Cyrillic_A, Cyrillic_yeru ] }; + key <AC06> { [ Cyrillic_ha, Cyrillic_HA, Cyrillic_YERU ] }; + key <AC07> { [ Cyrillic_er, Cyrillic_ER, Cyrillic_e ] }; + key <AC08> { [ Cyrillic_o, Cyrillic_O, Cyrillic_E ] }; + key <AC09> { [ Cyrillic_el, Cyrillic_EL, numerosign ] }; + key <AC10> { [ Cyrillic_de, Cyrillic_DE, section ] }; + key <AC11> { [ Cyrillic_pe, Cyrillic_PE, ellipsis ] }; + key <BKSL> { [ exclam, bar, bar ] }; + + key <LSGT> { [ parenleft, parenright, NoSymbol ] }; + key <AB01> { [ Cyrillic_ya, Cyrillic_YA, emdash ] }; + key <AB02> { [ Cyrillic_che, Cyrillic_CHE, endash ] }; + key <AB03> { [ Cyrillic_io, Cyrillic_IO, copyright ] }; + key <AB04> { [ Cyrillic_es, Cyrillic_ES, NoSymbol ] }; + key <AB05> { [ Cyrillic_em, Cyrillic_EM, NoSymbol ] }; + key <AB06> { [ Cyrillic_i, Cyrillic_I, less ] }; + key <AB07> { [ Cyrillic_te, Cyrillic_TE, greater ] }; + key <AB08> { [ Cyrillic_softsign, Cyrillic_SOFTSIGN, guillemotleft ] }; + key <AB09> { [ Cyrillic_ve, Cyrillic_VE, guillemotright ] }; + key <AB10> { [ Cyrillic_yu, Cyrillic_YU, backslash ] }; + + // End alphanumeric section + + key <SPCE> { [ space, space, nobreakspace ] }; + + include "level3(ralt_switch)" +}; + +partial alphanumeric_keys +xkb_symbols "olpc" { + +// Contact: Walter Bender <walter@laptop.org> + + include "mn(basic)" + + key <AE07> { [ 7, semicolon, ampersand ] }; + + key <BKSL> { [ backslash, bar, exclam ] }; + + include "group(olpc)" +}; diff --git a/xorg-server/xkeyboard-config/symbols/np b/xorg-server/xkeyboard-config/symbols/np index 635fa348a..e139b0ff7 100644 --- a/xorg-server/xkeyboard-config/symbols/np +++ b/xorg-server/xkeyboard-config/symbols/np @@ -1,120 +1,121 @@ -// based on a keyboard map from an 'xkb/symbols/dev' file
-
-partial default alphanumeric_keys
-xkb_symbols "basic" {
-
- name[Group1]= "Nepal";
-
-// `,1,2,3,4,5,6,7,8,9,0,-,=
-
- key <TLDE> { [ 0x100093D,0x100093C ] };
- key <AE01> { [ 0x1000967 ] };
- key <AE02> { [ 0x1000968 ] };
- key <AE03> { [ 0x1000969 ] };
- key <AE04> { [ 0x100096A ] };
- key <AE05> { [ 0x100096B ] };
- key <AE06> { [ 0x100096C ] };
- key <AE07> { [ 0x100096D ] };
- key <AE08> { [ 0x100096e ] };
- key <AE09> { [ 0x100096F ] };
- key <AE10> { [ 0x1000966,0x1000970 ] };
- key <AE11> { [ minus, 0x1000952 ] };
- key <AE12> { [ equal, 0x100200C ] };
-
-// q,w,e,r,t,y,u,i,o,p,[,]
-
- key <AD01> { [ 0x100091F, 0x1000920 ] };
- key <AD02> { [ 0x100094C, 0x1000914 ] };
- key <AD03> { [ 0x1000947, 0x1000948 ] };
- key <AD04> { [ 0x1000930, 0x1000943 ] };
- key <AD05> { [ 0x1000924, 0x1000925 ] };
- key <AD06> { [ 0x100092F, 0x100091E ] };
- key <AD07> { [ 0x1000941, 0x1000942 ] };
- key <AD08> { [ 0x100093F, 0x1000940 ] };
- key <AD09> { [ 0x100094B, 0x1000913 ] };
- key <AD10> { [ 0x100092A, 0x100092B ] };
- key <AD11> { [ 0x1000907, 0x1000908 ] };
- key <AD12> { [ 0x100090F, 0x1000910 ] };
-
-// a,s,d,f,g,h,j,k,l,;,',Backslash
- key <AC01> { [ 0x100093E, 0x1000906 ] };
- key <AC02> { [ 0x1000938, 0x1000936 ] };
- key <AC03> { [ 0x1000926, 0x1000927 ] };
- key <AC04> { [ 0x1000909, 0x100090A ] };
- key <AC05> { [ 0x1000917, 0x1000918 ] };
- key <AC06> { [ 0x1000939, 0x1000905 ] };
- key <AC07> { [ 0x100091C, 0x100091D ] };
- key <AC08> { [ 0x1000915, 0x1000916 ] };
- key <AC09> { [ 0x1000932, 0x1000933 ] };
- key <AC10> { [ semicolon, colon ] };
- key <AC11> { [ quoteright, quotedbl ] };
- key <BKSL> { [ 0x1000950, 0x1000903 ] };
-
-
-// z,x,c,v,b,n,m,,,.,/
- key <AB01> { [ 0x1000937, 0x100090B ] };
- key <AB02> { [ 0x1000921, 0x1000922 ] };
- key <AB03> { [ 0x100091B, 0x100091A ] };
- key <AB04> { [ 0x1000935, 0x1000901 ] };
- key <AB05> { [ 0x100092C, 0x100092D ] };
- key <AB06> { [ 0x1000928, 0x1000923 ] };
- key <AB07> { [ 0x100092E, 0x1000902 ] };
- key <AB08> { [ comma, 0x1000919 ] };
- key <AB09> { [ 0x1000964, 0x1000965 ] };
- key <AB10> { [ 0x100094D, question ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc" {
-
-// Contact: Walter Bender <walter@laptop.org>
-
- include "np"
- key <TLDE> { [ grave, asciitilde ] };
- key <AE01> { [ 0x1000967 ] }; // Nepali digit one
- key <AE02> { [ 0x1000968 ] }; // Nepali digit two
- key <AE03> { [ 0x1000969 ] }; // Nepali digit three
- key <AE04> { [ 0x100096A ] }; // Nepali digit four
- key <AE05> { [ 0x100096B ] }; // Nepali digit five
- key <AE06> { [ 0x100096C, sterling ] }; // Nepali digit six
- key <AE07> { [ 0x100096D, eurosign ] }; // Nepali digit seven
- key <AE08> { [ 0x100096e ] }; // Nepali digit eight
- key <AE09> { [ 0x100096F ] }; // Nepali digit nine
- key <AE10> { [ 0x1000966 ] }; // Nepali digit zero
- key <AE12> { [ 0x1000950, 0x1000903 ] }; // OM, SIGN VISARGA
-
- key <AD01> { [ 0x100091C, 0x100091D ] }; // JA, JHA
- key <AD02> { [ 0x1000917, 0x1000918 ] }; // GA, GHA
- key <AD03> { [ 0x100092F, 0x100091E ] }; // YA, YNA
- key <AD04> { [ 0x1000938, 0x1000936 ] }; // SA, SHA
- key <AD05> { [ 0x100090F, 0x1000910 ] }; // E, AI
- key <AD06> { [ 0x100091B, 0x100091A ] }; // CHHA, CHA
- key <AD07> { [ 0x100092A, 0x100092B ] }; // PA, PHA
- key <AD08> { [ 0x1000947, 0x1000948 ] }; // VOWEL SIGN E, VOWEL SIGN AI
- key <AD09> { [ 0x100094B, 0x100093E ] }; // VOWEL SIGN O, VOWEL SIGN AA
- key <AD10> { [ 0x1000924, 0x1000925 ] }; // TA, THA
- key <AD11> { [ 0x1000909, 0x100090A ] }; // HRSHWA U, DIRGHA UU
- key <AD12> { [ 0x100093F, 0x1000940 ] }; // VOWEL SIGN HRSHWA I, VOWEL SIGN DIRGHA II
-
- key <AC01> { [ 0x100092E, 0x1000902 ] }; // MA, SIGN ANUSVARA
- key <AC02> { [ 0x1000907, 0x1000908 ] }; // HRSHWA I, DIRGHA II
- key <AC03> { [ 0x1000928, 0x1000923 ] }; // NA, NNA
- key <AC04> { [ 0x100094D, 0x1000921 ] }; // VIRAMA (HALANTA?), DDA
- key <AC05> { [ 0x100091F, 0x1000920 ] }; // TTA, TTHA
- key <AC06> { [ 0x1000926, 0x1000927 ] }; // DA, DHA
- key <AC07> { [ 0x100093E, 0x1000901 ] }; // SIGN AA, SIGN CANDRABINDU
- key <AC08> { [ 0x1000930, 0x1000943 ] }; // RA, VOWEL SIGN VOCALIC R
- key <AC09> { [ 0x1000915, 0x1000916 ] }; // KA, KHA
-
- key <AB01> { [ 0x1000937, 0x100090B ] }; // SSA, VOCALIC R (RRI)
- key <AB02> { [ 0x100092C, 0x100092D ] }; // BA, BHA
- key <AB03> { [ 0x1000941, 0x1000942 ] }; // VOWEL SIGN HRSHWA U, VOWEL SIGN DIRGHA U (UU)
- key <AB04> { [ 0x1000939, 0x1000922 ] }; // HA, DDHA
- key <AB05> { [ 0x1000913, 0x1000914 ] }; // O, AU
- key <AB06> { [ 0x1000905, 0x1000906 ] }; // A, AA
- key <AB07> { [ 0x1000932, 0x1000919 ] }; // LA, NGA
- key <AB08> { [ comma, 0x1000935 ] }; // VA
- key <AB09> { [ 0x1000964, 0x1000965 ] }; // PURNA VIRAM, DIRGHA VIRAM
-
- include "group(olpc)"
-};
+// based on a keyboard map from an 'xkb/symbols/dev' file + +partial default alphanumeric_keys +xkb_symbols "basic" { + + name[Group1]= "Nepal"; + +// `,1,2,3,4,5,6,7,8,9,0,-,= + + key <TLDE> { [ 0x100093D,0x100093C ] }; + key <AE01> { [ 0x1000967 ] }; + key <AE02> { [ 0x1000968 ] }; + key <AE03> { [ 0x1000969 ] }; + key <AE04> { [ 0x100096A ] }; + key <AE05> { [ 0x100096B ] }; + key <AE06> { [ 0x100096C ] }; + key <AE07> { [ 0x100096D ] }; + key <AE08> { [ 0x100096e ] }; + key <AE09> { [ 0x100096F ] }; + key <AE10> { [ 0x1000966,0x1000970 ] }; + key <AE11> { [ minus, 0x1000952 ] }; + key <AE12> { [ equal, 0x100200C ] }; + +// q,w,e,r,t,y,u,i,o,p,[,] + + key <AD01> { [ 0x100091F, 0x1000920 ] }; + key <AD02> { [ 0x100094C, 0x1000914 ] }; + key <AD03> { [ 0x1000947, 0x1000948 ] }; + key <AD04> { [ 0x1000930, 0x1000943 ] }; + key <AD05> { [ 0x1000924, 0x1000925 ] }; + key <AD06> { [ 0x100092F, 0x100091E ] }; + key <AD07> { [ 0x1000941, 0x1000942 ] }; + key <AD08> { [ 0x100093F, 0x1000940 ] }; + key <AD09> { [ 0x100094B, 0x1000913 ] }; + key <AD10> { [ 0x100092A, 0x100092B ] }; + key <AD11> { [ 0x1000907, 0x1000908 ] }; + key <AD12> { [ 0x100090F, 0x1000910 ] }; + +// a,s,d,f,g,h,j,k,l,;,',Backslash + key <AC01> { [ 0x100093E, 0x1000906 ] }; + key <AC02> { [ 0x1000938, 0x1000936 ] }; + key <AC03> { [ 0x1000926, 0x1000927 ] }; + key <AC04> { [ 0x1000909, 0x100090A ] }; + key <AC05> { [ 0x1000917, 0x1000918 ] }; + key <AC06> { [ 0x1000939, 0x1000905 ] }; + key <AC07> { [ 0x100091C, 0x100091D ] }; + key <AC08> { [ 0x1000915, 0x1000916 ] }; + key <AC09> { [ 0x1000932, 0x1000933 ] }; + key <AC10> { [ semicolon, colon ] }; + key <AC11> { [ quoteright, quotedbl ] }; + key <BKSL> { [ 0x1000950, 0x1000903 ] }; + + +// z,x,c,v,b,n,m,,,.,/ + key <AB01> { [ 0x1000937, 0x100090B ] }; + key <AB02> { [ 0x1000921, 0x1000922 ] }; + key <AB03> { [ 0x100091B, 0x100091A ] }; + key <AB04> { [ 0x1000935, 0x1000901 ] }; + key <AB05> { [ 0x100092C, 0x100092D ] }; + key <AB06> { [ 0x1000928, 0x1000923 ] }; + key <AB07> { [ 0x100092E, 0x1000902 ] }; + key <AB08> { [ comma, 0x1000919 ] }; + key <AB09> { [ 0x1000964, 0x1000965 ] }; + key <AB10> { [ 0x100094D, question ] }; +}; + +partial alphanumeric_keys + +xkb_symbols "olpc" { +// Contact: Walter Bender <walter@laptop.org> + + include "np" + key <TLDE> { [ 0x100091E, 0x1000965 ] }; // NYA; double danda + key <AE01> { [ 0x1000967, 0x10FFFFD ] }; // Nepali digit one; U091C+U094D+U091E + key <AE02> { [ 0x1000968, 0x1000908 ] }; // Nepali digit two; key <AE03> { [ 0x1000969, 0x1000918 ] }; // Nepali digit three; + key <AE04> { [ 0x100096A, 0x10FFFFC ] }; // Nepali digit four; U0926+U094D+U0927 + key <AE05> { [ 0x100096B, 0x100091B ] }; // Nepali digit five + key <AE06> { [ 0x100096C, 0x100091F ] }; // Nepali digit six + key <AE07> { [ 0x100096D, 0x1000920 ] }; // Nepali digit seven + key <AE08> { [ 0x100096e, 0x1000921 ] }; // Nepali digit eight + key <AE09> { [ 0x100096F, 0x1000922 ] }; // Nepali digit nine + key <AE10> { [ 0x1000966, 0x1000923 ] }; // Nepali digit zero + key <AE11> { [ 0x1000914, 0x1000913 ] }; // O, AU + key <AE12> { [ 0x100200C, 0x1000902 ] }; // ZERO-WIDTH-NON-JOINER (ZWNJ); SIGN ANUSVARA + key <BKSL> { [ 0x100094D, 0x100200D ] }; // SIGN VIRAMA; ZERO-WIDTH-JOINER (ZWJ) + key <AD01> { [ 0x10FFFFB, 0x10FFFFA ] }; // U0924+U094D+U0930; U0924+U094D+U0924 + key <AD02> { [ 0x1000927, 0x10FFFF9 ] }; // DHA; U0921+U094D+U0922 + key <AD03> { [ 0x100092D, 0x1000910 ] }; // BHA, AI + key <AD04> { [ 0x100091A, 0x10FFFF8 ] }; // CA; U0926+U094D+U0935 + key <AD05> { [ 0x1000924, 0x10FFFF7 ] }; // TA; U091F+U094D+U091F + key <AD06> { [ 0x1000925, 0x10FFFF6 ] }; // THA; U0920+U094D+U0920 + key <AD07> { [ 0x1000917, 0x100090A ] }; // GA, UU + key <AD08> { [ 0x1000937, 0x10FFFF5 ] }; // SSA; U0915+U094D+U0937 + key <AD09> { [ 0x100092F, 0x1000907 ] }; // YA, I + key <AD10> { [ 0x1000909, 0x100090F ] }; // U, E + key <AD11> { [ 0x10FFFF4, 0x1000943 ] }; // U0928+U094D+ZWJ; VOWEL SIGN VOCALIC R + key <AD12> { [ 0x1000947, 0x1000948 ] }; // SIGN E; SIGN AI + key <AC01> { [ 0x100092C, 0x1000906 ] }; // BA, AA + key <AC02> { [ 0x1000915, 0x10FFFF3 ] }; // KA; U0919+U094D+U0915 + key <AC03> { [ 0x100092E, 0x10FFFF2 ] }; // MA; U0919+U094D+U0917 + key <AC04> { [ 0x100093E, 0x1000901 ] }; // CANDRABINDU, VOWEL SIGN AA + key <AC05> { [ 0x1000928, 0x10FFFF1 ] }; // NA; U0926+U094D+U0926 + key <AC06> { [ 0x100091C, 0x100091D ] }; // JA, JHA + key <AC07> { [ 0x1000935, 0x100094B ] }; // VA, VOWEL SIGN O + key <AC08> { [ 0x100092A, 0x100092B ] }; // PA, PHA + key <AC09> { [ 0x100093F, 0x1000940 ] }; // VOWEL SIGN I, VOWEL SIGN II + key <AC10> { [ 0x1000938, 0x10FFFF0 ] }; // SA; U091F+U094D+U0920 + key <AC11> { [ 0x1000941, 0x1000942 ] }; // VOWEL SIGN U, VOWEL SIGN UU + key <AB01> { [ 0x1000936, 0x10FFFEF ] }; // SHA; U0915+U094D+U0915 + key <AB02> { [ 0x1000939, 0x10FFFEE ] }; // HA; U0939+U094D+U092F + key <AB03> { [ 0x1000905, 0x100090B ] }; // A; U0909+U090B + key <AB04> { [ 0x1000916, 0x1000950 ] }; // KHA, OM + key <AB05> { [ 0x1000926, 0x100094C ] }; // DA, VOWEL SIGN AU + key <AB06> { [ 0x1000932, 0x10FFFED ] }; // LA; U0926+U094D+U092F + key <AB07> { [ 0x1000903, 0x10FFFEC ] }; // SIGN VISARGA; U0921+U094D+U0921 + key <AB08> { [ 0x100093D, 0x1000919 ] }; // SIGN AVAGRHA; NGA + key <AB09> { [ 0x1000964, 0x10FFFEB ] }; // DANDA; U0936+U094D+U0930 + key <AB10> { [ 0x1000930, 0x10FFFEA ] }; // RA; U0930+U0941 + + include "group(olpc)" +}; |