diff options
49 files changed, 2146 insertions, 1864 deletions
diff --git a/mesalib/configs/autoconf.in b/mesalib/configs/autoconf.in index 38fe3179f..3de341241 100644 --- a/mesalib/configs/autoconf.in +++ b/mesalib/configs/autoconf.in @@ -75,7 +75,6 @@ GLESv1_CM_LIB = GLESv1_CM GLESv2_LIB = GLESv2 VG_LIB = OpenVG GLAPI_LIB = glapi -WAYLAND_EGL_LIB = wayland-egl # Library names (actual file names) GL_LIB_NAME = @GL_LIB_NAME@ @@ -87,7 +86,6 @@ GLESv1_CM_LIB_NAME = @GLESv1_CM_LIB_NAME@ GLESv2_LIB_NAME = @GLESv2_LIB_NAME@ VG_LIB_NAME = @VG_LIB_NAME@ GLAPI_LIB_NAME = @GLAPI_LIB_NAME@ -WAYLAND_EGL_LIB_NAME = @WAYLAND_EGL_LIB_NAME@ # Globs used to install the lib and all symlinks GL_LIB_GLOB = @GL_LIB_GLOB@ @@ -99,7 +97,6 @@ GLESv1_CM_LIB_GLOB = @GLESv1_CM_LIB_GLOB@ GLESv2_LIB_GLOB = @GLESv2_LIB_GLOB@ VG_LIB_GLOB = @VG_LIB_GLOB@ GLAPI_LIB_GLOB = @GLAPI_LIB_GLOB@ -WAYLAND_EGL_LIB_GLOB = @WAYLAND_EGL_LIB_GLOB@ # Directories to build LIB_DIR = @LIB_DIR@ @@ -143,7 +140,6 @@ GLESv1_CM_LIB_DEPS = $(EXTRA_LIB_PATH) @GLESv1_CM_LIB_DEPS@ GLESv2_LIB_DEPS = $(EXTRA_LIB_PATH) @GLESv2_LIB_DEPS@ VG_LIB_DEPS = $(EXTRA_LIB_PATH) @VG_LIB_DEPS@ GLAPI_LIB_DEPS = $(EXTRA_LIB_PATH) @GLAPI_LIB_DEPS@ -WAYLAND_EGL_LIB_DEPS = $(EXTRA_LIB_PATH) @WAYLAND_EGL_LIB_DEPS@ # DRI dependencies MESA_MODULES = @MESA_MODULES@ @@ -202,9 +198,6 @@ GLESv2_PC_LIB_PRIV = @GLESv2_PC_LIB_PRIV@ EGL_PC_REQ_PRIV = @GL_PC_REQ_PRIV@ EGL_PC_LIB_PRIV = @GL_PC_LIB_PRIV@ EGL_PC_CFLAGS = @GL_PC_CFLAGS@ -WAYLAND_EGL_PC_REQ_PRIV = @WAYLAND_EGL_PC_REQ_PRIV@ -WAYLAND_EGL_PC_LIB_PRIV = @WAYLAND_EGL_PC_LIB_PRIV@ -WAYLAND_EGL_PC_CFLAGS = @WAYLAND_EGL_PC_CFLAGS@ XCB_DRI2_CFLAGS = @XCB_DRI2_CFLAGS@ XCB_DRI2_LIBS = @XCB_DRI2_LIBS@ diff --git a/mesalib/configs/default b/mesalib/configs/default index 7e1aceb6b..43cb51076 100644 --- a/mesalib/configs/default +++ b/mesalib/configs/default @@ -62,7 +62,6 @@ GLESv1_CM_LIB = GLESv1_CM GLESv2_LIB = GLESv2 VG_LIB = OpenVG GLAPI_LIB = glapi -WAYLAND_EGL_LIB = wayland-egl # Library names (actual file names) GL_LIB_NAME = lib$(GL_LIB).so @@ -74,7 +73,6 @@ GLESv1_CM_LIB_NAME = lib$(GLESv1_CM_LIB).so GLESv2_LIB_NAME = lib$(GLESv2_LIB).so VG_LIB_NAME = lib$(VG_LIB).so GLAPI_LIB_NAME = lib$(GLAPI_LIB).so -WAYLAND_EGL_LIB_NAME = lib$(WAYLAND_EGL_LIB).so # globs used to install the lib and all symlinks GL_LIB_GLOB = $(GL_LIB_NAME)* @@ -86,7 +84,6 @@ GLESv1_CM_LIB_GLOB = $(GLESv1_CM_LIB_NAME)* GLESv2_LIB_GLOB = $(GLESv2_LIB_NAME)* VG_LIB_GLOB = $(VG_LIB_NAME)* GLAPI_LIB_GLOB = $(GLAPI_LIB_NAME)* -WAYLAND_EGL_LIB_GLOB = $(WAYLAND_EGL_LIB_NAME)* DRI_CFLAGS = $(CFLAGS) DRI_CXXFLAGS = $(CXXFLAGS) @@ -134,7 +131,6 @@ GLESv1_CM_LIB_DEPS = $(EXTRA_LIB_PATH) -lpthread GLESv2_LIB_DEPS = $(EXTRA_LIB_PATH) -lpthread VG_LIB_DEPS = $(EXTRA_LIB_PATH) -lpthread GLAPI_LIB_DEPS = $(EXTRA_LIB_PATH) -lpthread -WAYLAND_EGL_LIB_DEPS = $(EXTRA_LIB_PATH) -lwayland-client -ldrm # Program dependencies - specific GL libraries added in Makefiles X11_LIBS = -lX11 @@ -179,6 +175,3 @@ GLESv2_PC_CFLAGS = VG_PC_REQ_PRIV = VG_PC_LIB_PRIV = VG_PC_CFLAGS = -WAYLAND_EGL_PC_REQ_PRIV = -WAYLAND_EGL_PC_LIB_PRIV = -WAYLAND_EGL_PC_CFLAGS = diff --git a/mesalib/configure.ac b/mesalib/configure.ac index 2472cc141..06d400f15 100644 --- a/mesalib/configure.ac +++ b/mesalib/configure.ac @@ -97,13 +97,13 @@ AC_COMPILE_IFELSE( not clang #endif ]])], -[CLANG=yes], [CLANG=no]) +[acv_mesa_CLANG=yes], [acv_mesa_CLANG=no]) -AC_MSG_RESULT([$CLANG]) +AC_MSG_RESULT([$acv_mesa_CLANG]) dnl If we're using GCC, make sure that it is at least version 3.3.0. Older dnl versions are explictly not supported. -if test "x$GCC" = xyes -a "x$CLANG" = xno; then +if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then AC_MSG_CHECKING([whether gcc version is sufficient]) major=0 minor=0 @@ -273,39 +273,9 @@ if test "x$enable_64bit" = xyes; then fi fi -dnl -dnl shared/static libraries, mimic libtool options -dnl -AC_ARG_ENABLE([static], - [AS_HELP_STRING([--enable-static], - [build static libraries @<:@default=disabled@:>@])], - [enable_static="$enableval"], - [enable_static=no] -) -case "x$enable_static" in -xyes|xno ) ;; -x ) enable_static=no ;; -* ) - AC_MSG_ERROR([Static library option '$enable_static' is not a valid]) - ;; -esac -AC_ARG_ENABLE([shared], - [AS_HELP_STRING([--disable-shared], - [build shared libraries @<:@default=enabled@:>@])], - [enable_shared="$enableval"], - [enable_shared=yes] -) -case "x$enable_shared" in -xyes|xno ) ;; -x ) enable_shared=yes ;; -* ) - AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid]) - ;; -esac - dnl Can't have static and shared libraries, default to static if user dnl explicitly requested. If both disabled, set to static since shared -dnl was explicitly requirested. +dnl was explicitly requested. case "x$enable_static$enable_shared" in xyesyes ) AC_MSG_WARN([Can't build static and shared libraries, disabling shared]) @@ -413,7 +383,6 @@ GLESv1_CM_LIB_NAME='lib$(GLESv1_CM_LIB).'${LIB_EXTENSION} GLESv2_LIB_NAME='lib$(GLESv2_LIB).'${LIB_EXTENSION} VG_LIB_NAME='lib$(VG_LIB).'${LIB_EXTENSION} GLAPI_LIB_NAME='lib$(GLAPI_LIB).'${LIB_EXTENSION} -WAYLAND_EGL_LIB_NAME='lib$(WAYLAND_EGL_LIB).'${LIB_EXTENSION} GL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' GLU_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLU_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' @@ -424,7 +393,6 @@ GLESv1_CM_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv1_CM_LIB)'${LIB_VERSION_SEPARATOR}' GLESv2_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv2_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' VG_LIB_GLOB=${LIB_PREFIX_GLOB}'$(VG_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' GLAPI_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLAPI_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' -WAYLAND_EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(WAYLAND_EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*' AC_SUBST([GL_LIB_NAME]) AC_SUBST([GLU_LIB_NAME]) @@ -434,7 +402,6 @@ AC_SUBST([GLESv1_CM_LIB_NAME]) AC_SUBST([GLESv2_LIB_NAME]) AC_SUBST([VG_LIB_NAME]) AC_SUBST([GLAPI_LIB_NAME]) -AC_SUBST([WAYLAND_EGL_LIB_NAME]) AC_SUBST([GL_LIB_GLOB]) AC_SUBST([GLU_LIB_GLOB]) @@ -444,7 +411,6 @@ AC_SUBST([GLESv1_CM_LIB_GLOB]) AC_SUBST([GLESv2_LIB_GLOB]) AC_SUBST([VG_LIB_GLOB]) AC_SUBST([GLAPI_LIB_GLOB]) -AC_SUBST([WAYLAND_EGL_LIB_GLOB]) dnl dnl Arch/platform-specific settings @@ -1687,7 +1653,6 @@ AC_ARG_WITH([egl-platforms], [with_egl_platforms=yes]) EGL_PLATFORMS="" -WAYLAND_EGL_LIB_DEPS="" case "$with_egl_platforms" in yes) @@ -1703,7 +1668,7 @@ yes) egl_platforms=`IFS=', '; echo $with_egl_platforms` for plat in $egl_platforms; do test -d "$srcdir/src/gallium/state_trackers/egl/$plat" || \ - AC_MSG_ERROR([EGL platform '$plat' doesn't exist]) + AC_MSG_ERROR([EGL platform '$plat' does not exist]) if test "$plat" = "fbdev"; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/fbdev" fi @@ -1713,8 +1678,10 @@ yes) if test "$plat" = "wayland"; then PKG_CHECK_MODULES([WAYLAND], [wayland-client wayland-server],, \ [AC_MSG_ERROR([cannot find libwayland-client])]) - WAYLAND_EGL_LIB_DEPS="$WAYLAND_LIBS $LIBDRM_LIBS" GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/wayland" + + m4_ifdef([WAYLAND_SCANNER_RULES], + [WAYLAND_SCANNER_RULES(['$(top_srcdir)/src/egl/wayland/wayland-drm/protocol'])]) fi if test "$plat" = "drm" && test "x$enable_gbm" = "xno"; then AC_MSG_ERROR([EGL platform drm needs gbm]) @@ -1729,16 +1696,6 @@ yes) esac AC_SUBST([EGL_PLATFORMS]) -AC_SUBST([WAYLAND_EGL_LIB_DEPS]) -WAYLAND_EGL_PC_REQ_PRIV="wayland-client libdrm" -WAYLAND_EGL_PC_LIB_PRIV= -WAYLAND_EGL_PC_CFLAGS= - -AC_SUBST([WAYLAND_EGL_PC_REQ_PRIV]) -AC_SUBST([WAYLAND_EGL_PC_LIB_PRIV]) -AC_SUBST([WAYLAND_EGL_PC_CFLAGS]) - - AC_ARG_WITH([egl-driver-dir], [AS_HELP_STRING([--with-egl-driver-dir=DIR], [directory for EGL drivers [[default=${libdir}/egl]]])], @@ -1946,8 +1903,13 @@ dnl Substitute the config AC_CONFIG_FILES([configs/autoconf src/gbm/Makefile src/gbm/main/gbm.pc + src/egl/wayland/Makefile + src/egl/wayland/wayland-egl/Makefile + src/egl/wayland/wayland-egl/wayland-egl.pc + src/egl/wayland/wayland-drm/Makefile src/mesa/drivers/dri/dri.pc src/mesa/drivers/dri/Makefile + src/mesa/drivers/dri/common/Makefile src/mesa/drivers/dri/i915/Makefile src/mesa/drivers/dri/i965/Makefile src/mesa/drivers/dri/nouveau/Makefile diff --git a/mesalib/src/mapi/glapi/SConscript b/mesalib/src/mapi/glapi/SConscript index dad7d5972..9882806ce 100644 --- a/mesalib/src/mapi/glapi/SConscript +++ b/mesalib/src/mapi/glapi/SConscript @@ -38,7 +38,6 @@ glapi_sources = [ mapi_sources = [ 'u_current.c', 'u_execmem.c', - 'u_thread.c', ] for s in mapi_sources: o = env.SharedObject(s[:-2], '../mapi/' + s) diff --git a/mesalib/src/mapi/mapi/sources.mak b/mesalib/src/mapi/mapi/sources.mak index c50234b57..28141860f 100644 --- a/mesalib/src/mapi/mapi/sources.mak +++ b/mesalib/src/mapi/mapi/sources.mak @@ -16,8 +16,7 @@ MAPI_UTIL_SOURCES = \ u_current.c \ - u_execmem.c \ - u_thread.c + u_execmem.c MAPI_SOURCES = \ entry.c \ diff --git a/mesalib/src/mapi/mapi/u_thread.c b/mesalib/src/mapi/mapi/u_thread.c deleted file mode 100644 index 7b52ca99b..000000000 --- a/mesalib/src/mapi/mapi/u_thread.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul 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. - */ - - -#include <stdio.h> -#include <stdlib.h> -#include "u_compiler.h" -#include "u_thread.h" - - -/* - * This file should still compile even when THREADS is not defined. - * This is to make things easier to deal with on the makefile scene.. - */ -#ifdef THREADS -#include <errno.h> - -/* - * Error messages - */ -#define INIT_TSD_ERROR "_glthread_: failed to allocate key for thread specific data" -#define GET_TSD_ERROR "_glthread_: failed to get thread specific data" -#define SET_TSD_ERROR "_glthread_: thread failed to set thread specific data" - - -/* - * Magic number to determine if a TSD object has been initialized. - * Kind of a hack but there doesn't appear to be a better cross-platform - * solution. - */ -#define INIT_MAGIC 0xff8adc98 - - - -/* - * POSIX Threads -- The best way to go if your platform supports them. - * Solaris >= 2.5 have POSIX threads, IRIX >= 6.4 reportedly - * has them, and many of the free Unixes now have them. - * Be sure to use appropriate -mt or -D_REENTRANT type - * compile flags when building. - */ -#ifdef PTHREADS - -unsigned long -u_thread_self(void) -{ - return (unsigned long) pthread_self(); -} - - -void -u_tsd_init(struct u_tsd *tsd) -{ - if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) { - perror(INIT_TSD_ERROR); - exit(-1); - } - tsd->initMagic = INIT_MAGIC; -} - - -void * -u_tsd_get(struct u_tsd *tsd) -{ - if (tsd->initMagic != (int) INIT_MAGIC) { - u_tsd_init(tsd); - } - return pthread_getspecific(tsd->key); -} - - -void -u_tsd_set(struct u_tsd *tsd, void *ptr) -{ - if (tsd->initMagic != (int) INIT_MAGIC) { - u_tsd_init(tsd); - } - if (pthread_setspecific(tsd->key, ptr) != 0) { - perror(SET_TSD_ERROR); - exit(-1); - } -} - -#endif /* PTHREADS */ - - - -/* - * Win32 Threads. The only available option for Windows 95/NT. - * Be sure that you compile using the Multithreaded runtime, otherwise - * bad things will happen. - */ -#ifdef WIN32 - -unsigned long -u_thread_self(void) -{ - return GetCurrentThreadId(); -} - - -void -u_tsd_init(struct u_tsd *tsd) -{ - tsd->key = TlsAlloc(); - if (tsd->key == TLS_OUT_OF_INDEXES) { - perror(INIT_TSD_ERROR); - exit(-1); - } - tsd->initMagic = INIT_MAGIC; -} - - -void -u_tsd_destroy(struct u_tsd *tsd) -{ - if (tsd->initMagic != INIT_MAGIC) { - return; - } - TlsFree(tsd->key); - tsd->initMagic = 0x0; -} - - -void * -u_tsd_get(struct u_tsd *tsd) -{ - if (tsd->initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - return TlsGetValue(tsd->key); -} - - -void -u_tsd_set(struct u_tsd *tsd, void *ptr) -{ - /* the following code assumes that the struct u_tsd has been initialized - to zero at creation */ - if (tsd->initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - if (TlsSetValue(tsd->key, ptr) == 0) { - perror(SET_TSD_ERROR); - exit(-1); - } -} - -#endif /* WIN32 */ - - -#else /* THREADS */ - - -/* - * no-op functions - */ - -unsigned long -u_thread_self(void) -{ - return 0; -} - - -void -u_tsd_init(struct u_tsd *tsd) -{ - (void) tsd; -} - - -void * -u_tsd_get(struct u_tsd *tsd) -{ - (void) tsd; - return NULL; -} - - -void -u_tsd_set(struct u_tsd *tsd, void *ptr) -{ - (void) tsd; - (void) ptr; -} - - -#endif /* THREADS */ diff --git a/mesalib/src/mapi/mapi/u_thread.h b/mesalib/src/mapi/mapi/u_thread.h index 7db22b793..ffe17b207 100644 --- a/mesalib/src/mapi/mapi/u_thread.h +++ b/mesalib/src/mapi/mapi/u_thread.h @@ -42,6 +42,8 @@ #ifndef _U_THREAD_H_ #define _U_THREAD_H_ +#include <stdio.h> +#include <stdlib.h> #include "u_compiler.h" #if defined(PTHREADS) @@ -57,6 +59,20 @@ #endif #endif +/* + * Error messages + */ +#define INIT_TSD_ERROR "_glthread_: failed to allocate key for thread specific data" +#define GET_TSD_ERROR "_glthread_: failed to get thread specific data" +#define SET_TSD_ERROR "_glthread_: thread failed to set thread specific data" + + +/* + * Magic number to determine if a TSD object has been initialized. + * Kind of a hack but there doesn't appear to be a better cross-platform + * solution. + */ +#define INIT_MAGIC 0xff8adc98 #ifdef __cplusplus extern "C" { @@ -76,7 +92,7 @@ extern "C" { struct u_tsd { pthread_key_t key; - int initMagic; + unsigned initMagic; }; typedef pthread_mutex_t u_mutex; @@ -89,6 +105,46 @@ typedef pthread_mutex_t u_mutex; #define u_mutex_lock(name) (void) pthread_mutex_lock(&(name)) #define u_mutex_unlock(name) (void) pthread_mutex_unlock(&(name)) +static INLINE unsigned long +u_thread_self(void) +{ + return (unsigned long) pthread_self(); +} + + +static INLINE void +u_tsd_init(struct u_tsd *tsd) +{ + if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) { + perror(INIT_TSD_ERROR); + exit(-1); + } + tsd->initMagic = INIT_MAGIC; +} + + +static INLINE void * +u_tsd_get(struct u_tsd *tsd) +{ + if (tsd->initMagic != INIT_MAGIC) { + u_tsd_init(tsd); + } + return pthread_getspecific(tsd->key); +} + + +static INLINE void +u_tsd_set(struct u_tsd *tsd, void *ptr) +{ + if (tsd->initMagic != INIT_MAGIC) { + u_tsd_init(tsd); + } + if (pthread_setspecific(tsd->key, ptr) != 0) { + perror(SET_TSD_ERROR); + exit(-1); + } +} + #endif /* PTHREADS */ @@ -101,7 +157,7 @@ typedef pthread_mutex_t u_mutex; struct u_tsd { DWORD key; - int initMagic; + unsigned initMagic; }; typedef CRITICAL_SECTION u_mutex; @@ -115,6 +171,60 @@ typedef CRITICAL_SECTION u_mutex; #define u_mutex_lock(name) EnterCriticalSection(&name) #define u_mutex_unlock(name) LeaveCriticalSection(&name) +static INLINE unsigned long +u_thread_self(void) +{ + return GetCurrentThreadId(); +} + + +static INLINE void +u_tsd_init(struct u_tsd *tsd) +{ + tsd->key = TlsAlloc(); + if (tsd->key == TLS_OUT_OF_INDEXES) { + perror(INIT_TSD_ERROR); + exit(-1); + } + tsd->initMagic = INIT_MAGIC; +} + + +static INLINE void +u_tsd_destroy(struct u_tsd *tsd) +{ + if (tsd->initMagic != INIT_MAGIC) { + return; + } + TlsFree(tsd->key); + tsd->initMagic = 0x0; +} + + +static INLINE void * +u_tsd_get(struct u_tsd *tsd) +{ + if (tsd->initMagic != INIT_MAGIC) { + u_tsd_init(tsd); + } + return TlsGetValue(tsd->key); +} + + +static INLINE void +u_tsd_set(struct u_tsd *tsd, void *ptr) +{ + /* the following code assumes that the struct u_tsd has been initialized + to zero at creation */ + if (tsd->initMagic != INIT_MAGIC) { + u_tsd_init(tsd); + } + if (TlsSetValue(tsd->key, ptr) == 0) { + perror(SET_TSD_ERROR); + exit(-1); + } +} + #endif /* WIN32 */ @@ -124,7 +234,7 @@ typedef CRITICAL_SECTION u_mutex; #ifndef THREADS struct u_tsd { - int initMagic; + unsigned initMagic; }; typedef unsigned u_mutex; @@ -135,23 +245,39 @@ typedef unsigned u_mutex; #define u_mutex_lock(name) (void) name #define u_mutex_unlock(name) (void) name -#endif /* THREADS */ +/* + * no-op functions + */ + +static INLINE unsigned long +u_thread_self(void) +{ + return 0; +} -unsigned long -u_thread_self(void); +static INLINE void +u_tsd_init(struct u_tsd *tsd) +{ + (void) tsd; +} -void -u_tsd_init(struct u_tsd *tsd); -void -u_tsd_destroy(struct u_tsd *tsd); /* WIN32 only */ +static INLINE void * +u_tsd_get(struct u_tsd *tsd) +{ + (void) tsd; + return NULL; +} -void * -u_tsd_get(struct u_tsd *tsd); -void -u_tsd_set(struct u_tsd *tsd, void *ptr); +static INLINE void +u_tsd_set(struct u_tsd *tsd, void *ptr) +{ + (void) tsd; + (void) ptr; +} +#endif /* THREADS */ #ifdef __cplusplus diff --git a/mesalib/src/mesa/drivers/dri/Makefile.am b/mesalib/src/mesa/drivers/dri/Makefile.am index 3722082eb..8b9358221 100644 --- a/mesalib/src/mesa/drivers/dri/Makefile.am +++ b/mesalib/src/mesa/drivers/dri/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS= +SUBDIRS = common if HAVE_I915_DRI SUBDIRS+=i915 diff --git a/mesalib/src/mesa/drivers/dri/common/Makefile.am b/mesalib/src/mesa/drivers/dri/common/Makefile.am new file mode 100644 index 000000000..4b43f4409 --- /dev/null +++ b/mesalib/src/mesa/drivers/dri/common/Makefile.am @@ -0,0 +1,37 @@ +# Copyright © 2012 Intel Corporation +# +# 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. + +AM_CFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/src/ \ + -I$(top_srcdir)/src/mapi \ + -I$(top_srcdir)/src/mesa/ \ + $(DEFINES) \ + $(ASM_FLAGS) \ + $(API_DEFINES) \ + $(LIBDRM_CFLAGS) + +noinst_LTLIBRARIES = libdricommon.la + +libdricommon_la_SOURCES = \ + utils.c \ + dri_util.c \ + xmlconfig.c diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index 75f6e9bb6..7238a2d60 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -520,17 +520,29 @@ _mesa_copy_buffer_subdata(struct gl_context *ctx, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { - void *srcPtr, *dstPtr; + GLubyte *srcPtr, *dstPtr; /* the buffers should not be mapped */ assert(!_mesa_bufferobj_mapped(src)); assert(!_mesa_bufferobj_mapped(dst)); - srcPtr = ctx->Driver.MapBufferRange(ctx, readOffset, size, - GL_MAP_READ_BIT, src); - dstPtr = ctx->Driver.MapBufferRange(ctx, writeOffset, size, - (GL_MAP_WRITE_BIT | - GL_MAP_INVALIDATE_RANGE_BIT), dst); + if (src == dst) { + srcPtr = dstPtr = ctx->Driver.MapBufferRange(ctx, 0, src->Size, + GL_MAP_READ_BIT | + GL_MAP_WRITE_BIT, src); + + if (!srcPtr) + return; + + srcPtr += readOffset; + dstPtr += writeOffset; + } else { + srcPtr = ctx->Driver.MapBufferRange(ctx, readOffset, size, + GL_MAP_READ_BIT, src); + dstPtr = ctx->Driver.MapBufferRange(ctx, writeOffset, size, + (GL_MAP_WRITE_BIT | + GL_MAP_INVALIDATE_RANGE_BIT), dst); + } /* Note: the src and dst regions will never overlap. Trying to do so * would generate GL_INVALID_VALUE earlier. @@ -539,7 +551,8 @@ _mesa_copy_buffer_subdata(struct gl_context *ctx, memcpy(dstPtr, srcPtr, size); ctx->Driver.UnmapBuffer(ctx, src); - ctx->Driver.UnmapBuffer(ctx, dst); + if (dst != src) + ctx->Driver.UnmapBuffer(ctx, dst); } diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c index 95b8211b2..677debffc 100644 --- a/mesalib/src/mesa/main/dlist.c +++ b/mesalib/src/mesa/main/dlist.c @@ -46,6 +46,9 @@ #include "dlist.h" #include "enums.h" #include "eval.h" +#if FEATURE_EXT_framebuffer_object +#include "fbobject.h" +#endif #include "framebuffer.h" #include "glapi/glapi.h" #include "hash.h" @@ -10112,6 +10115,24 @@ _mesa_create_save_table(void) SET_GenVertexArraysAPPLE(table, _mesa_GenVertexArraysAPPLE); SET_IsVertexArrayAPPLE(table, _mesa_IsVertexArrayAPPLE); + /* 310. GL_EXT_framebuffer_object */ + SET_GenFramebuffersEXT(table, _mesa_GenFramebuffersEXT); + SET_BindFramebufferEXT(table, _mesa_BindFramebufferEXT); + SET_DeleteFramebuffersEXT(table, _mesa_DeleteFramebuffersEXT); + SET_CheckFramebufferStatusEXT(table, _mesa_CheckFramebufferStatusEXT); + SET_GenRenderbuffersEXT(table, _mesa_GenRenderbuffersEXT); + SET_BindRenderbufferEXT(table, _mesa_BindRenderbufferEXT); + SET_DeleteRenderbuffersEXT(table, _mesa_DeleteRenderbuffersEXT); + SET_RenderbufferStorageEXT(table, _mesa_RenderbufferStorageEXT); + SET_FramebufferTexture1DEXT(table, _mesa_FramebufferTexture1DEXT); + SET_FramebufferTexture2DEXT(table, _mesa_FramebufferTexture2DEXT); + SET_FramebufferTexture3DEXT(table, _mesa_FramebufferTexture3DEXT); + SET_FramebufferRenderbufferEXT(table, _mesa_FramebufferRenderbufferEXT); + SET_GenerateMipmapEXT(table, _mesa_GenerateMipmapEXT); + + /* 317. GL_EXT_framebuffer_multisample */ + SET_RenderbufferStorageMultisample(table, _mesa_RenderbufferStorageMultisample); + /* GL_ARB_vertex_array_object */ SET_BindVertexArray(table, _mesa_BindVertexArray); SET_GenVertexArrays(table, _mesa_GenVertexArrays); diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c index ff98c69cd..a2d889116 100644 --- a/mesalib/src/mesa/main/format_unpack.c +++ b/mesalib/src/mesa/main/format_unpack.c @@ -2210,6 +2210,58 @@ unpack_int_rgba_RG_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) } static void +unpack_int_rgba_RG_UINT16(const GLushort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i * 2 + 0]; + dst[i][1] = src[i * 2 + 1]; + dst[i][2] = 0; + dst[i][3] = 1; + } +} + +static void +unpack_int_rgba_RG_INT16(const GLshort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i * 2 + 0]; + dst[i][1] = src[i * 2 + 1]; + dst[i][2] = 0; + dst[i][3] = 1; + } +} + +static void +unpack_int_rgba_RG_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i * 2 + 0]; + dst[i][1] = src[i * 2 + 1]; + dst[i][2] = 0; + dst[i][3] = 1; + } +} + +static void +unpack_int_rgba_RG_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i * 2 + 0]; + dst[i][1] = src[i * 2 + 1]; + dst[i][2] = 0; + dst[i][3] = 1; + } +} + +static void unpack_int_rgba_R_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) { unsigned int i; @@ -2223,6 +2275,113 @@ unpack_int_rgba_R_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) } static void +unpack_int_rgba_R_UINT16(const GLushort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i]; + dst[i][1] = 0; + dst[i][2] = 0; + dst[i][3] = 1; + } +} + +static void +unpack_int_rgba_R_INT16(const GLshort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i]; + dst[i][1] = 0; + dst[i][2] = 0; + dst[i][3] = 1; + } +} + +static void +unpack_int_rgba_R_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i]; + dst[i][1] = 0; + dst[i][2] = 0; + dst[i][3] = 1; + } +} + +static void +unpack_int_rgba_R_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i]; + dst[i][1] = 0; + dst[i][2] = 0; + dst[i][3] = 1; + } +} + +static void +unpack_int_rgba_ALPHA_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = 0; + dst[i][3] = src[i]; + } +} + +static void +unpack_int_rgba_ALPHA_UINT16(const GLushort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = 0; + dst[i][3] = src[i]; + } +} + +static void +unpack_int_rgba_ALPHA_INT16(const GLshort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = 0; + dst[i][3] = src[i]; + } +} + +static void +unpack_int_rgba_ALPHA_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = 0; + dst[i][3] = src[i]; + } +} + +static void +unpack_int_rgba_ALPHA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = 0; + dst[i][3] = src[i]; + } +} + +static void unpack_int_rgba_LUMINANCE_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) { unsigned int i; @@ -2245,6 +2404,50 @@ unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint *src, GLuint dst[][4], GLuin } static void +unpack_int_rgba_LUMINANCE_ALPHA_UINT16(const GLushort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0]; + dst[i][3] = src[i * 2 + 1]; + } +} + +static void +unpack_int_rgba_LUMINANCE_ALPHA_INT16(const GLshort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0]; + dst[i][3] = src[i * 2 + 1]; + } +} + +static void +unpack_int_rgba_LUMINANCE_ALPHA_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0]; + dst[i][3] = src[i * 2 + 1]; + } +} + +static void +unpack_int_rgba_LUMINANCE_ALPHA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0]; + dst[i][3] = src[i * 2 + 1]; + } +} + +static void unpack_int_rgba_INTENSITY_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) { unsigned int i; @@ -2255,6 +2458,46 @@ unpack_int_rgba_INTENSITY_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) } static void +unpack_int_rgba_INTENSITY_UINT16(const GLushort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i]; + } +} + +static void +unpack_int_rgba_INTENSITY_INT16(const GLshort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i]; + } +} + +static void +unpack_int_rgba_INTENSITY_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i]; + } +} + +static void +unpack_int_rgba_INTENSITY_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i]; + } +} + +static void unpack_int_rgba_ARGB2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n) { unsigned int i; @@ -2318,24 +2561,102 @@ _mesa_unpack_uint_rgba_row(gl_format format, GLuint n, case MESA_FORMAT_RG_INT32: unpack_int_rgba_RG_UINT32(src, dst, n); break; + + case MESA_FORMAT_RG_UINT16: + unpack_int_rgba_RG_UINT16(src, dst, n); + break; + case MESA_FORMAT_RG_INT16: + unpack_int_rgba_RG_INT16(src, dst, n); + break; + + case MESA_FORMAT_RG_UINT8: + unpack_int_rgba_RG_UINT8(src, dst, n); + break; + case MESA_FORMAT_RG_INT8: + unpack_int_rgba_RG_INT8(src, dst, n); + break; + case MESA_FORMAT_R_UINT32: case MESA_FORMAT_R_INT32: unpack_int_rgba_R_UINT32(src, dst, n); break; + case MESA_FORMAT_R_UINT16: + unpack_int_rgba_R_UINT16(src, dst, n); + break; + case MESA_FORMAT_R_INT16: + unpack_int_rgba_R_INT16(src, dst, n); + break; + + case MESA_FORMAT_R_UINT8: + unpack_int_rgba_R_UINT8(src, dst, n); + break; + case MESA_FORMAT_R_INT8: + unpack_int_rgba_R_INT8(src, dst, n); + break; + + case MESA_FORMAT_ALPHA_UINT32: + case MESA_FORMAT_ALPHA_INT32: + unpack_int_rgba_ALPHA_UINT32(src, dst, n); + break; + + case MESA_FORMAT_ALPHA_UINT16: + unpack_int_rgba_ALPHA_UINT16(src, dst, n); + break; + case MESA_FORMAT_ALPHA_INT16: + unpack_int_rgba_ALPHA_INT16(src, dst, n); + break; + + case MESA_FORMAT_ALPHA_UINT8: + unpack_int_rgba_ALPHA_UINT8(src, dst, n); + break; + case MESA_FORMAT_ALPHA_INT8: + unpack_int_rgba_ALPHA_INT8(src, dst, n); + break; + case MESA_FORMAT_LUMINANCE_UINT32: case MESA_FORMAT_LUMINANCE_INT32: unpack_int_rgba_LUMINANCE_UINT32(src, dst, n); break; + case MESA_FORMAT_LUMINANCE_ALPHA_UINT32: case MESA_FORMAT_LUMINANCE_ALPHA_INT32: unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src, dst, n); break; + + case MESA_FORMAT_LUMINANCE_ALPHA_UINT16: + unpack_int_rgba_LUMINANCE_ALPHA_UINT16(src, dst, n); + break; + case MESA_FORMAT_LUMINANCE_ALPHA_INT16: + unpack_int_rgba_LUMINANCE_ALPHA_INT16(src, dst, n); + break; + + case MESA_FORMAT_LUMINANCE_ALPHA_UINT8: + unpack_int_rgba_LUMINANCE_ALPHA_UINT8(src, dst, n); + break; + case MESA_FORMAT_LUMINANCE_ALPHA_INT8: + unpack_int_rgba_LUMINANCE_ALPHA_INT8(src, dst, n); + break; + case MESA_FORMAT_INTENSITY_UINT32: case MESA_FORMAT_INTENSITY_INT32: unpack_int_rgba_INTENSITY_UINT32(src, dst, n); break; + case MESA_FORMAT_INTENSITY_UINT16: + unpack_int_rgba_INTENSITY_UINT16(src, dst, n); + break; + case MESA_FORMAT_INTENSITY_INT16: + unpack_int_rgba_INTENSITY_INT16(src, dst, n); + break; + + case MESA_FORMAT_INTENSITY_UINT8: + unpack_int_rgba_INTENSITY_UINT8(src, dst, n); + break; + case MESA_FORMAT_INTENSITY_INT8: + unpack_int_rgba_INTENSITY_INT8(src, dst, n); + break; + case MESA_FORMAT_ARGB2101010_UINT: unpack_int_rgba_ARGB2101010_UINT(src, dst, n); break; diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index 96317dbf4..cecb70c01 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -2516,14 +2516,16 @@ _mesa_format_to_type_and_comps(gl_format format, /** * Check if a gl_format exactly matches a GL formaat/type combination * such that we can use memcpy() from one to the other. - * - * Note: this matching assumes that GL_PACK/UNPACK_SWAP_BYTES is unset. - * + * \param gl_format a MESA_FORMAT_x value + * \param format the user-specified image format + * \param type the user-specified image datatype + * \param swapBytes typically the current pixel pack/unpack byteswap state * \return GL_TRUE if the formats match, GL_FALSE otherwise. */ GLboolean _mesa_format_matches_format_and_type(gl_format gl_format, - GLenum format, GLenum type) + GLenum format, GLenum type, + GLboolean swapBytes) { const GLboolean littleEndian = _mesa_little_endian(); @@ -2543,21 +2545,77 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_RGBA8888: - return ((format == GL_RGBA && (type == GL_UNSIGNED_INT_8_8_8_8 || - (type == GL_UNSIGNED_BYTE && !littleEndian))) || - (format == GL_ABGR_EXT && (type == GL_UNSIGNED_INT_8_8_8_8_REV || - (type == GL_UNSIGNED_BYTE && littleEndian)))); + if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8 && !swapBytes) + return GL_TRUE; + + if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV && swapBytes) + return GL_TRUE; + + if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && !littleEndian) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8_REV + && !swapBytes) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8 + && swapBytes) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_BYTE && littleEndian) + return GL_TRUE; + + return GL_FALSE; case MESA_FORMAT_RGBA8888_REV: - return ((format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV)); + if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV && + !swapBytes) + return GL_TRUE; + + if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8 && swapBytes) + return GL_TRUE; + + if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && littleEndian) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8 && + !swapBytes) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8_REV && + swapBytes) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_BYTE && !littleEndian) + return GL_TRUE; + + return GL_FALSE; case MESA_FORMAT_ARGB8888: - return ((format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8_REV || - (type == GL_UNSIGNED_BYTE && littleEndian)))); + if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV && + !swapBytes) + return GL_TRUE; + + if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8 && swapBytes) + return GL_TRUE; + + if (format == GL_BGRA && type == GL_UNSIGNED_BYTE && littleEndian) + return GL_TRUE; + + return GL_FALSE; case MESA_FORMAT_ARGB8888_REV: - return ((format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8 || - (type == GL_UNSIGNED_BYTE && !littleEndian)))); + if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8 && !swapBytes) + return GL_TRUE; + + if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV && + swapBytes) + return GL_TRUE; + + if (format == GL_BGRA && type == GL_UNSIGNED_BYTE && !littleEndian) + return GL_TRUE; + + return GL_FALSE; case MESA_FORMAT_RGBX8888: case MESA_FORMAT_RGBX8888_REV: @@ -2568,13 +2626,14 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_RGB888: - return format == GL_RGB && type == GL_UNSIGNED_BYTE && littleEndian; + return format == GL_BGR && type == GL_UNSIGNED_BYTE && littleEndian; case MESA_FORMAT_BGR888: - return GL_FALSE; + return format == GL_RGB && type == GL_UNSIGNED_BYTE && littleEndian; case MESA_FORMAT_RGB565: - return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5; + return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 && !swapBytes; + case MESA_FORMAT_RGB565_REV: /* Some of the 16-bit MESA_FORMATs that would seem to correspond to * GL_UNSIGNED_SHORT_* are byte-swapped instead of channel-reversed, @@ -2583,15 +2642,20 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_ARGB4444: - return format == GL_BGRA && type == GL_UNSIGNED_SHORT_4_4_4_4_REV; + return format == GL_BGRA && type == GL_UNSIGNED_SHORT_4_4_4_4_REV && + !swapBytes; + case MESA_FORMAT_ARGB4444_REV: return GL_FALSE; case MESA_FORMAT_RGBA5551: - return format == GL_RGBA && type == GL_UNSIGNED_SHORT_5_5_5_1; + return format == GL_RGBA && type == GL_UNSIGNED_SHORT_5_5_5_1 && + !swapBytes; case MESA_FORMAT_ARGB1555: - return format == GL_BGRA && type == GL_UNSIGNED_SHORT_1_5_5_5_REV; + return format == GL_BGRA && type == GL_UNSIGNED_SHORT_1_5_5_5_REV && + !swapBytes; + case MESA_FORMAT_ARGB1555_REV: return GL_FALSE; @@ -2603,7 +2667,7 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_AL1616: - return format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_SHORT && littleEndian && !swapBytes; case MESA_FORMAT_AL1616_REV: return GL_FALSE; @@ -2613,15 +2677,18 @@ _mesa_format_matches_format_and_type(gl_format gl_format, case MESA_FORMAT_A8: return format == GL_ALPHA && type == GL_UNSIGNED_BYTE; case MESA_FORMAT_A16: - return format == GL_ALPHA && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_ALPHA && type == GL_UNSIGNED_SHORT && + littleEndian && !swapBytes; case MESA_FORMAT_L8: return format == GL_LUMINANCE && type == GL_UNSIGNED_BYTE; case MESA_FORMAT_L16: - return format == GL_LUMINANCE && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_LUMINANCE && type == GL_UNSIGNED_SHORT && + littleEndian && !swapBytes; case MESA_FORMAT_I8: return format == GL_INTENSITY && type == GL_UNSIGNED_BYTE; case MESA_FORMAT_I16: - return format == GL_INTENSITY && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_INTENSITY && type == GL_UNSIGNED_SHORT && + littleEndian && !swapBytes; case MESA_FORMAT_YCBCR: case MESA_FORMAT_YCBCR_REV: @@ -2635,32 +2702,38 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_R16: - return format == GL_RED && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_RED && type == GL_UNSIGNED_SHORT && littleEndian && + !swapBytes; case MESA_FORMAT_RG1616: - return format == GL_RG && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_RG && type == GL_UNSIGNED_SHORT && littleEndian && + !swapBytes; case MESA_FORMAT_RG1616_REV: return GL_FALSE; case MESA_FORMAT_ARGB2101010: - return format == GL_BGRA && type == GL_UNSIGNED_INT_2_10_10_10_REV; + return format == GL_BGRA && type == GL_UNSIGNED_INT_2_10_10_10_REV && + !swapBytes; case MESA_FORMAT_Z24_S8: - return format == GL_DEPTH_STENCIL && type == GL_UNSIGNED_INT_24_8; + return format == GL_DEPTH_STENCIL && type == GL_UNSIGNED_INT_24_8 && + !swapBytes; case MESA_FORMAT_Z24_X8: case MESA_FORMAT_S8_Z24: return GL_FALSE; case MESA_FORMAT_Z16: - return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_SHORT; + return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_SHORT && + !swapBytes; case MESA_FORMAT_X8_Z24: return GL_FALSE; case MESA_FORMAT_Z32: - return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_INT; + return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_INT && + !swapBytes; case MESA_FORMAT_S8: - return GL_FALSE; + return format == GL_STENCIL_INDEX && type == GL_UNSIGNED_BYTE; case MESA_FORMAT_SRGB8: case MESA_FORMAT_SRGBA8: @@ -2682,44 +2755,44 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_RGBA_FLOAT32: - return format == GL_RGBA && type == GL_FLOAT; + return format == GL_RGBA && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_RGBA_FLOAT16: - return format == GL_RGBA && type == GL_HALF_FLOAT; + return format == GL_RGBA && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_RGB_FLOAT32: - return format == GL_RGB && type == GL_FLOAT; + return format == GL_RGB && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_RGB_FLOAT16: - return format == GL_RGB && type == GL_HALF_FLOAT; + return format == GL_RGB && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_ALPHA_FLOAT32: - return format == GL_ALPHA && type == GL_FLOAT; + return format == GL_ALPHA && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_ALPHA_FLOAT16: - return format == GL_ALPHA && type == GL_HALF_FLOAT; + return format == GL_ALPHA && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_LUMINANCE_FLOAT32: - return format == GL_LUMINANCE && type == GL_FLOAT; + return format == GL_LUMINANCE && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_LUMINANCE_FLOAT16: - return format == GL_LUMINANCE && type == GL_HALF_FLOAT; + return format == GL_LUMINANCE && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: - return format == GL_LUMINANCE_ALPHA && type == GL_FLOAT; + return format == GL_LUMINANCE_ALPHA && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: - return format == GL_LUMINANCE_ALPHA && type == GL_HALF_FLOAT; + return format == GL_LUMINANCE_ALPHA && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_INTENSITY_FLOAT32: - return format == GL_INTENSITY && type == GL_FLOAT; + return format == GL_INTENSITY && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_INTENSITY_FLOAT16: - return format == GL_INTENSITY && type == GL_HALF_FLOAT; + return format == GL_INTENSITY && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_R_FLOAT32: - return format == GL_RED && type == GL_FLOAT; + return format == GL_RED && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_R_FLOAT16: - return format == GL_RED && type == GL_HALF_FLOAT; + return format == GL_RED && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_RG_FLOAT32: - return format == GL_RG && type == GL_FLOAT; + return format == GL_RG && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_RG_FLOAT16: - return format == GL_RG && type == GL_HALF_FLOAT; + return format == GL_RG && type == GL_HALF_FLOAT && !swapBytes; /* FINISHME: What do we want to do for GL_EXT_texture_integer? */ case MESA_FORMAT_ALPHA_UINT8: @@ -2786,8 +2859,26 @@ _mesa_format_matches_format_and_type(gl_format gl_format, case MESA_FORMAT_SIGNED_R8: case MESA_FORMAT_SIGNED_RG88_REV: case MESA_FORMAT_SIGNED_RGBX8888: + return GL_FALSE; + case MESA_FORMAT_SIGNED_RGBA8888: + if (format == GL_RGBA && type == GL_BYTE && !littleEndian) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_BYTE && littleEndian) + return GL_TRUE; + + return GL_FALSE; + case MESA_FORMAT_SIGNED_RGBA8888_REV: + if (format == GL_RGBA && type == GL_BYTE && littleEndian) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_BYTE && !littleEndian) + return GL_TRUE; + + return GL_FALSE; + case MESA_FORMAT_SIGNED_R16: case MESA_FORMAT_SIGNED_GR1616: case MESA_FORMAT_SIGNED_RGB_16: @@ -2823,15 +2914,20 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_ARGB2101010_UINT: - return GL_FALSE; + return (format == GL_BGRA_INTEGER_EXT && + type == GL_UNSIGNED_INT_2_10_10_10_REV && + !swapBytes); case MESA_FORMAT_RGB9_E5_FLOAT: - return format == GL_RGB && type == GL_UNSIGNED_INT_5_9_9_9_REV; + return format == GL_RGB && type == GL_UNSIGNED_INT_5_9_9_9_REV && + !swapBytes; + case MESA_FORMAT_R11_G11_B10_FLOAT: - return format == GL_RGB && type == GL_UNSIGNED_INT_10F_11F_11F_REV; + return format == GL_RGB && type == GL_UNSIGNED_INT_10F_11F_11F_REV && + !swapBytes; case MESA_FORMAT_Z32_FLOAT: - return format == GL_DEPTH_COMPONENT && type == GL_FLOAT; + return format == GL_DEPTH_COMPONENT && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_Z32_FLOAT_X24S8: return GL_FALSE; diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h index 960934338..3a694a813 100644 --- a/mesalib/src/mesa/main/formats.h +++ b/mesalib/src/mesa/main/formats.h @@ -343,7 +343,8 @@ _mesa_format_num_components(gl_format format); GLboolean _mesa_format_matches_format_and_type(gl_format gl_format, - GLenum format, GLenum type); + GLenum format, GLenum type, + GLboolean swapBytes); #ifdef __cplusplus diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c index f874ab21a..d07e2aaa8 100644 --- a/mesalib/src/mesa/main/pack.c +++ b/mesalib/src/mesa/main/pack.c @@ -462,7 +462,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) #undef FN_NAME #define DST_TYPE GLushort -#define SRC_CONVERT(x) (x) +#define SRC_CONVERT(x) MIN2(x, 0xffff) #define FN_NAME pack_ushort_from_uint_rgba #include "pack_tmp.h" #undef DST_TYPE @@ -470,7 +470,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) #undef FN_NAME #define DST_TYPE GLshort -#define SRC_CONVERT(x) (x) +#define SRC_CONVERT(x) CLAMP((int)x, -32768, 32767) #define FN_NAME pack_short_from_uint_rgba #include "pack_tmp.h" #undef DST_TYPE @@ -478,7 +478,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) #undef FN_NAME #define DST_TYPE GLubyte -#define SRC_CONVERT(x) (x) +#define SRC_CONVERT(x) MIN2(x, 0xff) #define FN_NAME pack_ubyte_from_uint_rgba #include "pack_tmp.h" #undef DST_TYPE @@ -486,7 +486,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) #undef FN_NAME #define DST_TYPE GLbyte -#define SRC_CONVERT(x) (x) +#define SRC_CONVERT(x) CLAMP((int)x, -128, 127) #define FN_NAME pack_byte_from_uint_rgba #include "pack_tmp.h" #undef DST_TYPE @@ -2020,14 +2020,10 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], if (dstPacking->SwapBytes) { GLint swapSize = _mesa_sizeof_packed_type(dstType); if (swapSize == 2) { - if (dstPacking->SwapBytes) { - _mesa_swap2((GLushort *) dstAddr, n * comps); - } + _mesa_swap2((GLushort *) dstAddr, n * comps); } else if (swapSize == 4) { - if (dstPacking->SwapBytes) { - _mesa_swap4((GLuint *) dstAddr, n * comps); - } + _mesa_swap4((GLuint *) dstAddr, n * comps); } } @@ -3008,27 +3004,6 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], static inline GLuint -clamp_byte_to_uint(GLbyte b) -{ - return b < 0 ? 0 : b; -} - - -static inline GLuint -clamp_short_to_uint(GLshort s) -{ - return s < 0 ? 0 : s; -} - - -static inline GLuint -clamp_int_to_uint(GLint i) -{ - return i < 0 ? 0 : i; -} - - -static inline GLuint clamp_float_to_uint(GLfloat f) { return f < 0.0F ? 0 : IROUND(f); @@ -3150,10 +3125,10 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4], PROCESS(aSrc, ACOMP, 1, GLubyte, (GLuint)); break; case GL_BYTE: - PROCESS(rSrc, RCOMP, 0, GLbyte, clamp_byte_to_uint); - PROCESS(gSrc, GCOMP, 0, GLbyte, clamp_byte_to_uint); - PROCESS(bSrc, BCOMP, 0, GLbyte, clamp_byte_to_uint); - PROCESS(aSrc, ACOMP, 1, GLbyte, clamp_byte_to_uint); + PROCESS(rSrc, RCOMP, 0, GLbyte, (GLuint)); + PROCESS(gSrc, GCOMP, 0, GLbyte, (GLuint)); + PROCESS(bSrc, BCOMP, 0, GLbyte, (GLuint)); + PROCESS(aSrc, ACOMP, 1, GLbyte, (GLuint)); break; case GL_UNSIGNED_SHORT: PROCESS(rSrc, RCOMP, 0, GLushort, (GLuint)); @@ -3162,10 +3137,10 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4], PROCESS(aSrc, ACOMP, 1, GLushort, (GLuint)); break; case GL_SHORT: - PROCESS(rSrc, RCOMP, 0, GLshort, clamp_short_to_uint); - PROCESS(gSrc, GCOMP, 0, GLshort, clamp_short_to_uint); - PROCESS(bSrc, BCOMP, 0, GLshort, clamp_short_to_uint); - PROCESS(aSrc, ACOMP, 1, GLshort, clamp_short_to_uint); + PROCESS(rSrc, RCOMP, 0, GLshort, (GLuint)); + PROCESS(gSrc, GCOMP, 0, GLshort, (GLuint)); + PROCESS(bSrc, BCOMP, 0, GLshort, (GLuint)); + PROCESS(aSrc, ACOMP, 1, GLshort, (GLuint)); break; case GL_UNSIGNED_INT: PROCESS(rSrc, RCOMP, 0, GLuint, (GLuint)); @@ -3174,10 +3149,10 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4], PROCESS(aSrc, ACOMP, 1, GLuint, (GLuint)); break; case GL_INT: - PROCESS(rSrc, RCOMP, 0, GLint, clamp_int_to_uint); - PROCESS(gSrc, GCOMP, 0, GLint, clamp_int_to_uint); - PROCESS(bSrc, BCOMP, 0, GLint, clamp_int_to_uint); - PROCESS(aSrc, ACOMP, 1, GLint, clamp_int_to_uint); + PROCESS(rSrc, RCOMP, 0, GLint, (GLuint)); + PROCESS(gSrc, GCOMP, 0, GLint, (GLuint)); + PROCESS(bSrc, BCOMP, 0, GLint, (GLuint)); + PROCESS(aSrc, ACOMP, 1, GLint, (GLuint)); break; case GL_FLOAT: PROCESS(rSrc, RCOMP, 0, GLfloat, clamp_float_to_uint); diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c index c1489d211..908a55e70 100644 --- a/mesalib/src/mesa/main/readpix.c +++ b/mesalib/src/mesa/main/readpix.c @@ -209,15 +209,10 @@ fast_read_rgba_pixels_memcpy( struct gl_context *ctx, GLubyte *dst, *map; int dstStride, stride, j, texelBytes; - if (!_mesa_format_matches_format_and_type(rb->Format, format, type)) + if (!_mesa_format_matches_format_and_type(rb->Format, format, type, + ctx->Pack.SwapBytes)) return GL_FALSE; - /* check for things we can't handle here */ - if (packing->SwapBytes || - packing->LsbFirst) { - return GL_FALSE; - } - dstStride = _mesa_image_row_stride(packing, width, format, type); dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, format, type, 0, 0); diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c index 818deb8e4..42495c8c7 100644 --- a/mesalib/src/mesa/main/texgetimage.c +++ b/mesalib/src/mesa/main/texgetimage.c @@ -462,6 +462,15 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, transferOps |= IMAGE_CLAMP_BIT; } } + /* This applies to RGB, RGBA textures. if the format is either LUMINANCE + * or LUMINANCE ALPHA, luminance (L) is computed as L=R+G+B .we need to + * clamp the sum to [0,1]. + */ + else if ((format == GL_LUMINANCE || + format == GL_LUMINANCE_ALPHA) && + dataType == GL_UNSIGNED_NORMALIZED) { + transferOps |= IMAGE_CLAMP_BIT; + } if (_mesa_is_format_compressed(texImage->TexFormat)) { get_tex_rgba_compressed(ctx, dimensions, format, type, diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index 600dab302..827fcb788 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -1139,11 +1139,9 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS) ASSERT(_mesa_get_format_bytes(dstFormat) == 2); if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGB565 && baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_SHORT_5_6_5) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -1243,30 +1241,9 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS) ASSERT(_mesa_get_format_bytes(dstFormat) == 4); if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_RGBA8888 || - dstFormat == MESA_FORMAT_RGBX8888) && 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, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_RGBA8888_REV || - dstFormat == MESA_FORMAT_RGBX8888_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))) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -1367,28 +1344,9 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) ASSERT(_mesa_get_format_bytes(dstFormat) == 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, - dstRowStride, dstSlices, - 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)) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path (big endian) */ memcpy_texture(ctx, dims, dstFormat, @@ -1553,18 +1511,15 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgb888(TEXSTORE_PARAMS) { - const GLboolean littleEndian = _mesa_little_endian(); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_RGB888); ASSERT(_mesa_get_format_bytes(dstFormat) == 3); if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && baseInternalFormat == GL_RGB && - srcFormat == GL_BGR && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -1670,18 +1625,15 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_bgr888(TEXSTORE_PARAMS) { - const GLboolean littleEndian = _mesa_little_endian(); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_BGR888); ASSERT(_mesa_get_format_bytes(dstFormat) == 3); if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -1775,11 +1727,9 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS) ASSERT(_mesa_get_format_bytes(dstFormat) == 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) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -1838,11 +1788,9 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS) ASSERT(_mesa_get_format_bytes(dstFormat) == 2); if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGBA5551 && baseInternalFormat == GL_RGBA && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_SHORT_5_5_5_1) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -1891,11 +1839,9 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS) ASSERT(_mesa_get_format_bytes(dstFormat) == 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) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -1955,11 +1901,9 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS) ASSERT(_mesa_get_format_bytes(dstFormat) == 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) { + baseInternalFormat == GL_RGBA && + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -2458,9 +2402,9 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS) ASSERT(_mesa_get_format_bytes(dstFormat) == 1); if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -2990,7 +2934,6 @@ _mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) { - const GLboolean littleEndian = _mesa_little_endian(); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBA8888 || @@ -2998,11 +2941,9 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) ASSERT(_mesa_get_format_bytes(dstFormat) == 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))) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -3010,19 +2951,6 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) 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, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } else { /* general path */ const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, @@ -3465,13 +3393,14 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) } 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; + 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; @@ -3534,13 +3463,14 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) } 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; + 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; @@ -3603,13 +3533,14 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) } 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; + 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; @@ -3959,9 +3890,8 @@ _mesa_texstore_rgb9_e5(TEXSTORE_PARAMS) ASSERT(baseInternalFormat == GL_RGB); if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_INT_5_9_9_9_REV) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -4008,9 +3938,8 @@ _mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS) ASSERT(baseInternalFormat == GL_RGB); if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_INT_10F_11F_11F_REV) { + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, @@ -4119,11 +4048,9 @@ _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS) ASSERT(dstFormat == MESA_FORMAT_ARGB2101010_UINT); ASSERT(_mesa_get_format_bytes(dstFormat) == 4); - if (!srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB2101010_UINT && - srcFormat == GL_BGRA_INTEGER_EXT && - srcType == GL_UNSIGNED_INT_2_10_10_10_REV && - baseInternalFormat == GL_RGBA) { + if (baseInternalFormat == GL_RGBA && + _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, diff --git a/mesalib/src/mesa/swrast/s_aaline.c b/mesalib/src/mesa/swrast/s_aaline.c index d4b1805d9..d36d87697 100644 --- a/mesalib/src/mesa/swrast/s_aaline.c +++ b/mesalib/src/mesa/swrast/s_aaline.c @@ -479,7 +479,7 @@ _swrast_choose_aa_line_function(struct gl_context *ctx) ASSERT(ctx->Line.SmoothFlag); if (ctx->Texture._EnabledCoordUnits != 0 - || ctx->FragmentProgram._Current + || _swrast_use_fragment_program(ctx) || (ctx->Light.Enabled && ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) || ctx->Fog.ColorSumEnabled diff --git a/mesalib/src/mesa/swrast/s_aalinetemp.h b/mesalib/src/mesa/swrast/s_aalinetemp.h index 376ef32d0..ba9f8abb9 100644 --- a/mesalib/src/mesa/swrast/s_aalinetemp.h +++ b/mesalib/src/mesa/swrast/s_aalinetemp.h @@ -67,7 +67,7 @@ NAME(plot)(struct gl_context *ctx, struct LineInfo *line, int ix, int iy) ATTRIB_LOOP_BEGIN GLfloat (*attribArray)[4] = line->span.array->attribs[attr]; if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0 - && !ctx->FragmentProgram._Current) { + && !_swrast_use_fragment_program(ctx)) { /* texcoord w/ divide by Q */ const GLuint unit = attr - FRAG_ATTRIB_TEX0; const GLfloat invQ = solve_plane_recip(fx, fy, line->attrPlane[attr][3]); diff --git a/mesalib/src/mesa/swrast/s_aatriangle.c b/mesalib/src/mesa/swrast/s_aatriangle.c index c68fdf63b..b59177fa7 100644 --- a/mesalib/src/mesa/swrast/s_aatriangle.c +++ b/mesalib/src/mesa/swrast/s_aatriangle.c @@ -299,7 +299,7 @@ _swrast_set_aa_triangle_function(struct gl_context *ctx) ASSERT(ctx->Polygon.SmoothFlag); if (ctx->Texture._EnabledCoordUnits != 0 - || ctx->FragmentProgram._Current + || _swrast_use_fragment_program(ctx) || swrast->_FogEnabled || _mesa_need_secondary_color(ctx)) { SWRAST_CONTEXT(ctx)->Triangle = general_aa_tri; diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c index 14cb9b180..cc304d70c 100644 --- a/mesalib/src/mesa/swrast/s_context.c +++ b/mesalib/src/mesa/swrast/s_context.c @@ -105,7 +105,7 @@ _swrast_update_rasterflags( struct gl_context *ctx ) } - if (ctx->FragmentProgram._Current) { + if (_swrast_use_fragment_program(ctx)) { rasterMask |= FRAGPROG_BIT; } @@ -170,7 +170,7 @@ _swrast_update_fog_hint( struct gl_context *ctx ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); swrast->_PreferPixelFog = (!swrast->AllowVertexFog || - ctx->FragmentProgram._Current || + _swrast_use_fragment_program(ctx) || (ctx->Hint.Fog == GL_NICEST && swrast->AllowPixelFog)); } @@ -220,13 +220,14 @@ _swrast_update_deferred_texture(struct gl_context *ctx) swrast->_DeferredTexture = GL_FALSE; } else { + GLboolean use_fprog = _swrast_use_fragment_program(ctx); const struct gl_fragment_program *fprog = ctx->FragmentProgram._Current; - if (fprog && (fprog->Base.OutputsWritten & (1 << FRAG_RESULT_DEPTH))) { + if (use_fprog && (fprog->Base.OutputsWritten & (1 << FRAG_RESULT_DEPTH))) { /* Z comes from fragment program/shader */ swrast->_DeferredTexture = GL_FALSE; } - else if (fprog && fprog->UsesKill) { + else if (use_fprog && fprog->UsesKill) { swrast->_DeferredTexture = GL_FALSE; } else if (ctx->Query.CurrentOcclusionObject) { @@ -254,7 +255,8 @@ _swrast_update_fog_state( struct gl_context *ctx ) (fp->Base.Target == GL_FRAGMENT_PROGRAM_NV)); /* determine if fog is needed, and if so, which fog mode */ - swrast->_FogEnabled = (fp == NULL && ctx->Fog.Enabled); + swrast->_FogEnabled = (!_swrast_use_fragment_program(ctx) && + ctx->Fog.Enabled); } @@ -265,10 +267,11 @@ _swrast_update_fog_state( struct gl_context *ctx ) static void _swrast_update_fragment_program(struct gl_context *ctx, GLbitfield newState) { - const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; - if (fp) { - _mesa_load_state_parameters(ctx, fp->Base.Parameters); - } + if (!_swrast_use_fragment_program(ctx)) + return; + + _mesa_load_state_parameters(ctx, + ctx->FragmentProgram._Current->Base.Parameters); } @@ -286,7 +289,7 @@ _swrast_update_specular_vertex_add(struct gl_context *ctx) swrast->SpecularVertexAdd = (separateSpecular && ctx->Texture._EnabledUnits == 0x0 - && !ctx->FragmentProgram._Current + && !_swrast_use_fragment_program(ctx) && !ctx->ATIFragmentShader._Enabled); } @@ -497,7 +500,7 @@ _swrast_update_active_attribs(struct gl_context *ctx) /* * Compute _ActiveAttribsMask = which fragment attributes are needed. */ - if (ctx->FragmentProgram._Current) { + if (_swrast_use_fragment_program(ctx)) { /* fragment program/shader */ attribsMask = ctx->FragmentProgram._Current->Base.InputsRead; attribsMask &= ~FRAG_BIT_WPOS; /* WPOS is always handled specially */ diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h index ae239a9a8..363bdf03a 100644 --- a/mesalib/src/mesa/swrast/s_context.h +++ b/mesalib/src/mesa/swrast/s_context.h @@ -47,6 +47,7 @@ #include "main/mtypes.h" #include "program/prog_execute.h" #include "swrast.h" +#include "s_fragprog.h" #include "s_span.h" diff --git a/mesalib/src/mesa/swrast/s_drawpix.c b/mesalib/src/mesa/swrast/s_drawpix.c index c5466ddbd..c19808bd4 100644 --- a/mesalib/src/mesa/swrast/s_drawpix.c +++ b/mesalib/src/mesa/swrast/s_drawpix.c @@ -239,7 +239,8 @@ fast_draw_rgba_pixels(struct gl_context *ctx, GLint x, GLint y, return GL_TRUE; } - if (_mesa_format_matches_format_and_type(rb->Format, format, type)) { + if (_mesa_format_matches_format_and_type(rb->Format, format, type, + ctx->Unpack.SwapBytes)) { fast_draw_generic_pixels(ctx, rb, x, y, width, height, format, type, &unpack, pixels); return GL_TRUE; diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c index 1caa0ebc2..cd20d8e36 100644 --- a/mesalib/src/mesa/swrast/s_fragprog.c +++ b/mesalib/src/mesa/swrast/s_fragprog.c @@ -30,6 +30,18 @@ #include "s_fragprog.h" #include "s_span.h" +/** + * \brief Should swrast use a fragment program? + * + * \return true if the current fragment program exists and is not the fixed + * function fragment program + */ +GLboolean +_swrast_use_fragment_program(struct gl_context *ctx) +{ + struct gl_fragment_program *fp = ctx->FragmentProgram._Current; + return fp && fp != ctx->FragmentProgram._TexEnvProgram; +} /** * Apply texture object's swizzle (X/Y/Z/W/0/1) to incoming 'texel' diff --git a/mesalib/src/mesa/swrast/s_fragprog.h b/mesalib/src/mesa/swrast/s_fragprog.h index bd5fe6877..ac1f5ff4c 100644 --- a/mesalib/src/mesa/swrast/s_fragprog.h +++ b/mesalib/src/mesa/swrast/s_fragprog.h @@ -1,40 +1,42 @@ -/*
- * Mesa 3-D graphics library
- * Version: 6.5.3
- *
- * Copyright (C) 1999-2006 Brian Paul 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.
- */
-
-
-#ifndef S_FRAGPROG_H
-#define S_FRAGPROG_H
-
-
-#include "s_span.h"
-
-struct gl_context;
-
-
-extern void
-_swrast_exec_fragment_program(struct gl_context *ctx, SWspan *span);
-
-
-#endif /* S_FRAGPROG_H */
-
+/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 1999-2006 Brian Paul 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. + */ + + +#ifndef S_FRAGPROG_H +#define S_FRAGPROG_H + + +#include "s_span.h" + +struct gl_context; + +GLboolean +_swrast_use_fragment_program(struct gl_context *ctx); + +extern void +_swrast_exec_fragment_program(struct gl_context *ctx, SWspan *span); + + +#endif /* S_FRAGPROG_H */ + diff --git a/mesalib/src/mesa/swrast/s_lines.c b/mesalib/src/mesa/swrast/s_lines.c index aba403308..ee997b08a 100644 --- a/mesalib/src/mesa/swrast/s_lines.c +++ b/mesalib/src/mesa/swrast/s_lines.c @@ -1,268 +1,268 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2007 Brian Paul 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.
- */
-
-
-#include "main/glheader.h"
-#include "main/context.h"
-#include "main/colormac.h"
-#include "main/macros.h"
-#include "s_aaline.h"
-#include "s_context.h"
-#include "s_feedback.h"
-#include "s_lines.h"
-#include "s_span.h"
-
-
-/*
- * Init the mask[] array to implement a line stipple.
- */
-static void
-compute_stipple_mask( struct gl_context *ctx, GLuint len, GLubyte mask[] )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLuint i;
-
- for (i = 0; i < len; i++) {
- GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf;
- if ((1 << bit) & ctx->Line.StipplePattern) {
- mask[i] = GL_TRUE;
- }
- else {
- mask[i] = GL_FALSE;
- }
- swrast->StippleCounter++;
- }
-}
-
-
-/*
- * To draw a wide line we can simply redraw the span N times, side by side.
- */
-static void
-draw_wide_line( struct gl_context *ctx, SWspan *span, GLboolean xMajor )
-{
- const GLint width = (GLint) CLAMP(ctx->Line.Width,
- ctx->Const.MinLineWidth,
- ctx->Const.MaxLineWidth);
- GLint start;
-
- ASSERT(span->end < MAX_WIDTH);
-
- if (width & 1)
- start = width / 2;
- else
- start = width / 2 - 1;
-
- if (xMajor) {
- GLint *y = span->array->y;
- GLuint i;
- GLint w;
- for (w = 0; w < width; w++) {
- if (w == 0) {
- for (i = 0; i < span->end; i++)
- y[i] -= start;
- }
- else {
- for (i = 0; i < span->end; i++)
- y[i]++;
- }
- _swrast_write_rgba_span(ctx, span);
- }
- }
- else {
- GLint *x = span->array->x;
- GLuint i;
- GLint w;
- for (w = 0; w < width; w++) {
- if (w == 0) {
- for (i = 0; i < span->end; i++)
- x[i] -= start;
- }
- else {
- for (i = 0; i < span->end; i++)
- x[i]++;
- }
- _swrast_write_rgba_span(ctx, span);
- }
- }
-}
-
-
-
-/**********************************************************************/
-/***** Rasterization *****/
-/**********************************************************************/
-
-/* Simple RGBA index line (no stipple, width=1, no Z, no fog, no tex)*/
-#define NAME simple_no_z_rgba_line
-#define INTERP_RGBA
-#define RENDER_SPAN(span) _swrast_write_rgba_span(ctx, &span);
-#include "s_linetemp.h"
-
-
-/* Z, fog, wide, stipple RGBA line */
-#define NAME rgba_line
-#define INTERP_RGBA
-#define INTERP_Z
-#define RENDER_SPAN(span) \
- if (ctx->Line.StippleFlag) { \
- span.arrayMask |= SPAN_MASK; \
- compute_stipple_mask(ctx, span.end, span.array->mask); \
- } \
- if (ctx->Line.Width > 1.0) { \
- draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
- } \
- else { \
- _swrast_write_rgba_span(ctx, &span); \
- }
-#include "s_linetemp.h"
-
-
-/* General-purpose line (any/all features). */
-#define NAME general_line
-#define INTERP_RGBA
-#define INTERP_Z
-#define INTERP_ATTRIBS
-#define RENDER_SPAN(span) \
- if (ctx->Line.StippleFlag) { \
- span.arrayMask |= SPAN_MASK; \
- compute_stipple_mask(ctx, span.end, span.array->mask); \
- } \
- if (ctx->Line.Width > 1.0) { \
- draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
- } \
- else { \
- _swrast_write_rgba_span(ctx, &span); \
- }
-#include "s_linetemp.h"
-
-
-
-void
-_swrast_add_spec_terms_line(struct gl_context *ctx,
- const SWvertex *v0, const SWvertex *v1)
-{
- SWvertex *ncv0 = (SWvertex *)v0;
- SWvertex *ncv1 = (SWvertex *)v1;
- GLfloat rSum, gSum, bSum;
- GLchan cSave[2][4];
-
- /* save original colors */
- COPY_CHAN4(cSave[0], ncv0->color);
- COPY_CHAN4(cSave[1], ncv1->color);
- /* sum v0 */
- rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[FRAG_ATTRIB_COL1][0];
- gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[FRAG_ATTRIB_COL1][1];
- bSum = CHAN_TO_FLOAT(ncv0->color[2]) + ncv0->attrib[FRAG_ATTRIB_COL1][2];
- UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[0], rSum);
- UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[1], gSum);
- UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[2], bSum);
- /* sum v1 */
- rSum = CHAN_TO_FLOAT(ncv1->color[0]) + ncv1->attrib[FRAG_ATTRIB_COL1][0];
- gSum = CHAN_TO_FLOAT(ncv1->color[1]) + ncv1->attrib[FRAG_ATTRIB_COL1][1];
- bSum = CHAN_TO_FLOAT(ncv1->color[2]) + ncv1->attrib[FRAG_ATTRIB_COL1][2];
- UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[0], rSum);
- UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[1], gSum);
- UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[2], bSum);
- /* draw */
- SWRAST_CONTEXT(ctx)->SpecLine( ctx, ncv0, ncv1 );
- /* restore original colors */
- COPY_CHAN4( ncv0->attrib[FRAG_ATTRIB_COL0], cSave[0] );
- COPY_CHAN4( ncv1->attrib[FRAG_ATTRIB_COL0], cSave[1] );
-}
-
-
-
-#ifdef DEBUG
-
-/* record the current line function name */
-static const char *lineFuncName = NULL;
-
-#define USE(lineFunc) \
-do { \
- lineFuncName = #lineFunc; \
- /*printf("%s\n", lineFuncName);*/ \
- swrast->Line = lineFunc; \
-} while (0)
-
-#else
-
-#define USE(lineFunc) swrast->Line = lineFunc
-
-#endif
-
-
-
-/**
- * Determine which line drawing function to use given the current
- * rendering context.
- *
- * Please update the summary flag _SWRAST_NEW_LINE if you add or remove
- * tests to this code.
- */
-void
-_swrast_choose_line( struct gl_context *ctx )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLboolean specular = (ctx->Fog.ColorSumEnabled ||
- (ctx->Light.Enabled &&
- ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR));
-
- if (ctx->RenderMode == GL_RENDER) {
- if (ctx->Line.SmoothFlag) {
- /* antialiased lines */
- _swrast_choose_aa_line_function(ctx);
- ASSERT(swrast->Line);
- }
- else if (ctx->Texture._EnabledCoordUnits
- || ctx->FragmentProgram._Current
- || swrast->_FogEnabled
- || specular) {
- USE(general_line);
- }
- else if (ctx->Depth.Test
- || ctx->Line.Width != 1.0
- || ctx->Line.StippleFlag) {
- /* no texture, but Z, fog, width>1, stipple, etc. */
-#if CHAN_BITS == 32
- USE(general_line);
-#else
- USE(rgba_line);
-#endif
- }
- else {
- ASSERT(!ctx->Depth.Test);
- ASSERT(ctx->Line.Width == 1.0);
- /* simple lines */
- USE(simple_no_z_rgba_line);
- }
- }
- else if (ctx->RenderMode == GL_FEEDBACK) {
- USE(_swrast_feedback_line);
- }
- else {
- ASSERT(ctx->RenderMode == GL_SELECT);
- USE(_swrast_select_line);
- }
-}
+/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul 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. + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" +#include "main/macros.h" +#include "s_aaline.h" +#include "s_context.h" +#include "s_feedback.h" +#include "s_lines.h" +#include "s_span.h" + + +/* + * Init the mask[] array to implement a line stipple. + */ +static void +compute_stipple_mask( struct gl_context *ctx, GLuint len, GLubyte mask[] ) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + GLuint i; + + for (i = 0; i < len; i++) { + GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf; + if ((1 << bit) & ctx->Line.StipplePattern) { + mask[i] = GL_TRUE; + } + else { + mask[i] = GL_FALSE; + } + swrast->StippleCounter++; + } +} + + +/* + * To draw a wide line we can simply redraw the span N times, side by side. + */ +static void +draw_wide_line( struct gl_context *ctx, SWspan *span, GLboolean xMajor ) +{ + const GLint width = (GLint) CLAMP(ctx->Line.Width, + ctx->Const.MinLineWidth, + ctx->Const.MaxLineWidth); + GLint start; + + ASSERT(span->end < MAX_WIDTH); + + if (width & 1) + start = width / 2; + else + start = width / 2 - 1; + + if (xMajor) { + GLint *y = span->array->y; + GLuint i; + GLint w; + for (w = 0; w < width; w++) { + if (w == 0) { + for (i = 0; i < span->end; i++) + y[i] -= start; + } + else { + for (i = 0; i < span->end; i++) + y[i]++; + } + _swrast_write_rgba_span(ctx, span); + } + } + else { + GLint *x = span->array->x; + GLuint i; + GLint w; + for (w = 0; w < width; w++) { + if (w == 0) { + for (i = 0; i < span->end; i++) + x[i] -= start; + } + else { + for (i = 0; i < span->end; i++) + x[i]++; + } + _swrast_write_rgba_span(ctx, span); + } + } +} + + + +/**********************************************************************/ +/***** Rasterization *****/ +/**********************************************************************/ + +/* Simple RGBA index line (no stipple, width=1, no Z, no fog, no tex)*/ +#define NAME simple_no_z_rgba_line +#define INTERP_RGBA +#define RENDER_SPAN(span) _swrast_write_rgba_span(ctx, &span); +#include "s_linetemp.h" + + +/* Z, fog, wide, stipple RGBA line */ +#define NAME rgba_line +#define INTERP_RGBA +#define INTERP_Z +#define RENDER_SPAN(span) \ + if (ctx->Line.StippleFlag) { \ + span.arrayMask |= SPAN_MASK; \ + compute_stipple_mask(ctx, span.end, span.array->mask); \ + } \ + if (ctx->Line.Width > 1.0) { \ + draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ + } \ + else { \ + _swrast_write_rgba_span(ctx, &span); \ + } +#include "s_linetemp.h" + + +/* General-purpose line (any/all features). */ +#define NAME general_line +#define INTERP_RGBA +#define INTERP_Z +#define INTERP_ATTRIBS +#define RENDER_SPAN(span) \ + if (ctx->Line.StippleFlag) { \ + span.arrayMask |= SPAN_MASK; \ + compute_stipple_mask(ctx, span.end, span.array->mask); \ + } \ + if (ctx->Line.Width > 1.0) { \ + draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ + } \ + else { \ + _swrast_write_rgba_span(ctx, &span); \ + } +#include "s_linetemp.h" + + + +void +_swrast_add_spec_terms_line(struct gl_context *ctx, + const SWvertex *v0, const SWvertex *v1) +{ + SWvertex *ncv0 = (SWvertex *)v0; + SWvertex *ncv1 = (SWvertex *)v1; + GLfloat rSum, gSum, bSum; + GLchan cSave[2][4]; + + /* save original colors */ + COPY_CHAN4(cSave[0], ncv0->color); + COPY_CHAN4(cSave[1], ncv1->color); + /* sum v0 */ + rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[FRAG_ATTRIB_COL1][0]; + gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[FRAG_ATTRIB_COL1][1]; + bSum = CHAN_TO_FLOAT(ncv0->color[2]) + ncv0->attrib[FRAG_ATTRIB_COL1][2]; + UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[0], rSum); + UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[1], gSum); + UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[2], bSum); + /* sum v1 */ + rSum = CHAN_TO_FLOAT(ncv1->color[0]) + ncv1->attrib[FRAG_ATTRIB_COL1][0]; + gSum = CHAN_TO_FLOAT(ncv1->color[1]) + ncv1->attrib[FRAG_ATTRIB_COL1][1]; + bSum = CHAN_TO_FLOAT(ncv1->color[2]) + ncv1->attrib[FRAG_ATTRIB_COL1][2]; + UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[0], rSum); + UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[1], gSum); + UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[2], bSum); + /* draw */ + SWRAST_CONTEXT(ctx)->SpecLine( ctx, ncv0, ncv1 ); + /* restore original colors */ + COPY_CHAN4( ncv0->attrib[FRAG_ATTRIB_COL0], cSave[0] ); + COPY_CHAN4( ncv1->attrib[FRAG_ATTRIB_COL0], cSave[1] ); +} + + + +#ifdef DEBUG + +/* record the current line function name */ +static const char *lineFuncName = NULL; + +#define USE(lineFunc) \ +do { \ + lineFuncName = #lineFunc; \ + /*printf("%s\n", lineFuncName);*/ \ + swrast->Line = lineFunc; \ +} while (0) + +#else + +#define USE(lineFunc) swrast->Line = lineFunc + +#endif + + + +/** + * Determine which line drawing function to use given the current + * rendering context. + * + * Please update the summary flag _SWRAST_NEW_LINE if you add or remove + * tests to this code. + */ +void +_swrast_choose_line( struct gl_context *ctx ) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + GLboolean specular = (ctx->Fog.ColorSumEnabled || + (ctx->Light.Enabled && + ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)); + + if (ctx->RenderMode == GL_RENDER) { + if (ctx->Line.SmoothFlag) { + /* antialiased lines */ + _swrast_choose_aa_line_function(ctx); + ASSERT(swrast->Line); + } + else if (ctx->Texture._EnabledCoordUnits + || _swrast_use_fragment_program(ctx) + || swrast->_FogEnabled + || specular) { + USE(general_line); + } + else if (ctx->Depth.Test + || ctx->Line.Width != 1.0 + || ctx->Line.StippleFlag) { + /* no texture, but Z, fog, width>1, stipple, etc. */ +#if CHAN_BITS == 32 + USE(general_line); +#else + USE(rgba_line); +#endif + } + else { + ASSERT(!ctx->Depth.Test); + ASSERT(ctx->Line.Width == 1.0); + /* simple lines */ + USE(simple_no_z_rgba_line); + } + } + else if (ctx->RenderMode == GL_FEEDBACK) { + USE(_swrast_feedback_line); + } + else { + ASSERT(ctx->RenderMode == GL_SELECT); + USE(_swrast_select_line); + } +} diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c index 7ab60b1e5..28f2f3d3f 100644 --- a/mesalib/src/mesa/swrast/s_span.c +++ b/mesalib/src/mesa/swrast/s_span.c @@ -139,7 +139,8 @@ _swrast_span_default_attribs(struct gl_context *ctx, SWspan *span) for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { const GLuint attr = FRAG_ATTRIB_TEX0 + i; const GLfloat *tc = ctx->Current.RasterTexCoords[i]; - if (ctx->FragmentProgram._Current || ctx->ATIFragmentShader._Enabled) { + if (_swrast_use_fragment_program(ctx) || + ctx->ATIFragmentShader._Enabled) { COPY_4V(span->attrStart[attr], tc); } else if (tc[3] > 0.0F) { @@ -498,7 +499,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span) swrast_texture_image_const(img); needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter) - || ctx->FragmentProgram._Current; + || _swrast_use_fragment_program(ctx); /* LOD is calculated directly in the ansiotropic filter, we can * skip the normal lambda function as the result is ignored. */ @@ -518,7 +519,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span) if (needLambda) { GLuint i; - if (ctx->FragmentProgram._Current + if (_swrast_use_fragment_program(ctx) || ctx->ATIFragmentShader._Enabled) { /* do perspective correction but don't divide s, t, r by q */ const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3]; @@ -559,7 +560,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span) } else { GLuint i; - if (ctx->FragmentProgram._Current || + if (_swrast_use_fragment_program(ctx) || ctx->ATIFragmentShader._Enabled) { /* do perspective correction but don't divide s, t, r by q */ const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3]; @@ -833,7 +834,7 @@ add_specular(struct gl_context *ctx, SWspan *span) GLfloat (*col1)[4] = span->array->attribs[FRAG_ATTRIB_COL1]; GLuint i; - ASSERT(!ctx->FragmentProgram._Current); + ASSERT(!_swrast_use_fragment_program(ctx)); ASSERT(span->arrayMask & SPAN_RGBA); ASSERT(swrast->_ActiveAttribMask & FRAG_BIT_COL1); (void) swrast; /* silence warning */ @@ -971,25 +972,7 @@ convert_color_type(SWspan *span, GLenum newType, GLuint output) static inline void shade_texture_span(struct gl_context *ctx, SWspan *span) { - /* This is a hack to work around drivers such as i965 that: - * - * - Set _MaintainTexEnvProgram to generate GLSL IR for - * fixed-function fragment processing. - * - Don't call _mesa_ir_link_shader to generate Mesa IR from - * the GLSL IR. - * - May use swrast to handle glDrawPixels. - * - * Since _mesa_ir_link_shader is never called, there is no Mesa IR - * to execute. Instead do regular fixed-function processing. - * - * It is also worth noting that the software fixed-function path is - * much faster than the software shader path. - */ - const bool use_fragment_program = - ctx->FragmentProgram._Current - && ctx->FragmentProgram._Current != ctx->FragmentProgram._TexEnvProgram; - - if (use_fragment_program || + if (_swrast_use_fragment_program(ctx) || ctx->ATIFragmentShader._Enabled) { /* programmable shading */ if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) { @@ -1018,7 +1001,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span) interpolate_wpos(ctx, span); /* Run fragment program/shader now */ - if (use_fragment_program) { + if (_swrast_use_fragment_program(ctx)) { _swrast_exec_fragment_program(ctx, span); } else { @@ -1052,8 +1035,8 @@ put_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], const void *values, const GLubyte *mask) { - gl_pack_ubyte_rgba_func pack_ubyte; - gl_pack_float_rgba_func pack_float; + gl_pack_ubyte_rgba_func pack_ubyte = NULL; + gl_pack_float_rgba_func pack_float = NULL; GLuint i; if (datatype == GL_UNSIGNED_BYTE) @@ -1151,7 +1134,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) const GLbitfield64 origArrayAttribs = span->arrayAttribs; const GLenum origChanType = span->array->ChanType; void * const origRgba = span->array->rgba; - const GLboolean shader = (ctx->FragmentProgram._Current + const GLboolean shader = (_swrast_use_fragment_program(ctx) || ctx->ATIFragmentShader._Enabled); const GLboolean shaderOrTexture = shader || ctx->Texture._EnabledCoordUnits; struct gl_framebuffer *fb = ctx->DrawBuffer; @@ -1326,7 +1309,8 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) const GLuint numBuffers = fb->_NumColorDrawBuffers; const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; const GLboolean multiFragOutputs = - (fp && fp->Base.OutputsWritten >= (1 << FRAG_RESULT_DATA0)); + _swrast_use_fragment_program(ctx) + && fp->Base.OutputsWritten >= (1 << FRAG_RESULT_DATA0); GLuint buf; for (buf = 0; buf < numBuffers; buf++) { diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c index 124aa5f8e..ddb4792f7 100644 --- a/mesalib/src/mesa/swrast/s_triangle.c +++ b/mesalib/src/mesa/swrast/s_triangle.c @@ -1038,7 +1038,7 @@ _swrast_choose_triangle( struct gl_context *ctx ) * needs to be interpolated. */ if (ctx->Texture._EnabledCoordUnits || - ctx->FragmentProgram._Current || + _swrast_use_fragment_program(ctx) || ctx->ATIFragmentShader._Enabled || _mesa_need_secondary_color(ctx) || swrast->_FogEnabled) { @@ -1060,7 +1060,7 @@ _swrast_choose_triangle( struct gl_context *ctx ) /* First see if we can use an optimized 2-D texture function */ if (ctx->Texture._EnabledCoordUnits == 0x1 - && !ctx->FragmentProgram._Current + && !_swrast_use_fragment_program(ctx) && !ctx->ATIFragmentShader._Enabled && ctx->Texture._EnabledUnits == 0x1 && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT diff --git a/xorg-server/Xext/shm.c b/xorg-server/Xext/shm.c index 7c9fbc7a9..2127dee3e 100644 --- a/xorg-server/Xext/shm.c +++ b/xorg-server/Xext/shm.c @@ -181,7 +181,7 @@ SigSysHandler(int signo) static Bool CheckForShmSyscall(void) { - void (*oldHandler)(); + void (*oldHandler)(int); int shmid = -1; /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */ diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac index b0bb9bba7..6241119c4 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.60) -AC_INIT([xorg-server], 1.11.99.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) -RELEASE_DATE="2011-12-27" +AC_INIT([xorg-server], 1.11.99.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +RELEASE_DATE="2012-01-27" AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE diff --git a/xorg-server/hw/xquartz/bundle/Info.plist.cpp b/xorg-server/hw/xquartz/bundle/Info.plist.cpp index a4b8e1926..4b6d9d182 100644 --- a/xorg-server/hw/xquartz/bundle/Info.plist.cpp +++ b/xorg-server/hw/xquartz/bundle/Info.plist.cpp @@ -19,9 +19,9 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>2.7.0</string> + <string>2.7.2</string> <key>CFBundleVersion</key> - <string>2.7.0</string> + <string>2.7.2</string> <key>CFBundleSignature</key> <string>x11a</string> <key>CSResourcesFileMapped</key> @@ -37,9 +37,9 @@ <key>LSApplicationCategoryType</key> <string>public.app-category.utilities</string> <key>NSHumanReadableCopyright</key> - <string>© 2003-2011 Apple Inc. + <string>© 2003-2012 Apple Inc. © 2003 XFree86 Project, Inc. -© 2003-2011 X.org Foundation, Inc. +© 2003-2012 X.org Foundation, Inc. </string> <key>NSMainNibFile</key> <string>main</string> diff --git a/xorg-server/hw/xwin/man/XWin.man b/xorg-server/hw/xwin/man/XWin.man index 6e69a185d..d03a36521 100644 --- a/xorg-server/hw/xwin/man/XWin.man +++ b/xorg-server/hw/xwin/man/XWin.man @@ -176,7 +176,8 @@ milliseconds causes an emulated middle button press. The default .I timeout is 50 milliseconds. Note that most mice with scroll wheel have middle button functionality, usually you will need this option only if you have -a two button mouse without scroll wheel. +a two button mouse without scroll wheel. Default is to enable this +option if \fIWindows\fP reports a two button mouse, disabled otherwise. .TP 8 .B \-[no]keyhook Enable [disable] a low-level keyboard hook for catching diff --git a/xorg-server/hw/xwin/win.h b/xorg-server/hw/xwin/win.h index 5ec7e3bee..d358d3eee 100644 --- a/xorg-server/hw/xwin/win.h +++ b/xorg-server/hw/xwin/win.h @@ -97,7 +97,8 @@ #define MOUSE_POLLING_INTERVAL 50 #define WIN_E3B_OFF -1 -#define WIN_E3B_DEFAULT 0 +#define WIN_E3B_DEFAULT 0 + #define WIN_FD_INVALID -1 #define WIN_SERVER_NONE 0x0L /* 0 */ diff --git a/xorg-server/hw/xwin/winclipboardthread.c b/xorg-server/hw/xwin/winclipboardthread.c index c160453c8..758bbd32d 100644 --- a/xorg-server/hw/xwin/winclipboardthread.c +++ b/xorg-server/hw/xwin/winclipboardthread.c @@ -53,8 +53,8 @@ extern Bool g_fUnicodeClipboard; extern unsigned long serverGeneration; -extern Bool g_fClipboardLaunched; extern Bool g_fClipboardStarted; +extern Bool g_fClipboardLaunched; extern HWND g_hwndClipboard; extern void *g_pClipboardDisplay; extern Window g_iClipboardWindow; @@ -85,7 +85,6 @@ winClipboardIOErrorHandler (Display *pDisplay); static void winClipboardThreadExit(void *arg); - /* * Main thread function */ @@ -151,7 +150,6 @@ winClipboardProc (void *pvNotUsed) { /* TODO: Cleanup the Win32 window and free any allocated memory */ ErrorF ("winClipboardProc - setjmp returned for IO Error Handler.\n"); - //goto thread_errorexit; } /* Use our generated cookie for authentication */ diff --git a/xorg-server/hw/xwin/winclipboardunicode.c b/xorg-server/hw/xwin/winclipboardunicode.c index 947475509..f49306904 100644 --- a/xorg-server/hw/xwin/winclipboardunicode.c +++ b/xorg-server/hw/xwin/winclipboardunicode.c @@ -44,7 +44,7 @@ winClipboardDetectUnicodeSupport (void) { Bool fReturn = FALSE; OSVERSIONINFOEX osvi = {0}; - + /* Get operating system version information */ osvi.dwOSVersionInfoSize = sizeof (osvi); GetVersionEx ((LPOSVERSIONINFO)&osvi); diff --git a/xorg-server/hw/xwin/winclipboardwndproc.c b/xorg-server/hw/xwin/winclipboardwndproc.c index 3d324e2d8..50a63001f 100644 --- a/xorg-server/hw/xwin/winclipboardwndproc.c +++ b/xorg-server/hw/xwin/winclipboardwndproc.c @@ -138,10 +138,9 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay, pDisplay, fUseUnicode, TRUE); - if (WIN_XEVENTS_NOTIFY == iReturn - || WIN_XEVENTS_CONVERT == iReturn) + if (WIN_XEVENTS_NOTIFY == iReturn) { - /* Bail out if convert or notify processed */ + /* Bail out if notify processed */ return iReturn; } } @@ -487,15 +486,12 @@ winClipboardWindowProc (HWND hwnd, UINT message, } /* Process the SelectionNotify event */ - do { - iReturn = winProcessXEventsTimeout (hwnd, + iReturn = winProcessXEventsTimeout (hwnd, iWindow, pDisplay, fConvertToUnicode, WIN_POLL_TIMEOUT); - } while (WIN_XEVENTS_CONVERT == iReturn); - /* * The last call to winProcessXEventsTimeout * from above had better have seen a notify event, or else we diff --git a/xorg-server/hw/xwin/winclipboardwrappers.c b/xorg-server/hw/xwin/winclipboardwrappers.c index cbf9a8ed2..3743b9edb 100644 --- a/xorg-server/hw/xwin/winclipboardwrappers.c +++ b/xorg-server/hw/xwin/winclipboardwrappers.c @@ -1,373 +1,375 @@ -/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *Copyright (C) Colin Harrison 2005-2008
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the copyright holder(s)
- *and author(s) 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 copyright holder(s) and author(s).
- *
- * Authors: Harold L Hunt II
- * Colin Harrison
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "dixstruct.h"
-#include <X11/Xatom.h>
-
-
-/*
- * Constants
- */
-
-#define CLIP_NUM_SELECTIONS 2
-#define CLIP_OWN_PRIMARY 0
-#define CLIP_OWN_CLIPBOARD 1
-
-
-/*
- * Local function prototypes
- */
-
-int winProcEstablishConnection(ClientPtr /* client */);
-int winProcSetSelectionOwner(ClientPtr /* client */);
-
-
-/*
- * References to external symbols
- */
-
-extern Bool g_fUnicodeSupport;
-extern int g_iNumScreens;
-extern unsigned int g_uiAuthDataLen;
-extern char *g_pAuthData;
-extern Bool g_fXdmcpEnabled;
-extern Bool g_fClipboardLaunched;
-extern Bool g_fClipboardStarted;
-extern Bool g_fClipboard;
-extern Window g_iClipboardWindow;
-extern Atom g_atomLastOwnedSelection;
-extern HWND g_hwndClipboard;
-extern Bool g_fClipboardPrimary;
-
-extern winDispatchProcPtr winProcEstablishConnectionOrig;
-extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
-
-
-/*
- * Wrapper for internal EstablishConnection function.
- * Initializes internal clients that must not be started until
- * an external client has connected.
- */
-
-int
-winProcEstablishConnection (ClientPtr client)
-{
- int iReturn;
- static int s_iCallCount = 0;
- static unsigned long s_ulServerGeneration = 0;
-
- #ifdef WINDBG
- if (s_iCallCount == 0) winDebug ("winProcEstablishConnection - Hello\n");
- #endif
-
- /* Do nothing if clipboard is not enabled */
- if (!g_fClipboard)
- {
- winDebug ("winProcEstablishConnection - Clipboard is not enabled, "
- "returning.\n");
-
- /* Unwrap the original function, call it, and return */
- InitialVector[2] = winProcEstablishConnectionOrig;
- iReturn = (*winProcEstablishConnectionOrig) (client);
- winProcEstablishConnectionOrig = NULL;
- return iReturn;
- }
-
- /* Watch for server reset */
- if (s_ulServerGeneration != serverGeneration)
- {
- /* Save new generation number */
- s_ulServerGeneration = serverGeneration;
-
- /* Reset call count */
- s_iCallCount = 0;
- }
-
- /* Increment call count */
- ++s_iCallCount;
-
- /*
- * This procedure is only used for initialization.
- * We can unwrap the original procedure at this point
- * so that this function is no longer called until the
- * server resets and the function is wrapped again.
- */
- InitialVector[2] = winProcEstablishConnectionOrig;
-
- /*
- * Call original function and bail if it fails.
- * NOTE: We must do this first, since we need XdmcpOpenDisplay
- * to be called before we initialize our clipboard client.
- */
- iReturn = (*winProcEstablishConnectionOrig) (client);
- if (iReturn != 0)
- {
- ErrorF ("winProcEstablishConnection - ProcEstablishConnection "
- "failed, bailing.\n");
- return iReturn;
- }
-
- /* Clear original function pointer */
- winProcEstablishConnectionOrig = NULL;
-
- /* If the clipboard client has already been started, abort */
- if (g_fClipboardLaunched)
- {
- winDebug ("winProcEstablishConnection - Clipboard client already "
- "launched, returning.\n");
- return iReturn;
- }
-
- /* Startup the clipboard client if clipboard mode is being used */
- if (g_fClipboard)
- {
- /*
- * NOTE: The clipboard client is started here for a reason:
- * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
- * 2) If the clipboard client attaches during X Server startup,
- * then it becomes the "magic client" that causes the X Server
- * to reset if it exits.
- * 3) XDMCP calls KillAllClients when it starts up.
- * 4) The clipboard client is a client, so it is killed.
- * 5) The clipboard client is the "magic client", so the X Server
- * resets itself.
- * 6) This repeats ad infinitum.
- * 7) We avoid this by waiting until at least one client (could
- * be XDM, could be another client) connects, which makes it
- * almost certain that the clipboard client will not connect
- * until after XDM when using XDMCP.
- */
-
- /* Create the clipboard client thread */
- if (!winInitClipboard ())
- {
- ErrorF ("winProcEstablishConnection - winClipboardInit "
- "failed.\n");
- return iReturn;
- }
-
- winDebug ("winProcEstablishConnection - winInitClipboard returned.\n");
- }
-
- /* Flag that clipboard client has been launched */
- g_fClipboardLaunched = TRUE;
-
- return iReturn;
-}
-
-
-/*
- * Wrapper for internal SetSelectionOwner function.
- * Grabs ownership of Windows clipboard when X11 clipboard owner changes.
- */
-int
-winProcSetSelectionOwner (ClientPtr client)
-{
- int i;
- DrawablePtr pDrawable;
- WindowPtr pWindow = None;
- static Window s_iOwners[CLIP_NUM_SELECTIONS] = {None};
- static unsigned long s_ulServerGeneration = 0;
- REQUEST(xSetSelectionOwnerReq);
-
- REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
-
- winDebug ("winProcSetSelectionOwner - Hello.\n");
-
- /* Watch for server reset */
- if (s_ulServerGeneration != serverGeneration)
- {
- /* Save new generation number */
- s_ulServerGeneration = serverGeneration;
-
- /* Initialize static variables */
- for (i = 0; i < CLIP_NUM_SELECTIONS; ++i)
- s_iOwners[i] = None;
- }
-
- /* Abort if clipboard not completely initialized yet */
- if (!g_fClipboardStarted)
- {
- winDebug ("winProcSetSelectionOwner - Clipboard not yet started, "
- "aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Grab window if we have one */
- if (None != stuff->window)
- {
- /* Grab the Window from the request */
- int rc = dixLookupWindow(&pWindow, stuff->window, client, DixReadAccess);
- if (rc != Success) {
- ErrorF ("winProcSetSelectionOwner - Found BadWindow, aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
- }
-
- /* Now we either have a valid window or None */
-
- /* Save selection owners for monitored selections, ignore other selections */
- if (XA_PRIMARY == stuff->selection && g_fClipboardPrimary)
- {
- /* Look for owned -> not owned transition */
- if (None == stuff->window
- && None != s_iOwners[CLIP_OWN_PRIMARY])
- {
- winDebug ("winProcSetSelectionOwner - PRIMARY - Going from "
- "owned to not owned.\n");
-
- /* Adjust last owned selection */
- if (None != s_iOwners[CLIP_OWN_CLIPBOARD])
- g_atomLastOwnedSelection = MakeAtom ("CLIPBOARD", 9, TRUE);
- else
- g_atomLastOwnedSelection = None;
- }
-
- /* Save new selection owner or None */
- s_iOwners[CLIP_OWN_PRIMARY] = stuff->window;
-
- winDebug ("winProcSetSelectionOwner - PRIMARY - Now owned by: 0x%x (clipboard is 0x%x)\n",
- stuff->window,g_iClipboardWindow);
- }
- else if (MakeAtom ("CLIPBOARD", 9, TRUE) == stuff->selection)
- {
- /* Look for owned -> not owned transition */
- if (None == stuff->window
- && None != s_iOwners[CLIP_OWN_CLIPBOARD])
- {
- winDebug ("winProcSetSelectionOwner - CLIPBOARD - Going from "
- "owned to not owned.\n");
-
- /* Adjust last owned selection */
- if ((None != s_iOwners[CLIP_OWN_PRIMARY]) && g_fClipboardPrimary)
- g_atomLastOwnedSelection = XA_PRIMARY;
- else
- g_atomLastOwnedSelection = None;
- }
-
- /* Save new selection owner or None */
- s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window;
-
- winDebug ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: 0x%x, clipboard is 0x%x\n",
- stuff->window,g_iClipboardWindow);
- }
- else
- goto winProcSetSelectionOwner_Done;
-
- /*
- * At this point, if one of the selections is still owned by the
- * clipboard manager then it should be marked as unowned since
- * we will be taking ownership of the Win32 clipboard.
- */
- if (g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY])
- s_iOwners[CLIP_OWN_PRIMARY] = None;
- if (g_iClipboardWindow == s_iOwners[CLIP_OWN_CLIPBOARD])
- s_iOwners[CLIP_OWN_CLIPBOARD] = None;
-
- /* Abort if no window at this point */
- if (None == stuff->window)
- {
- winDebug ("winProcSetSelectionOwner - No window, returning.\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Abort if invalid selection */
- if (!ValidAtom (stuff->selection))
- {
- winDebug ("winProcSetSelectionOwner - Found BadAtom, aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Cast Window to Drawable */
- pDrawable = (DrawablePtr) pWindow;
-
- /* Abort if clipboard manager is owning the selection */
- if (pDrawable->id == g_iClipboardWindow)
- {
- winDebug ("winProcSetSelectionOwner - We changed ownership, "
- "aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Abort if root window is taking ownership */
- if (pDrawable->id == 0)
- {
- winDebug ("winProcSetSelectionOwner - Root window taking ownership, "
- "aborting\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Access the Windows clipboard */
- if (!OpenClipboard (g_hwndClipboard))
- {
- ErrorF ("winProcSetSelectionOwner - OpenClipboard () failed: %08x, hwnd: %08x\n",
- (int) GetLastError (),g_hwndClipboard);
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Take ownership of the Windows clipboard */
- if (!EmptyClipboard ())
- {
- ErrorF ("winProcSetSelectionOwner - EmptyClipboard () failed: %08x\n",
- (int) GetLastError ());
- CloseClipboard ();
- goto winProcSetSelectionOwner_Done;
- }
-
- winDebug("winProcSetSelectionOwner - SetClipboardData NULL\n");
-
- /* Advertise Unicode if we support it */
- if (g_fUnicodeSupport)
- SetClipboardData (CF_UNICODETEXT, NULL);
-
- /* Always advertise regular text */
- SetClipboardData (CF_TEXT, NULL);
-
- /* Save handle to last owned selection */
- g_atomLastOwnedSelection = stuff->selection;
-
- /* Release the clipboard */
- if (!CloseClipboard ())
- {
- ErrorF ("winProcSetSelectionOwner - CloseClipboard () failed: "
- "%08x\n",
- (int) GetLastError ());
- goto winProcSetSelectionOwner_Done;
- }
-
-winProcSetSelectionOwner_Done:
- return (*winProcSetSelectionOwnerOrig) (client);
-}
+/* + *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved. + *Copyright (C) Colin Harrison 2005-2008 + * + *Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + *"Software"), to deal in the Software without restriction, including + *without limitation the rights to use, copy, modify, merge, publish, + *distribute, sublicense, and/or sell copies of the Software, and to + *permit persons to whom the Software is furnished to do so, subject to + *the following conditions: + * + *The above copyright notice and this permission notice shall be + *included in all copies or substantial portions of the Software. + * + *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR + *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + *Except as contained in this notice, the name of the copyright holder(s) + *and author(s) 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 copyright holder(s) and author(s). + * + * Authors: Harold L Hunt II + * Colin Harrison + */ + +#ifdef HAVE_XWIN_CONFIG_H +#include <xwin-config.h> +#endif +#include "win.h" +#include "dixstruct.h" +#include <X11/Xatom.h> + + +/* + * Constants + */ + +#define CLIP_NUM_SELECTIONS 2 +#define CLIP_OWN_PRIMARY 0 +#define CLIP_OWN_CLIPBOARD 1 + + +/* + * Local function prototypes + */ + +int winProcEstablishConnection(ClientPtr /* client */); +int winProcSetSelectionOwner(ClientPtr /* client */); +DISPATCH_PROC(winProcEstablishConnection); +DISPATCH_PROC(winProcSetSelectionOwner); + + +/* + * References to external symbols + */ + +extern Bool g_fUnicodeSupport; +extern int g_iNumScreens; +extern unsigned int g_uiAuthDataLen; +extern char *g_pAuthData; +extern Bool g_fXdmcpEnabled; +extern Bool g_fClipboardLaunched; +extern Bool g_fClipboardStarted; +extern Bool g_fClipboard; +extern Window g_iClipboardWindow; +extern Atom g_atomLastOwnedSelection; +extern HWND g_hwndClipboard; +extern Bool g_fClipboardPrimary; + +extern winDispatchProcPtr winProcEstablishConnectionOrig; +extern winDispatchProcPtr winProcSetSelectionOwnerOrig; + + +/* + * Wrapper for internal EstablishConnection function. + * Initializes internal clients that must not be started until + * an external client has connected. + */ + +int +winProcEstablishConnection (ClientPtr client) +{ + int iReturn; + static int s_iCallCount = 0; + static unsigned long s_ulServerGeneration = 0; + + #ifdef WINDBG + if (s_iCallCount == 0) winDebug ("winProcEstablishConnection - Hello\n"); + #endif + + /* Do nothing if clipboard is not enabled */ + if (!g_fClipboard) + { + winDebug ("winProcEstablishConnection - Clipboard is not enabled, " + "returning.\n"); + + /* Unwrap the original function, call it, and return */ + InitialVector[2] = winProcEstablishConnectionOrig; + iReturn = (*winProcEstablishConnectionOrig) (client); + winProcEstablishConnectionOrig = NULL; + return iReturn; + } + + /* Watch for server reset */ + if (s_ulServerGeneration != serverGeneration) + { + /* Save new generation number */ + s_ulServerGeneration = serverGeneration; + + /* Reset call count */ + s_iCallCount = 0; + } + + /* Increment call count */ + ++s_iCallCount; + + /* + * This procedure is only used for initialization. + * We can unwrap the original procedure at this point + * so that this function is no longer called until the + * server resets and the function is wrapped again. + */ + InitialVector[2] = winProcEstablishConnectionOrig; + + /* + * Call original function and bail if it fails. + * NOTE: We must do this first, since we need XdmcpOpenDisplay + * to be called before we initialize our clipboard client. + */ + iReturn = (*winProcEstablishConnectionOrig) (client); + if (iReturn != 0) + { + ErrorF ("winProcEstablishConnection - ProcEstablishConnection " + "failed, bailing.\n"); + return iReturn; + } + + /* Clear original function pointer */ + winProcEstablishConnectionOrig = NULL; + + /* If the clipboard client has already been started, abort */ + if (g_fClipboardLaunched) + { + winDebug ("winProcEstablishConnection - Clipboard client already " + "launched, returning.\n"); + return iReturn; + } + + /* Startup the clipboard client if clipboard mode is being used */ + if (g_fClipboard) + { + /* + * NOTE: The clipboard client is started here for a reason: + * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%) + * 2) If the clipboard client attaches during X Server startup, + * then it becomes the "magic client" that causes the X Server + * to reset if it exits. + * 3) XDMCP calls KillAllClients when it starts up. + * 4) The clipboard client is a client, so it is killed. + * 5) The clipboard client is the "magic client", so the X Server + * resets itself. + * 6) This repeats ad infinitum. + * 7) We avoid this by waiting until at least one client (could + * be XDM, could be another client) connects, which makes it + * almost certain that the clipboard client will not connect + * until after XDM when using XDMCP. + */ + + /* Create the clipboard client thread */ + if (!winInitClipboard ()) + { + ErrorF ("winProcEstablishConnection - winClipboardInit " + "failed.\n"); + return iReturn; + } + + winDebug ("winProcEstablishConnection - winInitClipboard returned.\n"); + } + + /* Flag that clipboard client has been launched */ + g_fClipboardLaunched = TRUE; + + return iReturn; +} + + +/* + * Wrapper for internal SetSelectionOwner function. + * Grabs ownership of Windows clipboard when X11 clipboard owner changes. + */ +int +winProcSetSelectionOwner (ClientPtr client) +{ + int i; + DrawablePtr pDrawable; + WindowPtr pWindow = None; + static Window s_iOwners[CLIP_NUM_SELECTIONS] = {None}; + static unsigned long s_ulServerGeneration = 0; + REQUEST(xSetSelectionOwnerReq); + + REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); + + winDebug ("winProcSetSelectionOwner - Hello.\n"); + + /* Watch for server reset */ + if (s_ulServerGeneration != serverGeneration) + { + /* Save new generation number */ + s_ulServerGeneration = serverGeneration; + + /* Initialize static variables */ + for (i = 0; i < CLIP_NUM_SELECTIONS; ++i) + s_iOwners[i] = None; + } + + /* Abort if clipboard not completely initialized yet */ + if (!g_fClipboardStarted) + { + winDebug ("winProcSetSelectionOwner - Clipboard not yet started, " + "aborting.\n"); + goto winProcSetSelectionOwner_Done; + } + + /* Grab window if we have one */ + if (None != stuff->window) + { + /* Grab the Window from the request */ + int rc = dixLookupWindow(&pWindow, stuff->window, client, DixReadAccess); + if (rc != Success) { + ErrorF ("winProcSetSelectionOwner - Found BadWindow, aborting.\n"); + goto winProcSetSelectionOwner_Done; + } + } + + /* Now we either have a valid window or None */ + + /* Save selection owners for monitored selections, ignore other selections */ + if (XA_PRIMARY == stuff->selection && g_fClipboardPrimary) + { + /* Look for owned -> not owned transition */ + if (None == stuff->window + && None != s_iOwners[CLIP_OWN_PRIMARY]) + { + winDebug ("winProcSetSelectionOwner - PRIMARY - Going from " + "owned to not owned.\n"); + + /* Adjust last owned selection */ + if (None != s_iOwners[CLIP_OWN_CLIPBOARD]) + g_atomLastOwnedSelection = MakeAtom ("CLIPBOARD", 9, TRUE); + else + g_atomLastOwnedSelection = None; + } + + /* Save new selection owner or None */ + s_iOwners[CLIP_OWN_PRIMARY] = stuff->window; + + winDebug ("winProcSetSelectionOwner - PRIMARY - Now owned by: 0x%x (clipboard is 0x%x)\n", + stuff->window,g_iClipboardWindow); + } + else if (MakeAtom ("CLIPBOARD", 9, TRUE) == stuff->selection) + { + /* Look for owned -> not owned transition */ + if (None == stuff->window + && None != s_iOwners[CLIP_OWN_CLIPBOARD]) + { + winDebug ("winProcSetSelectionOwner - CLIPBOARD - Going from " + "owned to not owned.\n"); + + /* Adjust last owned selection */ + if ((None != s_iOwners[CLIP_OWN_PRIMARY]) && g_fClipboardPrimary) + g_atomLastOwnedSelection = XA_PRIMARY; + else + g_atomLastOwnedSelection = None; + } + + /* Save new selection owner or None */ + s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window; + + winDebug ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: 0x%x, clipboard is 0x%x\n", + stuff->window,g_iClipboardWindow); + } + else + goto winProcSetSelectionOwner_Done; + + /* + * At this point, if one of the selections is still owned by the + * clipboard manager then it should be marked as unowned since + * we will be taking ownership of the Win32 clipboard. + */ + if (g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY]) + s_iOwners[CLIP_OWN_PRIMARY] = None; + if (g_iClipboardWindow == s_iOwners[CLIP_OWN_CLIPBOARD]) + s_iOwners[CLIP_OWN_CLIPBOARD] = None; + + /* Abort if no window at this point */ + if (None == stuff->window) + { + winDebug ("winProcSetSelectionOwner - No window, returning.\n"); + goto winProcSetSelectionOwner_Done; + } + + /* Abort if invalid selection */ + if (!ValidAtom (stuff->selection)) + { + winDebug ("winProcSetSelectionOwner - Found BadAtom, aborting.\n"); + goto winProcSetSelectionOwner_Done; + } + + /* Cast Window to Drawable */ + pDrawable = (DrawablePtr) pWindow; + + /* Abort if clipboard manager is owning the selection */ + if (pDrawable->id == g_iClipboardWindow) + { + winDebug ("winProcSetSelectionOwner - We changed ownership, " + "aborting.\n"); + goto winProcSetSelectionOwner_Done; + } + + /* Abort if root window is taking ownership */ + if (pDrawable->id == 0) + { + winDebug ("winProcSetSelectionOwner - Root window taking ownership, " + "aborting\n"); + goto winProcSetSelectionOwner_Done; + } + + /* Access the Windows clipboard */ + if (!OpenClipboard (g_hwndClipboard)) + { + ErrorF ("winProcSetSelectionOwner - OpenClipboard () failed: %08x, hwnd: %08x\n", + (int) GetLastError (),g_hwndClipboard); + goto winProcSetSelectionOwner_Done; + } + + /* Take ownership of the Windows clipboard */ + if (!EmptyClipboard ()) + { + ErrorF ("winProcSetSelectionOwner - EmptyClipboard () failed: %08x\n", + (int) GetLastError ()); + CloseClipboard (); + goto winProcSetSelectionOwner_Done; + } + + winDebug("winProcSetSelectionOwner - SetClipboardData NULL\n"); + + /* Advertise Unicode if we support it */ + if (g_fUnicodeSupport) + SetClipboardData (CF_UNICODETEXT, NULL); + + /* Always advertise regular text */ + SetClipboardData (CF_TEXT, NULL); + + /* Save handle to last owned selection */ + g_atomLastOwnedSelection = stuff->selection; + + /* Release the clipboard */ + if (!CloseClipboard ()) + { + ErrorF ("winProcSetSelectionOwner - CloseClipboard () failed: " + "%08x\n", + (int) GetLastError ()); + goto winProcSetSelectionOwner_Done; + } + +winProcSetSelectionOwner_Done: + return (*winProcSetSelectionOwnerOrig) (client); +} diff --git a/xorg-server/hw/xwin/winengine.c b/xorg-server/hw/xwin/winengine.c index 4b39bcfc2..3f5048dcd 100644 --- a/xorg-server/hw/xwin/winengine.c +++ b/xorg-server/hw/xwin/winengine.c @@ -68,20 +68,6 @@ winDetectSupportedEngines (void) osvi.dwOSVersionInfoSize = sizeof (osvi); GetVersionEx (&osvi); - /* Branch on platform ID */ - switch (osvi.dwPlatformId) - { - case VER_PLATFORM_WIN32_NT: - /* Engine 4 is supported on NT only */ - winDebug ("winDetectSupportedEngines - Windows NT/2000/XP\n"); - break; - - case VER_PLATFORM_WIN32_WINDOWS: - /* Engine 4 is supported on NT only */ - winDebug ("winDetectSupportedEngines - Windows 95/98/Me\n"); - break; - } - /* Do we have DirectDraw? */ if (g_hmodDirectDraw != NULL) { diff --git a/xorg-server/hw/xwin/winkeybd.c b/xorg-server/hw/xwin/winkeybd.c index a02e22d74..f5187571d 100644 --- a/xorg-server/hw/xwin/winkeybd.c +++ b/xorg-server/hw/xwin/winkeybd.c @@ -360,7 +360,7 @@ winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam) /* Get time of current message */ lTime = GetMessageTime (); - /* Look for next press message. */ + /* Look for next press message */ fReturn = PeekMessage (&msgNext, NULL, WM_KEYDOWN, WM_SYSKEYDOWN, PM_NOREMOVE); @@ -429,16 +429,16 @@ winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam) /* Get time of current message */ lTime = GetMessageTime (); - /* Look for next release message. */ + /* Look for next release message */ fReturn = PeekMessage (&msgNext, NULL, WM_KEYUP, WM_SYSKEYUP, PM_NOREMOVE); - + if (fReturn && msgNext.message != WM_KEYUP && msgNext.message != WM_SYSKEYUP) fReturn = 0; - + lastWasControlL = FALSE; - + /* Is next press an Alt_R with the same timestamp? */ if (fReturn && (msgNext.message == WM_KEYUP diff --git a/xorg-server/hw/xwin/winkeybd.h b/xorg-server/hw/xwin/winkeybd.h index 887ab7ad6..292d05cb6 100644 --- a/xorg-server/hw/xwin/winkeybd.h +++ b/xorg-server/hw/xwin/winkeybd.h @@ -1,308 +1,308 @@ -#if !defined(WINKEYBD_H)
-#define WINKEYBD_H
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, 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 THE XFREE86 PROJECT 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 XFree86 Project
- *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 XFree86 Project.
- *
- * Authors: Harold L Hunt II
- */
-
-/*
- * We need symbols for the scan codes of keys.
- */
-#include "winkeynames.h"
-
-#define VK_FN 0xFF
-
-#define WIN_KEYMAP_COLS 3
-
-/* ASCII column, rows 33 through 40 are for Speech Recognition with
- * num-lock asserted.
- * Rows 160 through 165 correspond to software-generated codes, which
- * may not be associated with the appropriate scan code/extended bit
- */
-const int
-g_iKeyMap [] = {
- /* count Windows VK, ASCII, ASCII when extended VK */
- /* 0 */ 0, 0, 0,
- /* 1 */ 0, 0, 0,
- /* 2 */ 0, 0, 0,
- /* 3 */ VK_CANCEL, 0, KEY_Break,
- /* 4 */ 0, 0, 0,
- /* 5 */ 0, 0, 0,
- /* 6 */ 0, 0, 0,
- /* 7 */ 0, 0, 0,
- /* 8 */ 0, 0, 0,
- /* 9 */ 0, 0, 0,
- /* 10 */ 0, 0, 0,
- /* 11 */ 0, 0, 0,
- /* 12 */ 0, 0, 0,
- /* 13 */ VK_RETURN, 0, KEY_KP_Enter,
- /* 14 */ 0, 0, 0,
- /* 15 */ 0, 0, 0,
- /* 16 */ VK_SHIFT, 0, 0,
- /* 17 */ VK_CONTROL, 0, KEY_RCtrl,
- /* 18 */ VK_MENU, 0, KEY_AltLang,
- /* 19 */ VK_PAUSE, KEY_Pause, 0,
- /* 20 */ 0, 0, 0,
- /* 21 */ 0, 0, 0,
- /* 22 */ 0, 0, 0,
- /* 23 */ 0, 0, 0,
- /* 24 */ 0, 0, 0,
- /* 25 */ 0, 0, 0,
- /* 26 */ 0, 0, 0,
- /* 27 */ 0, 0, 0,
- /* 28 */ 0, 0, 0,
- /* 29 */ 0, 0, 0,
- /* 30 */ 0, 0, 0,
- /* 31 */ 0, 0, 0,
- /* 32 */ 0, 0, 0,
- /* 33 */ VK_PRIOR, KEY_PgUp, KEY_PgUp,
- /* 34 */ VK_NEXT, KEY_PgDown, KEY_PgDown,
- /* 35 */ VK_END, KEY_End, KEY_End,
- /* 36 */ VK_HOME, KEY_Home, KEY_Home,
- /* 37 */ VK_LEFT, KEY_Left, KEY_Left,
- /* 38 */ VK_UP, KEY_Up, KEY_Up,
- /* 39 */ VK_RIGHT, KEY_Right, KEY_Right,
- /* 40 */ VK_DOWN, KEY_Down, KEY_Down,
- /* 41 */ 0, 0, 0,
- /* 42 */ 0, 0, 0,
- /* 43 */ 0, 0, 0,
- /* 44 */ VK_SNAPSHOT, 0, KEY_Print,
- /* 45 */ VK_INSERT, 0, KEY_Insert,
- /* 46 */ VK_DELETE, 0, KEY_Delete,
- /* 47 */ 0, 0, 0,
- /* 48 */ 0, 0, 0,
- /* 49 */ 0, 0, 0,
- /* 50 */ 0, 0, 0,
- /* 51 */ 0, 0, 0,
- /* 52 */ 0, 0, 0,
- /* 53 */ 0, 0, 0,
- /* 54 */ 0, 0, 0,
- /* 55 */ 0, 0, 0,
- /* 56 */ 0, 0, 0,
- /* 57 */ 0, 0, 0,
- /* 58 */ 0, 0, 0,
- /* 59 */ 0, 0, 0,
- /* 60 */ 0, 0, 0,
- /* 61 */ 0, 0, 0,
- /* 62 */ 0, 0, 0,
- /* 63 */ 0, 0, 0,
- /* 64 */ 0, 0, 0,
- /* 65 */ 0, 0, 0,
- /* 66 */ 0, 0, 0,
- /* 67 */ 0, 0, 0,
- /* 68 */ 0, 0, 0,
- /* 69 */ 0, 0, 0,
- /* 70 */ 0, 0, 0,
- /* 71 */ 0, 0, 0,
- /* 72 */ 0, 0, 0,
- /* 73 */ 0, 0, 0,
- /* 74 */ 0, 0, 0,
- /* 75 */ 0, 0, 0,
- /* 76 */ 0, 0, 0,
- /* 77 */ 0, 0, 0,
- /* 78 */ 0, 0, 0,
- /* 79 */ 0, 0, 0,
- /* 80 */ 0, 0, 0,
- /* 81 */ 0, 0, 0,
- /* 82 */ 0, 0, 0,
- /* 83 */ 0, 0, 0,
- /* 84 */ 0, 0, 0,
- /* 85 */ 0, 0, 0,
- /* 86 */ 0, 0, 0,
- /* 87 */ 0, 0, 0,
- /* 88 */ 0, 0, 0,
- /* 89 */ 0, 0, 0,
- /* 90 */ 0, 0, 0,
- /* 91 */ VK_LWIN, KEY_LMeta, 0,
- /* 92 */ VK_RWIN, KEY_RMeta, 0,
- /* 93 */ VK_APPS, KEY_Menu, 0,
- /* 94 */ 0, 0, 0,
- /* 95 */ 0, 0, 0,
- /* 96 */ 0, 0, 0,
- /* 97 */ 0, 0, 0,
- /* 98 */ 0, 0, 0,
- /* 99 */ 0, 0, 0,
- /* 100 */ 0, 0, 0,
- /* 101 */ 0, 0, 0,
- /* 102 */ 0, 0, 0,
- /* 103 */ 0, 0, 0,
- /* 104 */ 0, 0, 0,
- /* 105 */ 0, 0, 0,
- /* 106 */ 0, 0, 0,
- /* 107 */ 0, 0, 0,
- /* 108 */ 0, 0, 0,
- /* 109 */ 0, 0, 0,
- /* 110 */ 0, 0, 0,
- /* 111 */ VK_DIVIDE, 0, KEY_KP_Divide,
- /* 112 */ 0, 0, 0,
- /* 113 */ 0, 0, 0,
- /* 114 */ 0, 0, 0,
- /* 115 */ 0, 0, 0,
- /* 116 */ 0, 0, 0,
- /* 117 */ 0, 0, 0,
- /* 118 */ 0, 0, 0,
- /* 119 */ 0, 0, 0,
- /* 120 */ 0, 0, 0,
- /* 121 */ 0, 0, 0,
- /* 122 */ 0, 0, 0,
- /* 123 */ 0, 0, 0,
- /* 124 */ 0, 0, 0,
- /* 125 */ 0, 0, 0,
- /* 126 */ 0, 0, 0,
- /* 127 */ 0, 0, 0,
- /* 128 */ 0, 0, 0,
- /* 129 */ 0, 0, 0,
- /* 130 */ 0, 0, 0,
- /* 131 */ 0, 0, 0,
- /* 132 */ 0, 0, 0,
- /* 133 */ 0, 0, 0,
- /* 134 */ 0, 0, 0,
- /* 135 */ 0, 0, 0,
- /* 136 */ 0, 0, 0,
- /* 137 */ 0, 0, 0,
- /* 138 */ 0, 0, 0,
- /* 139 */ 0, 0, 0,
- /* 140 */ 0, 0, 0,
- /* 141 */ 0, 0, 0,
- /* 142 */ 0, 0, 0,
- /* 143 */ 0, 0, 0,
- /* 144 */ 0, 0, 0,
- /* 145 */ 0, 0, 0,
- /* 146 */ 0, 0, 0,
- /* 147 */ 0, 0, 0,
- /* 148 */ 0, 0, 0,
- /* 149 */ 0, 0, 0,
- /* 150 */ 0, 0, 0,
- /* 151 */ 0, 0, 0,
- /* 152 */ 0, 0, 0,
- /* 153 */ 0, 0, 0,
- /* 154 */ 0, 0, 0,
- /* 155 */ 0, 0, 0,
- /* 156 */ 0, 0, 0,
- /* 157 */ 0, 0, 0,
- /* 158 */ 0, 0, 0,
- /* 159 */ 0, 0, 0,
- /* 160 */ VK_LSHIFT, KEY_ShiftL, KEY_ShiftL,
- /* 161 */ VK_RSHIFT, KEY_ShiftR, KEY_ShiftR,
- /* 162 */ VK_LCONTROL, KEY_LCtrl, KEY_LCtrl,
- /* 163 */ VK_RCONTROL, KEY_RCtrl, KEY_RCtrl,
- /* 164 */ VK_LMENU, KEY_Alt, KEY_Alt,
- /* 165 */ VK_RMENU, KEY_AltLang, KEY_AltLang,
- /* 166 */ 0, 0, 0,
- /* 167 */ 0, 0, 0,
- /* 168 */ 0, 0, 0,
- /* 169 */ 0, 0, 0,
- /* 170 */ 0, 0, 0,
- /* 171 */ 0, 0, 0,
- /* 172 */ 0, 0, 0,
- /* 173 */ VK_VOLUME_MUTE, 0, KEY_Mute,
- /* 174 */ VK_VOLUME_DOWN, 0, KEY_AudioLower,
- /* 175 */ VK_VOLUME_UP, 0, KEY_AudioRaise,
- /* 176 */ VK_MEDIA_NEXT_TRACK, 0, KEY_NEXTSONG,
- /* 177 */ VK_MEDIA_PREV_TRACK, 0, KEY_PREVIOUSSONG,
- /* 178 */ VK_MEDIA_STOP, 0, KEY_STOPCD,
- /* 179 */ VK_MEDIA_PLAY_PAUSE, 0, KEY_PLAYPAUSE,
- /* 180 */ 0, 0, 0,
- /* 181 */ 0, 0, 0,
- /* 182 */ 0, 0, 0,
- /* 183 */ 0, 0, 0,
- /* 184 */ 0, 0, 0,
- /* 185 */ 0, 0, 0,
- /* 186 */ 0, 0, 0,
- /* 187 */ 0, 0, 0,
- /* 188 */ 0, 0, 0,
- /* 189 */ 0, 0, 0,
- /* 190 */ 0, 0, 0,
- /* 191 */ 0, 0, 0,
- /* 192 */ 0, 0, 0,
- /* 193 */ 0, 0, 0,
- /* 194 */ 0, 0, 0,
- /* 195 */ 0, 0, 0,
- /* 196 */ 0, 0, 0,
- /* 197 */ 0, 0, 0,
- /* 198 */ 0, 0, 0,
- /* 199 */ 0, 0, 0,
- /* 200 */ 0, 0, 0,
- /* 201 */ 0, 0, 0,
- /* 202 */ 0, 0, 0,
- /* 203 */ 0, 0, 0,
- /* 204 */ 0, 0, 0,
- /* 205 */ 0, 0, 0,
- /* 206 */ 0, 0, 0,
- /* 207 */ 0, 0, 0,
- /* 208 */ 0, 0, 0,
- /* 209 */ 0, 0, 0,
- /* 210 */ 0, 0, 0,
- /* 211 */ 0, 0, 0,
- /* 212 */ 0, 0, 0,
- /* 213 */ 0, 0, 0,
- /* 214 */ 0, 0, 0,
- /* 215 */ 0, 0, 0,
- /* 216 */ 0, 0, 0,
- /* 217 */ 0, 0, 0,
- /* 218 */ 0, 0, 0,
- /* 219 */ 0, 0, 0,
- /* 220 */ 0, 0, 0,
- /* 221 */ 0, 0, 0,
- /* 222 */ 0, 0, 0,
- /* 223 */ VK_OEM_8, 0, KEY_RCtrl, /* at least on Candian Multilingual Standard layout */
- /* 224 */ 0, 0, 0,
- /* 225 */ 0, 0, 0,
- /* 226 */ 0, 0, 0,
- /* 227 */ 0, 0, 0,
- /* 228 */ 0, 0, 0,
- /* 229 */ 0, 0, 0,
- /* 230 */ 0, 0, 0,
- /* 231 */ 0, 0, 0,
- /* 232 */ 0, 0, 0,
- /* 233 */ 0, 0, 0,
- /* 234 */ 0, 0, 0,
- /* 235 */ 0, 0, 0,
- /* 236 */ 0, 0, 0,
- /* 237 */ 0, 0, 0,
- /* 238 */ 0, 0, 0,
- /* 239 */ 0, 0, 0,
- /* 240 */ 0, 0, 0,
- /* 241 */ 0, 0, 0,
- /* 242 */ 0, 0, 0,
- /* 243 */ 0, 0, 0,
- /* 244 */ 0, 0, 0,
- /* 245 */ 0, 0, 0,
- /* 246 */ 0, 0, 0,
- /* 247 */ 0, 0, 0,
- /* 248 */ 0, 0, 0,
- /* 249 */ 0, 0, 0,
- /* 250 */ 0, 0, 0,
- /* 251 */ 0, 0, 0,
- /* 252 */ 0, 0, 0,
- /* 253 */ 0, 0, 0,
- /* 254 */ 0, 0, 0,
- /* 255 */ VK_FN, 0, KEY_Fn /* Most keyboards don't generate a scancode for Fn, but a few do... */
-};
-
-#endif /* WINKEYBD_H */
+#if !defined(WINKEYBD_H) +#define WINKEYBD_H +/* + *Copyright (C) 1994-2000 The XFree86 Project, 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 THE XFREE86 PROJECT 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 XFree86 Project + *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 XFree86 Project. + * + * Authors: Harold L Hunt II + */ + +/* + * We need symbols for the scan codes of keys. + */ +#include "winkeynames.h" + +#define VK_FN 0xFF + +#define WIN_KEYMAP_COLS 3 + +/* ASCII column, rows 33 through 40 are for Speech Recognition with + * num-lock asserted. + * Rows 160 through 165 correspond to software-generated codes, which + * may not be associated with the appropriate scan code/extended bit + */ +const int +g_iKeyMap [] = { + /* count Windows VK, ASCII, ASCII when extended VK */ + /* 0 */ 0, 0, 0, + /* 1 */ 0, 0, 0, + /* 2 */ 0, 0, 0, + /* 3 */ VK_CANCEL, 0, KEY_Break, + /* 4 */ 0, 0, 0, + /* 5 */ 0, 0, 0, + /* 6 */ 0, 0, 0, + /* 7 */ 0, 0, 0, + /* 8 */ 0, 0, 0, + /* 9 */ 0, 0, 0, + /* 10 */ 0, 0, 0, + /* 11 */ 0, 0, 0, + /* 12 */ 0, 0, 0, + /* 13 */ VK_RETURN, 0, KEY_KP_Enter, + /* 14 */ 0, 0, 0, + /* 15 */ 0, 0, 0, + /* 16 */ VK_SHIFT, 0, 0, + /* 17 */ VK_CONTROL, 0, KEY_RCtrl, + /* 18 */ VK_MENU, 0, KEY_AltLang, + /* 19 */ VK_PAUSE, KEY_Pause, 0, + /* 20 */ 0, 0, 0, + /* 21 */ 0, 0, 0, + /* 22 */ 0, 0, 0, + /* 23 */ 0, 0, 0, + /* 24 */ 0, 0, 0, + /* 25 */ 0, 0, 0, + /* 26 */ 0, 0, 0, + /* 27 */ 0, 0, 0, + /* 28 */ 0, 0, 0, + /* 29 */ 0, 0, 0, + /* 30 */ 0, 0, 0, + /* 31 */ 0, 0, 0, + /* 32 */ 0, 0, 0, + /* 33 */ VK_PRIOR, KEY_PgUp, KEY_PgUp, + /* 34 */ VK_NEXT, KEY_PgDown, KEY_PgDown, + /* 35 */ VK_END, KEY_End, KEY_End, + /* 36 */ VK_HOME, KEY_Home, KEY_Home, + /* 37 */ VK_LEFT, KEY_Left, KEY_Left, + /* 38 */ VK_UP, KEY_Up, KEY_Up, + /* 39 */ VK_RIGHT, KEY_Right, KEY_Right, + /* 40 */ VK_DOWN, KEY_Down, KEY_Down, + /* 41 */ 0, 0, 0, + /* 42 */ 0, 0, 0, + /* 43 */ 0, 0, 0, + /* 44 */ VK_SNAPSHOT, 0, KEY_Print, + /* 45 */ VK_INSERT, 0, KEY_Insert, + /* 46 */ VK_DELETE, 0, KEY_Delete, + /* 47 */ 0, 0, 0, + /* 48 */ 0, 0, 0, + /* 49 */ 0, 0, 0, + /* 50 */ 0, 0, 0, + /* 51 */ 0, 0, 0, + /* 52 */ 0, 0, 0, + /* 53 */ 0, 0, 0, + /* 54 */ 0, 0, 0, + /* 55 */ 0, 0, 0, + /* 56 */ 0, 0, 0, + /* 57 */ 0, 0, 0, + /* 58 */ 0, 0, 0, + /* 59 */ 0, 0, 0, + /* 60 */ 0, 0, 0, + /* 61 */ 0, 0, 0, + /* 62 */ 0, 0, 0, + /* 63 */ 0, 0, 0, + /* 64 */ 0, 0, 0, + /* 65 */ 0, 0, 0, + /* 66 */ 0, 0, 0, + /* 67 */ 0, 0, 0, + /* 68 */ 0, 0, 0, + /* 69 */ 0, 0, 0, + /* 70 */ 0, 0, 0, + /* 71 */ 0, 0, 0, + /* 72 */ 0, 0, 0, + /* 73 */ 0, 0, 0, + /* 74 */ 0, 0, 0, + /* 75 */ 0, 0, 0, + /* 76 */ 0, 0, 0, + /* 77 */ 0, 0, 0, + /* 78 */ 0, 0, 0, + /* 79 */ 0, 0, 0, + /* 80 */ 0, 0, 0, + /* 81 */ 0, 0, 0, + /* 82 */ 0, 0, 0, + /* 83 */ 0, 0, 0, + /* 84 */ 0, 0, 0, + /* 85 */ 0, 0, 0, + /* 86 */ 0, 0, 0, + /* 87 */ 0, 0, 0, + /* 88 */ 0, 0, 0, + /* 89 */ 0, 0, 0, + /* 90 */ 0, 0, 0, + /* 91 */ VK_LWIN, KEY_LMeta, 0, + /* 92 */ VK_RWIN, KEY_RMeta, 0, + /* 93 */ VK_APPS, KEY_Menu, 0, + /* 94 */ 0, 0, 0, + /* 95 */ 0, 0, 0, + /* 96 */ 0, 0, 0, + /* 97 */ 0, 0, 0, + /* 98 */ 0, 0, 0, + /* 99 */ 0, 0, 0, + /* 100 */ 0, 0, 0, + /* 101 */ 0, 0, 0, + /* 102 */ 0, 0, 0, + /* 103 */ 0, 0, 0, + /* 104 */ 0, 0, 0, + /* 105 */ 0, 0, 0, + /* 106 */ 0, 0, 0, + /* 107 */ 0, 0, 0, + /* 108 */ 0, 0, 0, + /* 109 */ 0, 0, 0, + /* 110 */ 0, 0, 0, + /* 111 */ VK_DIVIDE, 0, KEY_KP_Divide, + /* 112 */ 0, 0, 0, + /* 113 */ 0, 0, 0, + /* 114 */ 0, 0, 0, + /* 115 */ 0, 0, 0, + /* 116 */ 0, 0, 0, + /* 117 */ 0, 0, 0, + /* 118 */ 0, 0, 0, + /* 119 */ 0, 0, 0, + /* 120 */ 0, 0, 0, + /* 121 */ 0, 0, 0, + /* 122 */ 0, 0, 0, + /* 123 */ 0, 0, 0, + /* 124 */ 0, 0, 0, + /* 125 */ 0, 0, 0, + /* 126 */ 0, 0, 0, + /* 127 */ 0, 0, 0, + /* 128 */ 0, 0, 0, + /* 129 */ 0, 0, 0, + /* 130 */ 0, 0, 0, + /* 131 */ 0, 0, 0, + /* 132 */ 0, 0, 0, + /* 133 */ 0, 0, 0, + /* 134 */ 0, 0, 0, + /* 135 */ 0, 0, 0, + /* 136 */ 0, 0, 0, + /* 137 */ 0, 0, 0, + /* 138 */ 0, 0, 0, + /* 139 */ 0, 0, 0, + /* 140 */ 0, 0, 0, + /* 141 */ 0, 0, 0, + /* 142 */ 0, 0, 0, + /* 143 */ 0, 0, 0, + /* 144 */ 0, 0, 0, + /* 145 */ 0, 0, 0, + /* 146 */ 0, 0, 0, + /* 147 */ 0, 0, 0, + /* 148 */ 0, 0, 0, + /* 149 */ 0, 0, 0, + /* 150 */ 0, 0, 0, + /* 151 */ 0, 0, 0, + /* 152 */ 0, 0, 0, + /* 153 */ 0, 0, 0, + /* 154 */ 0, 0, 0, + /* 155 */ 0, 0, 0, + /* 156 */ 0, 0, 0, + /* 157 */ 0, 0, 0, + /* 158 */ 0, 0, 0, + /* 159 */ 0, 0, 0, + /* 160 */ VK_LSHIFT, KEY_ShiftL, KEY_ShiftL, + /* 161 */ VK_RSHIFT, KEY_ShiftR, KEY_ShiftR, + /* 162 */ VK_LCONTROL, KEY_LCtrl, KEY_LCtrl, + /* 163 */ VK_RCONTROL, KEY_RCtrl, KEY_RCtrl, + /* 164 */ VK_LMENU, KEY_Alt, KEY_Alt, + /* 165 */ VK_RMENU, KEY_AltLang, KEY_AltLang, + /* 166 */ 0, 0, 0, + /* 167 */ 0, 0, 0, + /* 168 */ 0, 0, 0, + /* 169 */ 0, 0, 0, + /* 170 */ 0, 0, 0, + /* 171 */ 0, 0, 0, + /* 172 */ 0, 0, 0, + /* 173 */ VK_VOLUME_MUTE, 0, KEY_Mute, + /* 174 */ VK_VOLUME_DOWN, 0, KEY_AudioLower, + /* 175 */ VK_VOLUME_UP, 0, KEY_AudioRaise, + /* 176 */ VK_MEDIA_NEXT_TRACK, 0, KEY_NEXTSONG, + /* 177 */ VK_MEDIA_PREV_TRACK, 0, KEY_PREVIOUSSONG, + /* 178 */ VK_MEDIA_STOP, 0, KEY_STOPCD, + /* 179 */ VK_MEDIA_PLAY_PAUSE, 0, KEY_PLAYPAUSE, + /* 180 */ 0, 0, 0, + /* 181 */ 0, 0, 0, + /* 182 */ 0, 0, 0, + /* 183 */ 0, 0, 0, + /* 184 */ 0, 0, 0, + /* 185 */ 0, 0, 0, + /* 186 */ 0, 0, 0, + /* 187 */ 0, 0, 0, + /* 188 */ 0, 0, 0, + /* 189 */ 0, 0, 0, + /* 190 */ 0, 0, 0, + /* 191 */ 0, 0, 0, + /* 192 */ 0, 0, 0, + /* 193 */ 0, 0, 0, + /* 194 */ 0, 0, 0, + /* 195 */ 0, 0, 0, + /* 196 */ 0, 0, 0, + /* 197 */ 0, 0, 0, + /* 198 */ 0, 0, 0, + /* 199 */ 0, 0, 0, + /* 200 */ 0, 0, 0, + /* 201 */ 0, 0, 0, + /* 202 */ 0, 0, 0, + /* 203 */ 0, 0, 0, + /* 204 */ 0, 0, 0, + /* 205 */ 0, 0, 0, + /* 206 */ 0, 0, 0, + /* 207 */ 0, 0, 0, + /* 208 */ 0, 0, 0, + /* 209 */ 0, 0, 0, + /* 210 */ 0, 0, 0, + /* 211 */ 0, 0, 0, + /* 212 */ 0, 0, 0, + /* 213 */ 0, 0, 0, + /* 214 */ 0, 0, 0, + /* 215 */ 0, 0, 0, + /* 216 */ 0, 0, 0, + /* 217 */ 0, 0, 0, + /* 218 */ 0, 0, 0, + /* 219 */ 0, 0, 0, + /* 220 */ 0, 0, 0, + /* 221 */ 0, 0, 0, + /* 222 */ 0, 0, 0, + /* 223 */ VK_OEM_8, 0, KEY_RCtrl, /* at least on Canadian Multilingual Standard layout */ + /* 224 */ 0, 0, 0, + /* 225 */ 0, 0, 0, + /* 226 */ 0, 0, 0, + /* 227 */ 0, 0, 0, + /* 228 */ 0, 0, 0, + /* 229 */ 0, 0, 0, + /* 230 */ 0, 0, 0, + /* 231 */ 0, 0, 0, + /* 232 */ 0, 0, 0, + /* 233 */ 0, 0, 0, + /* 234 */ 0, 0, 0, + /* 235 */ 0, 0, 0, + /* 236 */ 0, 0, 0, + /* 237 */ 0, 0, 0, + /* 238 */ 0, 0, 0, + /* 239 */ 0, 0, 0, + /* 240 */ 0, 0, 0, + /* 241 */ 0, 0, 0, + /* 242 */ 0, 0, 0, + /* 243 */ 0, 0, 0, + /* 244 */ 0, 0, 0, + /* 245 */ 0, 0, 0, + /* 246 */ 0, 0, 0, + /* 247 */ 0, 0, 0, + /* 248 */ 0, 0, 0, + /* 249 */ 0, 0, 0, + /* 250 */ 0, 0, 0, + /* 251 */ 0, 0, 0, + /* 252 */ 0, 0, 0, + /* 253 */ 0, 0, 0, + /* 254 */ 0, 0, 0, + /* 255 */ VK_FN, 0, KEY_Fn /* Most keyboards don't generate a scancode for Fn, but a few do... */ +}; + +#endif /* WINKEYBD_H */ diff --git a/xorg-server/hw/xwin/winkeynames.h b/xorg-server/hw/xwin/winkeynames.h index 55842f1b8..75e172e1f 100644 --- a/xorg-server/hw/xwin/winkeynames.h +++ b/xorg-server/hw/xwin/winkeynames.h @@ -1,206 +1,206 @@ -#ifndef _WINKEYNAMES_H
-#define _WINKEYNAMES_H
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Thomas Roell makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL 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.
- *
- */
-
-#define GLYPHS_PER_KEY 4
-#define NUM_KEYCODES 248
-#define MIN_KEYCODE 8
-#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1)
-
-#define AltMask Mod1Mask
-#define NumLockMask Mod2Mask
-#define AltLangMask Mod3Mask
-#define KanaMask Mod4Mask
-#define ScrollLockMask Mod5Mask
-
-#define ModifierDown(k) ((keyc->state & (k)) == (k))
-
-/*
- * NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three)
- * sets of scancodes. Set3 can only be generated by a MF keyboard.
- * Set2 sends a makecode for keypress, and the same code prefixed by a
- * F0 for keyrelease. This is a little bit ugly to handle. Thus we use
- * here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes.
- * Bit 7 ist set if the key is released. The code E0 switches to a
- * different meaning to add the new MF cursorkeys, while not breaking old
- * applications. E1 is another special prefix. Since I assume that there
- * will be further versions of PC/XT scancode compatible keyboards, we
- * may be in trouble one day.
- *
- * IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3.
- * 2) Use the keyboards native set and translate it to common keysyms.
- */
-
-/*
- * definition of the AT84/MF101/MF102 Keyboard:
- * ============================================================
- * Defined Key Cap Glyphs Pressed value
- * Key Name Main Also (hex) (dec)
- * ---------------- ---------- ------- ------ ------
- */
-
-#define KEY_Escape /* Escape 0x01 */ 1
-#define KEY_1 /* 1 ! 0x02 */ 2
-#define KEY_2 /* 2 @ 0x03 */ 3
-#define KEY_3 /* 3 # 0x04 */ 4
-#define KEY_4 /* 4 $ 0x05 */ 5
-#define KEY_5 /* 5 % 0x06 */ 6
-#define KEY_6 /* 6 ^ 0x07 */ 7
-#define KEY_7 /* 7 & 0x08 */ 8
-#define KEY_8 /* 8 * 0x09 */ 9
-#define KEY_9 /* 9 ( 0x0a */ 10
-#define KEY_0 /* 0 ) 0x0b */ 11
-#define KEY_Minus /* - (Minus) _ (Under) 0x0c */ 12
-#define KEY_Equal /* = (Equal) + 0x0d */ 13
-#define KEY_BackSpace /* Back Space 0x0e */ 14
-#define KEY_Tab /* Tab 0x0f */ 15
-#define KEY_Q /* Q 0x10 */ 16
-#define KEY_W /* W 0x11 */ 17
-#define KEY_E /* E 0x12 */ 18
-#define KEY_R /* R 0x13 */ 19
-#define KEY_T /* T 0x14 */ 20
-#define KEY_Y /* Y 0x15 */ 21
-#define KEY_U /* U 0x16 */ 22
-#define KEY_I /* I 0x17 */ 23
-#define KEY_O /* O 0x18 */ 24
-#define KEY_P /* P 0x19 */ 25
-#define KEY_LBrace /* [ { 0x1a */ 26
-#define KEY_RBrace /* ] } 0x1b */ 27
-#define KEY_Enter /* Enter 0x1c */ 28
-#define KEY_LCtrl /* Ctrl(left) 0x1d */ 29
-#define KEY_A /* A 0x1e */ 30
-#define KEY_S /* S 0x1f */ 31
-#define KEY_D /* D 0x20 */ 32
-#define KEY_F /* F 0x21 */ 33
-#define KEY_G /* G 0x22 */ 34
-#define KEY_H /* H 0x23 */ 35
-#define KEY_J /* J 0x24 */ 36
-#define KEY_K /* K 0x25 */ 37
-#define KEY_L /* L 0x26 */ 38
-#define KEY_SemiColon /* ;(SemiColon) :(Colon) 0x27 */ 39
-#define KEY_Quote /* ' (Apostr) " (Quote) 0x28 */ 40
-#define KEY_Tilde /* ` (Accent) ~ (Tilde) 0x29 */ 41
-#define KEY_ShiftL /* Shift(left) 0x2a */ 42
-#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 43
-#define KEY_Z /* Z 0x2c */ 44
-#define KEY_X /* X 0x2d */ 45
-#define KEY_C /* C 0x2e */ 46
-#define KEY_V /* V 0x2f */ 47
-#define KEY_B /* B 0x30 */ 48
-#define KEY_N /* N 0x31 */ 49
-#define KEY_M /* M 0x32 */ 50
-#define KEY_Comma /* , (Comma) < (Less) 0x33 */ 51
-#define KEY_Period /* . (Period) >(Greater)0x34 */ 52
-#define KEY_Slash /* / (Slash) ? 0x35 */ 53
-#define KEY_ShiftR /* Shift(right) 0x36 */ 54
-#define KEY_KP_Multiply /* * 0x37 */ 55
-#define KEY_Alt /* Alt(left) 0x38 */ 56
-#define KEY_Space /* (SpaceBar) 0x39 */ 57
-#define KEY_CapsLock /* CapsLock 0x3a */ 58
-#define KEY_F1 /* F1 0x3b */ 59
-#define KEY_F2 /* F2 0x3c */ 60
-#define KEY_F3 /* F3 0x3d */ 61
-#define KEY_F4 /* F4 0x3e */ 62
-#define KEY_F5 /* F5 0x3f */ 63
-#define KEY_F6 /* F6 0x40 */ 64
-#define KEY_F7 /* F7 0x41 */ 65
-#define KEY_F8 /* F8 0x42 */ 66
-#define KEY_F9 /* F9 0x43 */ 67
-#define KEY_F10 /* F10 0x44 */ 68
-#define KEY_NumLock /* NumLock 0x45 */ 69
-#define KEY_ScrollLock /* ScrollLock 0x46 */ 70
-#define KEY_KP_7 /* 7 Home 0x47 */ 71
-#define KEY_KP_8 /* 8 Up 0x48 */ 72
-#define KEY_KP_9 /* 9 PgUp 0x49 */ 73
-#define KEY_KP_Minus /* - (Minus) 0x4a */ 74
-#define KEY_KP_4 /* 4 Left 0x4b */ 75
-#define KEY_KP_5 /* 5 0x4c */ 76
-#define KEY_KP_6 /* 6 Right 0x4d */ 77
-#define KEY_KP_Plus /* + (Plus) 0x4e */ 78
-#define KEY_KP_1 /* 1 End 0x4f */ 79
-#define KEY_KP_2 /* 2 Down 0x50 */ 80
-#define KEY_KP_3 /* 3 PgDown 0x51 */ 81
-#define KEY_KP_0 /* 0 Insert 0x52 */ 82
-#define KEY_KP_Decimal /* . (Decimal) Delete 0x53 */ 83
-#define KEY_SysReqest /* SysReqest 0x54 */ 84
-#define KEY_Fn /* Fn 0x55 */ 85
-#define KEY_Less /* < (Less) >(Greater) 0x56 */ 86
-#define KEY_F11 /* F11 0x57 */ 87
-#define KEY_F12 /* F12 0x58 */ 88
-
-#define KEY_Prefix0 /* special 0x60 */ 96
-#define KEY_Prefix1 /* specail 0x61 */ 97
-
-/*
- * The 'scancodes' below are generated by the server, because the MF101/102
- * keyboard sends them as sequence of other scancodes
- */
-#define KEY_Home /* Home 0x59 */ 89
-#define KEY_Up /* Up 0x5a */ 90
-#define KEY_PgUp /* PgUp 0x5b */ 91
-#define KEY_Left /* Left 0x5c */ 92
-#define KEY_Begin /* Begin 0x5d */ 93
-#define KEY_Right /* Right 0x5e */ 94
-#define KEY_End /* End 0x5f */ 95
-#define KEY_Down /* Down 0x60 */ 96
-#define KEY_PgDown /* PgDown 0x61 */ 97
-#define KEY_Insert /* Insert 0x62 */ 98
-#define KEY_Delete /* Delete 0x63 */ 99
-#define KEY_KP_Enter /* Enter 0x64 */ 100
-#define KEY_RCtrl /* Ctrl(right) 0x65 */ 101
-#define KEY_Pause /* Pause 0x66 */ 102
-#define KEY_Print /* Print 0x67 */ 103
-#define KEY_KP_Divide /* Divide 0x68 */ 104
-#define KEY_AltLang /* AtlLang(right) 0x69 */ 105
-#define KEY_Break /* Break 0x6a */ 106
-#define KEY_LMeta /* Left Meta 0x6b */ 107
-#define KEY_RMeta /* Right Meta 0x6c */ 108
-#define KEY_Menu /* Menu 0x6d */ 109
-#define KEY_F13 /* F13 0x6e */ 110
-#define KEY_F14 /* F14 0x6f */ 111
-#define KEY_F15 /* F15 0x70 */ 112
-#define KEY_F16 /* F16 0x71 */ 113
-#define KEY_F17 /* F17 0x72 */ 114
-#define KEY_KP_DEC /* KP_DEC 0x73 */ 115
-#define KEY_KP_Equal /* Equal (Keypad) 0x76 */ 118
-#define KEY_XFER /* Kanji Transfer 0x79 */ 121
-#define KEY_NFER /* No Kanji Transfer 0x7b */ 123
-#define KEY_Yen /* Yen 0x7d */ 125
-#define KEY_HKTG /* Hirugana/Katakana tog 0xc8 */ 200
-#define KEY_BSlash2 /* \ _ 0xcb */ 203
-
-#define KEY_Mute /* Audio Mute */ 152
-#define KEY_AudioLower /* Audio Lower */ 168
-#define KEY_AudioRaise /* Audio Raise */ 166
-
-#define KEY_NEXTSONG /* Media next */ 145
-#define KEY_PLAYPAUSE /* Media play/pause toggle */ 154
-#define KEY_PREVIOUSSONG /* Media previous */ 136
-#define KEY_STOPCD /* Media stop */ 156
-
-/* These are for "notused" and "unknown" entries in translation maps. */
-#define KEY_NOTUSED 0
-#define KEY_UNKNOWN 255
-
-#endif /* _WINKEYNAMES_H */
+#ifndef _WINKEYNAMES_H +#define _WINKEYNAMES_H +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL 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. + * + */ + +#define GLYPHS_PER_KEY 4 +#define NUM_KEYCODES 248 +#define MIN_KEYCODE 8 +#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1) + +#define AltMask Mod1Mask +#define NumLockMask Mod2Mask +#define AltLangMask Mod3Mask +#define KanaMask Mod4Mask +#define ScrollLockMask Mod5Mask + +#define ModifierDown(k) ((keyc->state & (k)) == (k)) + +/* + * NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three) + * sets of scancodes. Set3 can only be generated by a MF keyboard. + * Set2 sends a makecode for keypress, and the same code prefixed by a + * F0 for keyrelease. This is a little bit ugly to handle. Thus we use + * here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes. + * Bit 7 ist set if the key is released. The code E0 switches to a + * different meaning to add the new MF cursorkeys, while not breaking old + * applications. E1 is another special prefix. Since I assume that there + * will be further versions of PC/XT scancode compatible keyboards, we + * may be in trouble one day. + * + * IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3. + * 2) Use the keyboards native set and translate it to common keysyms. + */ + +/* + * definition of the AT84/MF101/MF102 Keyboard: + * ============================================================ + * Defined Key Cap Glyphs Pressed value + * Key Name Main Also (hex) (dec) + * ---------------- ---------- ------- ------ ------ + */ + +#define KEY_Escape /* Escape 0x01 */ 1 +#define KEY_1 /* 1 ! 0x02 */ 2 +#define KEY_2 /* 2 @ 0x03 */ 3 +#define KEY_3 /* 3 # 0x04 */ 4 +#define KEY_4 /* 4 $ 0x05 */ 5 +#define KEY_5 /* 5 % 0x06 */ 6 +#define KEY_6 /* 6 ^ 0x07 */ 7 +#define KEY_7 /* 7 & 0x08 */ 8 +#define KEY_8 /* 8 * 0x09 */ 9 +#define KEY_9 /* 9 ( 0x0a */ 10 +#define KEY_0 /* 0 ) 0x0b */ 11 +#define KEY_Minus /* - (Minus) _ (Under) 0x0c */ 12 +#define KEY_Equal /* = (Equal) + 0x0d */ 13 +#define KEY_BackSpace /* Back Space 0x0e */ 14 +#define KEY_Tab /* Tab 0x0f */ 15 +#define KEY_Q /* Q 0x10 */ 16 +#define KEY_W /* W 0x11 */ 17 +#define KEY_E /* E 0x12 */ 18 +#define KEY_R /* R 0x13 */ 19 +#define KEY_T /* T 0x14 */ 20 +#define KEY_Y /* Y 0x15 */ 21 +#define KEY_U /* U 0x16 */ 22 +#define KEY_I /* I 0x17 */ 23 +#define KEY_O /* O 0x18 */ 24 +#define KEY_P /* P 0x19 */ 25 +#define KEY_LBrace /* [ { 0x1a */ 26 +#define KEY_RBrace /* ] } 0x1b */ 27 +#define KEY_Enter /* Enter 0x1c */ 28 +#define KEY_LCtrl /* Ctrl(left) 0x1d */ 29 +#define KEY_A /* A 0x1e */ 30 +#define KEY_S /* S 0x1f */ 31 +#define KEY_D /* D 0x20 */ 32 +#define KEY_F /* F 0x21 */ 33 +#define KEY_G /* G 0x22 */ 34 +#define KEY_H /* H 0x23 */ 35 +#define KEY_J /* J 0x24 */ 36 +#define KEY_K /* K 0x25 */ 37 +#define KEY_L /* L 0x26 */ 38 +#define KEY_SemiColon /* ;(SemiColon) :(Colon) 0x27 */ 39 +#define KEY_Quote /* ' (Apostr) " (Quote) 0x28 */ 40 +#define KEY_Tilde /* ` (Accent) ~ (Tilde) 0x29 */ 41 +#define KEY_ShiftL /* Shift(left) 0x2a */ 42 +#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 43 +#define KEY_Z /* Z 0x2c */ 44 +#define KEY_X /* X 0x2d */ 45 +#define KEY_C /* C 0x2e */ 46 +#define KEY_V /* V 0x2f */ 47 +#define KEY_B /* B 0x30 */ 48 +#define KEY_N /* N 0x31 */ 49 +#define KEY_M /* M 0x32 */ 50 +#define KEY_Comma /* , (Comma) < (Less) 0x33 */ 51 +#define KEY_Period /* . (Period) >(Greater)0x34 */ 52 +#define KEY_Slash /* / (Slash) ? 0x35 */ 53 +#define KEY_ShiftR /* Shift(right) 0x36 */ 54 +#define KEY_KP_Multiply /* * 0x37 */ 55 +#define KEY_Alt /* Alt(left) 0x38 */ 56 +#define KEY_Space /* (SpaceBar) 0x39 */ 57 +#define KEY_CapsLock /* CapsLock 0x3a */ 58 +#define KEY_F1 /* F1 0x3b */ 59 +#define KEY_F2 /* F2 0x3c */ 60 +#define KEY_F3 /* F3 0x3d */ 61 +#define KEY_F4 /* F4 0x3e */ 62 +#define KEY_F5 /* F5 0x3f */ 63 +#define KEY_F6 /* F6 0x40 */ 64 +#define KEY_F7 /* F7 0x41 */ 65 +#define KEY_F8 /* F8 0x42 */ 66 +#define KEY_F9 /* F9 0x43 */ 67 +#define KEY_F10 /* F10 0x44 */ 68 +#define KEY_NumLock /* NumLock 0x45 */ 69 +#define KEY_ScrollLock /* ScrollLock 0x46 */ 70 +#define KEY_KP_7 /* 7 Home 0x47 */ 71 +#define KEY_KP_8 /* 8 Up 0x48 */ 72 +#define KEY_KP_9 /* 9 PgUp 0x49 */ 73 +#define KEY_KP_Minus /* - (Minus) 0x4a */ 74 +#define KEY_KP_4 /* 4 Left 0x4b */ 75 +#define KEY_KP_5 /* 5 0x4c */ 76 +#define KEY_KP_6 /* 6 Right 0x4d */ 77 +#define KEY_KP_Plus /* + (Plus) 0x4e */ 78 +#define KEY_KP_1 /* 1 End 0x4f */ 79 +#define KEY_KP_2 /* 2 Down 0x50 */ 80 +#define KEY_KP_3 /* 3 PgDown 0x51 */ 81 +#define KEY_KP_0 /* 0 Insert 0x52 */ 82 +#define KEY_KP_Decimal /* . (Decimal) Delete 0x53 */ 83 +#define KEY_SysReqest /* SysReqest 0x54 */ 84 +#define KEY_Fn /* Fn 0x55 */ 85 +#define KEY_Less /* < (Less) >(Greater) 0x56 */ 86 +#define KEY_F11 /* F11 0x57 */ 87 +#define KEY_F12 /* F12 0x58 */ 88 + +#define KEY_Prefix0 /* special 0x60 */ 96 +#define KEY_Prefix1 /* specail 0x61 */ 97 + +/* + * The 'scancodes' below are generated by the server, because the MF101/102 + * keyboard sends them as sequence of other scancodes + */ +#define KEY_Home /* Home 0x59 */ 89 +#define KEY_Up /* Up 0x5a */ 90 +#define KEY_PgUp /* PgUp 0x5b */ 91 +#define KEY_Left /* Left 0x5c */ 92 +#define KEY_Begin /* Begin 0x5d */ 93 +#define KEY_Right /* Right 0x5e */ 94 +#define KEY_End /* End 0x5f */ 95 +#define KEY_Down /* Down 0x60 */ 96 +#define KEY_PgDown /* PgDown 0x61 */ 97 +#define KEY_Insert /* Insert 0x62 */ 98 +#define KEY_Delete /* Delete 0x63 */ 99 +#define KEY_KP_Enter /* Enter 0x64 */ 100 +#define KEY_RCtrl /* Ctrl(right) 0x65 */ 101 +#define KEY_Pause /* Pause 0x66 */ 102 +#define KEY_Print /* Print 0x67 */ 103 +#define KEY_KP_Divide /* Divide 0x68 */ 104 +#define KEY_AltLang /* AtlLang(right) 0x69 */ 105 +#define KEY_Break /* Break 0x6a */ 106 +#define KEY_LMeta /* Left Meta 0x6b */ 107 +#define KEY_RMeta /* Right Meta 0x6c */ 108 +#define KEY_Menu /* Menu 0x6d */ 109 +#define KEY_F13 /* F13 0x6e */ 110 +#define KEY_F14 /* F14 0x6f */ 111 +#define KEY_F15 /* F15 0x70 */ 112 +#define KEY_F16 /* F16 0x71 */ 113 +#define KEY_F17 /* F17 0x72 */ 114 +#define KEY_KP_DEC /* KP_DEC 0x73 */ 115 +#define KEY_KP_Equal /* Equal (Keypad) 0x76 */ 118 +#define KEY_XFER /* Kanji Transfer 0x79 */ 121 +#define KEY_NFER /* No Kanji Transfer 0x7b */ 123 +#define KEY_Yen /* Yen 0x7d */ 125 +#define KEY_HKTG /* Hirugana/Katakana tog 0xc8 */ 200 +#define KEY_BSlash2 /* \ _ 0xcb */ 203 + +#define KEY_Mute /* Audio Mute */ 152 +#define KEY_AudioLower /* Audio Lower */ 168 +#define KEY_AudioRaise /* Audio Raise */ 166 + +#define KEY_NEXTSONG /* Media next */ 145 +#define KEY_PLAYPAUSE /* Media play/pause toggle */ 154 +#define KEY_PREVIOUSSONG /* Media previous */ 136 +#define KEY_STOPCD /* Media stop */ 156 + +/* These are for "notused" and "unknown" entries in translation maps. */ +#define KEY_NOTUSED 0 +#define KEY_UNKNOWN 255 + +#endif /* _WINKEYNAMES_H */ diff --git a/xorg-server/hw/xwin/winmouse.c b/xorg-server/hw/xwin/winmouse.c index 9debead0d..e7cb1ccb7 100644 --- a/xorg-server/hw/xwin/winmouse.c +++ b/xorg-server/hw/xwin/winmouse.c @@ -348,17 +348,12 @@ winMouseButtonsHandle (ScreenPtr pScreen, /** * Enqueue a motion event. * - * XXX: miPointerMove does exactly this, but is static :-( (and uses a static buffer) - * */ void winEnqueueMotion(int x, int y) { int valuators[2]; ValuatorMask mask; - double dbl_x=(double)x; - double dbl_y=(double)y; - miPointerSetPosition(g_pwinPointer, Absolute, &dbl_x, &dbl_y); valuators[0] = x; valuators[1] = y; diff --git a/xorg-server/hw/xwin/winmultiwindowwndproc.c b/xorg-server/hw/xwin/winmultiwindowwndproc.c index 3ba110956..b5c7786b0 100644 --- a/xorg-server/hw/xwin/winmultiwindowwndproc.c +++ b/xorg-server/hw/xwin/winmultiwindowwndproc.c @@ -705,10 +705,11 @@ winTopLevelWindowProc (HWND hwnd, UINT message, /* Remove our keyboard hook if it is installed */ winRemoveKeyboardHookLL (); - /* Revert the X focus as well, but only if the Windows focus is going to another window */ - if (!wParam) - if (pWin) - DeleteWindowFromAnyEvents(pWin, FALSE); + + /* Revert the X focus as well, but only if the Windows focus is going to another window */ + if (!wParam && pWin) + DeleteWindowFromAnyEvents(pWin, FALSE); + return 0; case WM_SYSDEADCHAR: @@ -891,21 +892,21 @@ winTopLevelWindowProc (HWND hwnd, UINT message, winUpdateWindowPosition (hwnd, FALSE, &zstyle); - { - WinXWMHints hints; - if (winMultiWindowGetWMHints(pWin, &hints)) - { - /* - Give the window focus, unless it has an InputHint - which is FALSE (this is used by e.g. glean to - avoid every test window grabbing the focus) - */ - if (!((hints.flags & InputHint) && (!hints.input))) - { - SetForegroundWindow (hwnd); - } - } - } + { + WinXWMHints hints; + if (winMultiWindowGetWMHints(pWin, &hints)) + { + /* + Give the window focus, unless it has an InputHint + which is FALSE (this is used by e.g. glean to + avoid every test window grabbing the focus) + */ + if (!((hints.flags & InputHint) && (!hints.input))) + { + SetForegroundWindow (hwnd); + } + } + } } wmMsg.msg = WM_WM_MAP3; } diff --git a/xorg-server/hw/xwin/winprefs.c b/xorg-server/hw/xwin/winprefs.c index 440cdd2e7..b003f455d 100644 --- a/xorg-server/hw/xwin/winprefs.c +++ b/xorg-server/hw/xwin/winprefs.c @@ -53,8 +53,8 @@ extern const char *winGetBaseDir(void); extern const char *g_pszLogFile; -/* From winmultiwindowflex.l, the real parser */ -extern void parse_file (FILE *fp); +/* From winprefslex.l, the real parser */ +extern int parse_file (FILE *fp); /* Currently in use command ID, incremented each new menu item created */ @@ -712,6 +712,54 @@ winIconIsOverride(unsigned hiconIn) /* + * Open and parse the XWinrc config file @path. + * If @path is NULL, use the built-in default. + */ +static int +winPrefsLoadPreferences (char *path) +{ + FILE *prefFile = NULL; + + if (path) + prefFile = fopen (path, "r"); + else + { + char defaultPrefs[] = + "MENU rmenu {\n" + " \"How to customize this menu\" EXEC \"xterm +tb -e man XWinrc\"\n" + " \"Launch xterm\" EXEC xterm\n" + " \"Load .XWinrc\" RELOAD\n" + " SEPARATOR\n" + "}\n" + "\n" + "ROOTMENU rmenu\n"; + + path = "built-in default"; + prefFile = fmemopen(defaultPrefs, strlen(defaultPrefs), "r"); + } + + if (!prefFile) + { + ErrorF ("LoadPreferences: %s not found\n", path); + return FALSE; + } + + ErrorF ("LoadPreferences: Loading %s\n", path); + + if((parse_file (prefFile)) != 0) + { + ErrorF ("LoadPreferences: %s is badly formed!\n", path); + fclose (prefFile); + return FALSE; + } + + fclose (prefFile); + return TRUE; +} + + + +/* * Try and open ~/.XWinrc and system.XWinrc * Load it into prefs structure for use by other functions */ @@ -720,16 +768,15 @@ LoadPreferences (void) { char *home; char fname[PATH_MAX+NAME_MAX+2]; - FILE *prefFile; char szDisplay[512]; char *szEnvDisplay; int i, j; char param[PARAM_MAX+1]; char *srcParam, *dstParam; + int parsed = FALSE; /* First, clear all preference settings */ memset (&pref, 0, sizeof(pref)); - prefFile = NULL; /* Now try and find a ~/.xwinrc file */ home = getenv ("HOME"); @@ -739,16 +786,11 @@ LoadPreferences (void) if (fname[strlen(fname)-1]!='/') strcat (fname, "/"); strcat (fname, ".XWinrc"); - - prefFile = fopen (fname, "r"); - if (prefFile) - { - winDebug ("winPrefsLoadPreferences: %s\n", fname); - } + parsed = winPrefsLoadPreferences(fname); } /* No home file found, check system default */ - if (!prefFile) + if (!parsed) { char buffer[MAX_PATH]; #ifdef RELOCATE_PROJECTROOT @@ -757,18 +799,14 @@ LoadPreferences (void) strncpy(buffer, SYSCONFDIR"/X11/system.XWinrc", sizeof(buffer)); #endif buffer[sizeof(buffer)-1] = 0; - prefFile = fopen (buffer, "r"); - if (prefFile) - { - winDebug ("winPrefsLoadPreferences: %s\n", buffer); - } + parsed = winPrefsLoadPreferences(buffer); } - /* If we could open it, then read the settings and close it */ - if (prefFile) + /* Neither user nor system configuration found, or were badly formed */ + if (!parsed) { - parse_file (prefFile); - fclose (prefFile); + ErrorF ("LoadPreferences: See \"man XWinrc\" to customize the XWin menu.\n"); + parsed = winPrefsLoadPreferences(NULL); } /* Setup a DISPLAY environment variable, need to allocate on heap */ diff --git a/xorg-server/hw/xwin/winprefslex.l b/xorg-server/hw/xwin/winprefslex.l index 5a443407f..83204b61c 100644 --- a/xorg-server/hw/xwin/winprefslex.l +++ b/xorg-server/hw/xwin/winprefslex.l @@ -111,14 +111,18 @@ yywrap (void) /* * Run a file through the yacc parser */ -void +int parse_file (FILE *file) { + int ret; + if (!file) - return; + return 1; yylineno = 1; yyin = file; - yyparse (); + ret = yyparse (); + yylex_destroy (); + return ret; } diff --git a/xorg-server/hw/xwin/winprocarg.c b/xorg-server/hw/xwin/winprocarg.c index 3db9a1c3e..c83e1873c 100644 --- a/xorg-server/hw/xwin/winprocarg.c +++ b/xorg-server/hw/xwin/winprocarg.c @@ -1261,7 +1261,7 @@ winLogCommandLine (int argc, char *argv[]) /* - * winLogVersionInfo - Log Cygwin/X version information + * winLogVersionInfo - Log version information */ void diff --git a/xorg-server/hw/xwin/winwindow.h b/xorg-server/hw/xwin/winwindow.h index 8dd76caa9..e33319867 100644 --- a/xorg-server/hw/xwin/winwindow.h +++ b/xorg-server/hw/xwin/winwindow.h @@ -124,13 +124,13 @@ typedef struct _winWMMessageRec{ #define MwmHintsDecorations (1L << 1) -#define MwmDecorAll (1l << 0) -#define MwmDecorBorder (1l << 1) -#define MwmDecorHandle (1l << 2) -#define MwmDecorTitle (1l << 3) -#define MwmDecorMenu (1l << 4) -#define MwmDecorMinimize (1l << 5) -#define MwmDecorMaximize (1l << 6) +#define MwmDecorAll (1L << 0) +#define MwmDecorBorder (1L << 1) +#define MwmDecorHandle (1L << 2) +#define MwmDecorTitle (1L << 3) +#define MwmDecorMenu (1L << 4) +#define MwmDecorMinimize (1L << 5) +#define MwmDecorMaximize (1L << 6) /* This structure only contains 3 elements... the Motif 2.0 structure contains 5... we only need the first 3... so that is all we will define */ diff --git a/xorg-server/hw/xwin/winwndproc.c b/xorg-server/hw/xwin/winwndproc.c index d4e3c4529..41ce51cec 100644 --- a/xorg-server/hw/xwin/winwndproc.c +++ b/xorg-server/hw/xwin/winwndproc.c @@ -1065,7 +1065,7 @@ winWindowProc (HWND hwnd, UINT message, /* Discard fake Ctrl_L events that precede AltGR on non-US keyboards */ if (winIsFakeCtrl_L (message, wParam, lParam)) - return 0; + return 0; /* * Discard presses generated from Windows auto-repeat |