From 17bae6bffd517fd2a148099daea9bf77ff3be1c1 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 10 Oct 2011 17:47:50 +0200 Subject: Imported nx-X11-3.4.0-4.tar.gz Summary: Imported nx-X11-3.4.0-4.tar.gz Keywords: Imported nx-X11-3.4.0-4.tar.gz into Git repository --- nx-X11/CHANGELOG | 4 + nx-X11/CHANGELOG.NX.original | 4 + .../src/mesa/drivers/dri/common/glcontextmodes.c | 1 + .../dri/common/glcontextmodes.c.NX.original | 497 ++++++++++++++++ .../drivers/dri/common/glcontextmodes.c.X.original | 496 ++++++++++++++++ nx-X11/lib/SM/sm_client.c | 4 +- nx-X11/lib/SM/sm_client.c.NX.original | 633 +++++++++++++++++++++ nx-X11/lib/SM/sm_client.c.SM.original | 631 ++++++++++++++++++++ nx-X11/programs/Xserver/GL/glx/render2.c | 2 +- .../programs/Xserver/GL/glx/render2.c.NX.original | 271 +++++++++ .../programs/Xserver/GL/glx/render2.c.X.original | 271 +++++++++ nx-X11/programs/Xserver/GL/glx/render2swap.c | 2 +- .../Xserver/GL/glx/render2swap.c.NX.original | 393 +++++++++++++ .../Xserver/GL/glx/render2swap.c.X.original | 393 +++++++++++++ 14 files changed, 3599 insertions(+), 3 deletions(-) create mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c.NX.original create mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c.X.original create mode 100644 nx-X11/lib/SM/sm_client.c.NX.original create mode 100644 nx-X11/lib/SM/sm_client.c.SM.original create mode 100644 nx-X11/programs/Xserver/GL/glx/render2.c.NX.original create mode 100644 nx-X11/programs/Xserver/GL/glx/render2.c.X.original create mode 100644 nx-X11/programs/Xserver/GL/glx/render2swap.c.NX.original create mode 100644 nx-X11/programs/Xserver/GL/glx/render2swap.c.X.original diff --git a/nx-X11/CHANGELOG b/nx-X11/CHANGELOG index e433f2ca0..4faf2ad79 100644 --- a/nx-X11/CHANGELOG +++ b/nx-X11/CHANGELOG @@ -1,5 +1,9 @@ ChangeLog: +nx-X11-3.4.0-4 + +- Fixed TR06H02359. Removed compiler warnings. + nx-X11-3.4.0-3 - Updated copyright to year 2010. diff --git a/nx-X11/CHANGELOG.NX.original b/nx-X11/CHANGELOG.NX.original index e433f2ca0..4faf2ad79 100644 --- a/nx-X11/CHANGELOG.NX.original +++ b/nx-X11/CHANGELOG.NX.original @@ -1,5 +1,9 @@ ChangeLog: +nx-X11-3.4.0-4 + +- Fixed TR06H02359. Removed compiler warnings. + nx-X11-3.4.0-3 - Updated copyright to year 2010. diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c index 5e9e352f2..066c5ffba 100644 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c +++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c @@ -44,6 +44,7 @@ # include "GL/glxint.h" # ifdef XFree86Server +void *memset( void * ptr, int val, size_t size); # include "GL/glx_ansic.h" extern void * __glXMalloc( size_t size ); extern void __glXFree( void * ptr ); diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c.NX.original b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c.NX.original new file mode 100644 index 000000000..066c5ffba --- /dev/null +++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c.NX.original @@ -0,0 +1,497 @@ +/* + * (C) Copyright IBM Corporation 2003 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file glcontextmodes.c + * Utility routines for working with \c __GLcontextModes structures. At + * some point most or all of these functions will be moved to the Mesa + * code base. + * + * \author Ian Romanick + */ + +#if defined(IN_MINI_GLX) +# include +# include +# include +# include "GL/internal/dri_interface.h" +# include "imports.h" +# define __glXMemset memset +#else +# include +# include +# include "GL/glxint.h" + +# ifdef XFree86Server +void *memset( void * ptr, int val, size_t size); +# include "GL/glx_ansic.h" +extern void * __glXMalloc( size_t size ); +extern void __glXFree( void * ptr ); +# define _mesa_malloc(b) __glXMalloc(b) +# define _mesa_free(m) __glXFree(m) +# else +# include +# define __glXMemset memset +# define _mesa_malloc(b) Xmalloc(b) +# define _mesa_free(m) Xfree(m) +# endif /* XFree86Server */ +#endif /* !defined(IN_MINI_GLX) */ + +#include "glcontextmodes.h" + +#if !defined(IN_MINI_GLX) +#define NUM_VISUAL_TYPES 6 + +/** + * Convert an X visual type to a GLX visual type. + * + * \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.) + * to be converted. + * \return If \c visualType is a valid X visual type, a GLX visual type will + * be returned. Otherwise \c GLX_NONE will be returned. + */ +GLint +_gl_convert_from_x_visual_type( int visualType ) +{ + static const int glx_visual_types[ NUM_VISUAL_TYPES ] = { + GLX_STATIC_GRAY, GLX_GRAY_SCALE, + GLX_STATIC_COLOR, GLX_PSEUDO_COLOR, + GLX_TRUE_COLOR, GLX_DIRECT_COLOR + }; + + return ( (unsigned) visualType < NUM_VISUAL_TYPES ) + ? glx_visual_types[ visualType ] : GLX_NONE; +} + + +/** + * Convert a GLX visual type to an X visual type. + * + * \param visualType GLX visual type (i.e., \c GLX_TRUE_COLOR, + * \c GLX_STATIC_GRAY, etc.) to be converted. + * \return If \c visualType is a valid GLX visual type, an X visual type will + * be returned. Otherwise -1 will be returned. + */ +GLint +_gl_convert_to_x_visual_type( int visualType ) +{ + static const int x_visual_types[ NUM_VISUAL_TYPES ] = { + TrueColor, DirectColor, + PseudoColor, StaticColor, + GrayScale, StaticGray + }; + + return ( (unsigned) (visualType - GLX_TRUE_COLOR) <= NUM_VISUAL_TYPES ) + ? x_visual_types[ visualType - GLX_TRUE_COLOR ] : -1; +} + + +/** + * Copy a GLX visual config structure to a GL context mode structure. All + * of the fields in \c config are copied to \c mode. Additional fields in + * \c mode that can be derrived from the fields of \c config (i.e., + * \c haveDepthBuffer) are also filled in. The remaining fields in \c mode + * that cannot be derrived are set to default values. + * + * \param mode Destination GL context mode. + * \param config Source GLX visual config. + * + * \note + * The \c fbconfigID and \c visualID fields of the \c __GLcontextModes + * structure will be set to the \c vid of the \c __GLXvisualConfig structure. + */ +void +_gl_copy_visual_to_context_mode( __GLcontextModes * mode, + const __GLXvisualConfig * config ) +{ + __GLcontextModes * const next = mode->next; + + (void) __glXMemset( mode, 0, sizeof( __GLcontextModes ) ); + mode->next = next; + + mode->visualID = config->vid; + mode->visualType = _gl_convert_from_x_visual_type( config->class ); + mode->xRenderable = GL_TRUE; + mode->fbconfigID = config->vid; + mode->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT; + + mode->rgbMode = (config->rgba != 0); + mode->renderType = (mode->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; + + mode->colorIndexMode = !(mode->rgbMode); + mode->doubleBufferMode = (config->doubleBuffer != 0); + mode->stereoMode = (config->stereo != 0); + + mode->haveAccumBuffer = ((config->accumRedSize + + config->accumGreenSize + + config->accumBlueSize + + config->accumAlphaSize) > 0); + mode->haveDepthBuffer = (config->depthSize > 0); + mode->haveStencilBuffer = (config->stencilSize > 0); + + mode->redBits = config->redSize; + mode->greenBits = config->greenSize; + mode->blueBits = config->blueSize; + mode->alphaBits = config->alphaSize; + mode->redMask = config->redMask; + mode->greenMask = config->greenMask; + mode->blueMask = config->blueMask; + mode->alphaMask = config->alphaMask; + mode->rgbBits = mode->rgbMode ? config->bufferSize : 0; + mode->indexBits = mode->colorIndexMode ? config->bufferSize : 0; + + mode->accumRedBits = config->accumRedSize; + mode->accumGreenBits = config->accumGreenSize; + mode->accumBlueBits = config->accumBlueSize; + mode->accumAlphaBits = config->accumAlphaSize; + mode->depthBits = config->depthSize; + mode->stencilBits = config->stencilSize; + + mode->numAuxBuffers = config->auxBuffers; + mode->level = config->level; + + mode->visualRating = config->visualRating; + mode->transparentPixel = config->transparentPixel; + mode->transparentRed = config->transparentRed; + mode->transparentGreen = config->transparentGreen; + mode->transparentBlue = config->transparentBlue; + mode->transparentAlpha = config->transparentAlpha; + mode->transparentIndex = config->transparentIndex; + + mode->swapMethod = GLX_SWAP_UNDEFINED_OML; +} + + +/** + * Get data from a GL context mode. + * + * \param mode GL context mode whose data is to be returned. + * \param attribute Attribute of \c mode that is to be returned. + * \param value_return Location to store the data member of \c mode. + * \return If \c attribute is a valid attribute of \c mode, zero is + * returned. Otherwise \c GLX_BAD_ATTRIBUTE is returned. + */ +int +_gl_get_context_mode_data(const __GLcontextModes *mode, int attribute, + int *value_return) +{ + switch (attribute) { + case GLX_USE_GL: + *value_return = GL_TRUE; + return 0; + case GLX_BUFFER_SIZE: + *value_return = mode->rgbBits; + return 0; + case GLX_RGBA: + *value_return = mode->rgbMode; + return 0; + case GLX_RED_SIZE: + *value_return = mode->redBits; + return 0; + case GLX_GREEN_SIZE: + *value_return = mode->greenBits; + return 0; + case GLX_BLUE_SIZE: + *value_return = mode->blueBits; + return 0; + case GLX_ALPHA_SIZE: + *value_return = mode->alphaBits; + return 0; + case GLX_DOUBLEBUFFER: + *value_return = mode->doubleBufferMode; + return 0; + case GLX_STEREO: + *value_return = mode->stereoMode; + return 0; + case GLX_AUX_BUFFERS: + *value_return = mode->numAuxBuffers; + return 0; + case GLX_DEPTH_SIZE: + *value_return = mode->depthBits; + return 0; + case GLX_STENCIL_SIZE: + *value_return = mode->stencilBits; + return 0; + case GLX_ACCUM_RED_SIZE: + *value_return = mode->accumRedBits; + return 0; + case GLX_ACCUM_GREEN_SIZE: + *value_return = mode->accumGreenBits; + return 0; + case GLX_ACCUM_BLUE_SIZE: + *value_return = mode->accumBlueBits; + return 0; + case GLX_ACCUM_ALPHA_SIZE: + *value_return = mode->accumAlphaBits; + return 0; + case GLX_LEVEL: + *value_return = mode->level; + return 0; + case GLX_TRANSPARENT_TYPE_EXT: + *value_return = mode->transparentPixel; + return 0; + case GLX_TRANSPARENT_RED_VALUE: + *value_return = mode->transparentRed; + return 0; + case GLX_TRANSPARENT_GREEN_VALUE: + *value_return = mode->transparentGreen; + return 0; + case GLX_TRANSPARENT_BLUE_VALUE: + *value_return = mode->transparentBlue; + return 0; + case GLX_TRANSPARENT_ALPHA_VALUE: + *value_return = mode->transparentAlpha; + return 0; + case GLX_TRANSPARENT_INDEX_VALUE: + *value_return = mode->transparentIndex; + return 0; + case GLX_X_VISUAL_TYPE: + *value_return = mode->visualType; + return 0; + case GLX_CONFIG_CAVEAT: + *value_return = mode->visualRating; + return 0; + case GLX_VISUAL_ID: + *value_return = mode->visualID; + return 0; + case GLX_DRAWABLE_TYPE: + *value_return = mode->drawableType; + return 0; + case GLX_RENDER_TYPE: + *value_return = mode->renderType; + return 0; + case GLX_X_RENDERABLE: + *value_return = mode->xRenderable; + return 0; + case GLX_FBCONFIG_ID: + *value_return = mode->fbconfigID; + return 0; + case GLX_MAX_PBUFFER_WIDTH: + *value_return = mode->maxPbufferWidth; + return 0; + case GLX_MAX_PBUFFER_HEIGHT: + *value_return = mode->maxPbufferHeight; + return 0; + case GLX_MAX_PBUFFER_PIXELS: + *value_return = mode->maxPbufferPixels; + return 0; + case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX: + *value_return = mode->optimalPbufferWidth; + return 0; + case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX: + *value_return = mode->optimalPbufferHeight; + return 0; + case GLX_SWAP_METHOD_OML: + *value_return = mode->swapMethod; + return 0; + case GLX_SAMPLE_BUFFERS_SGIS: + *value_return = mode->sampleBuffers; + return 0; + case GLX_SAMPLES_SGIS: + *value_return = mode->samples; + return 0; + + /* Applications are NOT allowed to query GLX_VISUAL_SELECT_GROUP_SGIX. + * It is ONLY for communication between the GLX client and the GLX + * server. + */ + case GLX_VISUAL_SELECT_GROUP_SGIX: + default: + return GLX_BAD_ATTRIBUTE; + } +} +#endif /* !defined(IN_MINI_GLX) */ + + +/** + * Allocate a linked list of \c __GLcontextModes structures. The fields of + * each structure will be initialized to "reasonable" default values. In + * most cases this is the default value defined by table 3.4 of the GLX + * 1.3 specification. This means that most values are either initialized to + * zero or \c GLX_DONT_CARE (which is -1). As support for additional + * extensions is added, the new values will be initialized to appropriate + * values from the extension specification. + * + * \param count Number of structures to allocate. + * \param minimum_size Minimum size of a structure to allocate. This allows + * for differences in the version of the + * \c __GLcontextModes stucture used in libGL and in a + * DRI-based driver. + * \returns A pointer to the first element in a linked list of \c count + * stuctures on success, or \c NULL on failure. + * + * \warning Use of \c minimum_size does \b not guarantee binary compatibility. + * The fundamental assumption is that if the \c minimum_size + * specified by the driver and the size of the \c __GLcontextModes + * structure in libGL is the same, then the meaning of each byte in + * the structure is the same in both places. \b Be \b careful! + * Basically this means that fields have to be added in libGL and + * then propagated to drivers. Drivers should \b never arbitrarilly + * extend the \c __GLcontextModes data-structure. + */ +__GLcontextModes * +_gl_context_modes_create( unsigned count, size_t minimum_size ) +{ + const size_t size = (minimum_size > sizeof( __GLcontextModes )) + ? minimum_size : sizeof( __GLcontextModes ); + __GLcontextModes * base = NULL; + __GLcontextModes ** next; + unsigned i; + + next = & base; + for ( i = 0 ; i < count ; i++ ) { + *next = (__GLcontextModes *) _mesa_malloc( size ); + if ( *next == NULL ) { + _gl_context_modes_destroy( base ); + base = NULL; + break; + } + + (void) __glXMemset( *next, 0, size ); + (*next)->visualID = GLX_DONT_CARE; + (*next)->visualType = GLX_DONT_CARE; + (*next)->visualRating = GLX_NONE; + (*next)->transparentPixel = GLX_NONE; + (*next)->transparentRed = GLX_DONT_CARE; + (*next)->transparentGreen = GLX_DONT_CARE; + (*next)->transparentBlue = GLX_DONT_CARE; + (*next)->transparentAlpha = GLX_DONT_CARE; + (*next)->transparentIndex = GLX_DONT_CARE; + (*next)->xRenderable = GLX_DONT_CARE; + (*next)->fbconfigID = GLX_DONT_CARE; + (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML; + + next = & ((*next)->next); + } + + return base; +} + + +/** + * Destroy a linked list of \c __GLcontextModes structures created by + * \c _gl_context_modes_create. + * + * \param modes Linked list of structures to be destroyed. All structres + * in the list will be freed. + */ +void +_gl_context_modes_destroy( __GLcontextModes * modes ) +{ + while ( modes != NULL ) { + __GLcontextModes * const next = modes->next; + + _mesa_free( modes ); + modes = next; + } +} + + +/** + * Find a context mode matching a Visual ID. + * + * \param modes List list of context-mode structures to be searched. + * \param vid Visual ID to be found. + * \returns A pointer to a context-mode in \c modes if \c vid was found in + * the list, or \c NULL if it was not. + */ + +__GLcontextModes * +_gl_context_modes_find_visual( __GLcontextModes * modes, int vid ) +{ + while ( modes != NULL ) { + if ( modes->visualID == vid ) { + break; + } + + modes = modes->next; + } + + return modes; +} + + +/** + * Determine if two context-modes are the same. This is intended to be used + * by libGL implementations to compare to sets of driver generated FBconfigs. + * + * \param a Context-mode to be compared. + * \param b Context-mode to be compared. + * \returns \c GL_TRUE if the two context-modes are the same. \c GL_FALSE is + * returned otherwise. + */ +GLboolean +_gl_context_modes_are_same( const __GLcontextModes * a, + const __GLcontextModes * b ) +{ + return( (a->rgbMode == b->rgbMode) && + (a->floatMode == b->floatMode) && + (a->colorIndexMode == b->colorIndexMode) && + (a->doubleBufferMode == b->doubleBufferMode) && + (a->stereoMode == b->stereoMode) && + (a->redBits == b->redBits) && + (a->greenBits == b->greenBits) && + (a->blueBits == b->blueBits) && + (a->alphaBits == b->alphaBits) && +#if 0 /* For some reason these don't get set on the client-side in libGL. */ + (a->redMask == b->redMask) && + (a->greenMask == b->greenMask) && + (a->blueMask == b->blueMask) && + (a->alphaMask == b->alphaMask) && +#endif + (a->rgbBits == b->rgbBits) && + (a->indexBits == b->indexBits) && + (a->accumRedBits == b->accumRedBits) && + (a->accumGreenBits == b->accumGreenBits) && + (a->accumBlueBits == b->accumBlueBits) && + (a->accumAlphaBits == b->accumAlphaBits) && + (a->depthBits == b->depthBits) && + (a->stencilBits == b->stencilBits) && + (a->numAuxBuffers == b->numAuxBuffers) && + (a->level == b->level) && + (a->pixmapMode == b->pixmapMode) && + (a->visualRating == b->visualRating) && + + (a->transparentPixel == b->transparentPixel) && + + ((a->transparentPixel != GLX_TRANSPARENT_RGB) || + ((a->transparentRed == b->transparentRed) && + (a->transparentGreen == b->transparentGreen) && + (a->transparentBlue == b->transparentBlue) && + (a->transparentAlpha == b->transparentAlpha))) && + + ((a->transparentPixel != GLX_TRANSPARENT_INDEX) || + (a->transparentIndex == b->transparentIndex)) && + + (a->sampleBuffers == b->sampleBuffers) && + (a->samples == b->samples) && + ((a->drawableType & b->drawableType) != 0) && + (a->renderType == b->renderType) && + (a->maxPbufferWidth == b->maxPbufferWidth) && + (a->maxPbufferHeight == b->maxPbufferHeight) && + (a->maxPbufferPixels == b->maxPbufferPixels) && + (a->optimalPbufferWidth == b->optimalPbufferWidth) && + (a->optimalPbufferHeight == b->optimalPbufferHeight) && + (a->swapMethod == b->swapMethod) ); +} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c.X.original b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c.X.original new file mode 100644 index 000000000..5e9e352f2 --- /dev/null +++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c.X.original @@ -0,0 +1,496 @@ +/* + * (C) Copyright IBM Corporation 2003 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file glcontextmodes.c + * Utility routines for working with \c __GLcontextModes structures. At + * some point most or all of these functions will be moved to the Mesa + * code base. + * + * \author Ian Romanick + */ + +#if defined(IN_MINI_GLX) +# include +# include +# include +# include "GL/internal/dri_interface.h" +# include "imports.h" +# define __glXMemset memset +#else +# include +# include +# include "GL/glxint.h" + +# ifdef XFree86Server +# include "GL/glx_ansic.h" +extern void * __glXMalloc( size_t size ); +extern void __glXFree( void * ptr ); +# define _mesa_malloc(b) __glXMalloc(b) +# define _mesa_free(m) __glXFree(m) +# else +# include +# define __glXMemset memset +# define _mesa_malloc(b) Xmalloc(b) +# define _mesa_free(m) Xfree(m) +# endif /* XFree86Server */ +#endif /* !defined(IN_MINI_GLX) */ + +#include "glcontextmodes.h" + +#if !defined(IN_MINI_GLX) +#define NUM_VISUAL_TYPES 6 + +/** + * Convert an X visual type to a GLX visual type. + * + * \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.) + * to be converted. + * \return If \c visualType is a valid X visual type, a GLX visual type will + * be returned. Otherwise \c GLX_NONE will be returned. + */ +GLint +_gl_convert_from_x_visual_type( int visualType ) +{ + static const int glx_visual_types[ NUM_VISUAL_TYPES ] = { + GLX_STATIC_GRAY, GLX_GRAY_SCALE, + GLX_STATIC_COLOR, GLX_PSEUDO_COLOR, + GLX_TRUE_COLOR, GLX_DIRECT_COLOR + }; + + return ( (unsigned) visualType < NUM_VISUAL_TYPES ) + ? glx_visual_types[ visualType ] : GLX_NONE; +} + + +/** + * Convert a GLX visual type to an X visual type. + * + * \param visualType GLX visual type (i.e., \c GLX_TRUE_COLOR, + * \c GLX_STATIC_GRAY, etc.) to be converted. + * \return If \c visualType is a valid GLX visual type, an X visual type will + * be returned. Otherwise -1 will be returned. + */ +GLint +_gl_convert_to_x_visual_type( int visualType ) +{ + static const int x_visual_types[ NUM_VISUAL_TYPES ] = { + TrueColor, DirectColor, + PseudoColor, StaticColor, + GrayScale, StaticGray + }; + + return ( (unsigned) (visualType - GLX_TRUE_COLOR) <= NUM_VISUAL_TYPES ) + ? x_visual_types[ visualType - GLX_TRUE_COLOR ] : -1; +} + + +/** + * Copy a GLX visual config structure to a GL context mode structure. All + * of the fields in \c config are copied to \c mode. Additional fields in + * \c mode that can be derrived from the fields of \c config (i.e., + * \c haveDepthBuffer) are also filled in. The remaining fields in \c mode + * that cannot be derrived are set to default values. + * + * \param mode Destination GL context mode. + * \param config Source GLX visual config. + * + * \note + * The \c fbconfigID and \c visualID fields of the \c __GLcontextModes + * structure will be set to the \c vid of the \c __GLXvisualConfig structure. + */ +void +_gl_copy_visual_to_context_mode( __GLcontextModes * mode, + const __GLXvisualConfig * config ) +{ + __GLcontextModes * const next = mode->next; + + (void) __glXMemset( mode, 0, sizeof( __GLcontextModes ) ); + mode->next = next; + + mode->visualID = config->vid; + mode->visualType = _gl_convert_from_x_visual_type( config->class ); + mode->xRenderable = GL_TRUE; + mode->fbconfigID = config->vid; + mode->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT; + + mode->rgbMode = (config->rgba != 0); + mode->renderType = (mode->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; + + mode->colorIndexMode = !(mode->rgbMode); + mode->doubleBufferMode = (config->doubleBuffer != 0); + mode->stereoMode = (config->stereo != 0); + + mode->haveAccumBuffer = ((config->accumRedSize + + config->accumGreenSize + + config->accumBlueSize + + config->accumAlphaSize) > 0); + mode->haveDepthBuffer = (config->depthSize > 0); + mode->haveStencilBuffer = (config->stencilSize > 0); + + mode->redBits = config->redSize; + mode->greenBits = config->greenSize; + mode->blueBits = config->blueSize; + mode->alphaBits = config->alphaSize; + mode->redMask = config->redMask; + mode->greenMask = config->greenMask; + mode->blueMask = config->blueMask; + mode->alphaMask = config->alphaMask; + mode->rgbBits = mode->rgbMode ? config->bufferSize : 0; + mode->indexBits = mode->colorIndexMode ? config->bufferSize : 0; + + mode->accumRedBits = config->accumRedSize; + mode->accumGreenBits = config->accumGreenSize; + mode->accumBlueBits = config->accumBlueSize; + mode->accumAlphaBits = config->accumAlphaSize; + mode->depthBits = config->depthSize; + mode->stencilBits = config->stencilSize; + + mode->numAuxBuffers = config->auxBuffers; + mode->level = config->level; + + mode->visualRating = config->visualRating; + mode->transparentPixel = config->transparentPixel; + mode->transparentRed = config->transparentRed; + mode->transparentGreen = config->transparentGreen; + mode->transparentBlue = config->transparentBlue; + mode->transparentAlpha = config->transparentAlpha; + mode->transparentIndex = config->transparentIndex; + + mode->swapMethod = GLX_SWAP_UNDEFINED_OML; +} + + +/** + * Get data from a GL context mode. + * + * \param mode GL context mode whose data is to be returned. + * \param attribute Attribute of \c mode that is to be returned. + * \param value_return Location to store the data member of \c mode. + * \return If \c attribute is a valid attribute of \c mode, zero is + * returned. Otherwise \c GLX_BAD_ATTRIBUTE is returned. + */ +int +_gl_get_context_mode_data(const __GLcontextModes *mode, int attribute, + int *value_return) +{ + switch (attribute) { + case GLX_USE_GL: + *value_return = GL_TRUE; + return 0; + case GLX_BUFFER_SIZE: + *value_return = mode->rgbBits; + return 0; + case GLX_RGBA: + *value_return = mode->rgbMode; + return 0; + case GLX_RED_SIZE: + *value_return = mode->redBits; + return 0; + case GLX_GREEN_SIZE: + *value_return = mode->greenBits; + return 0; + case GLX_BLUE_SIZE: + *value_return = mode->blueBits; + return 0; + case GLX_ALPHA_SIZE: + *value_return = mode->alphaBits; + return 0; + case GLX_DOUBLEBUFFER: + *value_return = mode->doubleBufferMode; + return 0; + case GLX_STEREO: + *value_return = mode->stereoMode; + return 0; + case GLX_AUX_BUFFERS: + *value_return = mode->numAuxBuffers; + return 0; + case GLX_DEPTH_SIZE: + *value_return = mode->depthBits; + return 0; + case GLX_STENCIL_SIZE: + *value_return = mode->stencilBits; + return 0; + case GLX_ACCUM_RED_SIZE: + *value_return = mode->accumRedBits; + return 0; + case GLX_ACCUM_GREEN_SIZE: + *value_return = mode->accumGreenBits; + return 0; + case GLX_ACCUM_BLUE_SIZE: + *value_return = mode->accumBlueBits; + return 0; + case GLX_ACCUM_ALPHA_SIZE: + *value_return = mode->accumAlphaBits; + return 0; + case GLX_LEVEL: + *value_return = mode->level; + return 0; + case GLX_TRANSPARENT_TYPE_EXT: + *value_return = mode->transparentPixel; + return 0; + case GLX_TRANSPARENT_RED_VALUE: + *value_return = mode->transparentRed; + return 0; + case GLX_TRANSPARENT_GREEN_VALUE: + *value_return = mode->transparentGreen; + return 0; + case GLX_TRANSPARENT_BLUE_VALUE: + *value_return = mode->transparentBlue; + return 0; + case GLX_TRANSPARENT_ALPHA_VALUE: + *value_return = mode->transparentAlpha; + return 0; + case GLX_TRANSPARENT_INDEX_VALUE: + *value_return = mode->transparentIndex; + return 0; + case GLX_X_VISUAL_TYPE: + *value_return = mode->visualType; + return 0; + case GLX_CONFIG_CAVEAT: + *value_return = mode->visualRating; + return 0; + case GLX_VISUAL_ID: + *value_return = mode->visualID; + return 0; + case GLX_DRAWABLE_TYPE: + *value_return = mode->drawableType; + return 0; + case GLX_RENDER_TYPE: + *value_return = mode->renderType; + return 0; + case GLX_X_RENDERABLE: + *value_return = mode->xRenderable; + return 0; + case GLX_FBCONFIG_ID: + *value_return = mode->fbconfigID; + return 0; + case GLX_MAX_PBUFFER_WIDTH: + *value_return = mode->maxPbufferWidth; + return 0; + case GLX_MAX_PBUFFER_HEIGHT: + *value_return = mode->maxPbufferHeight; + return 0; + case GLX_MAX_PBUFFER_PIXELS: + *value_return = mode->maxPbufferPixels; + return 0; + case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX: + *value_return = mode->optimalPbufferWidth; + return 0; + case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX: + *value_return = mode->optimalPbufferHeight; + return 0; + case GLX_SWAP_METHOD_OML: + *value_return = mode->swapMethod; + return 0; + case GLX_SAMPLE_BUFFERS_SGIS: + *value_return = mode->sampleBuffers; + return 0; + case GLX_SAMPLES_SGIS: + *value_return = mode->samples; + return 0; + + /* Applications are NOT allowed to query GLX_VISUAL_SELECT_GROUP_SGIX. + * It is ONLY for communication between the GLX client and the GLX + * server. + */ + case GLX_VISUAL_SELECT_GROUP_SGIX: + default: + return GLX_BAD_ATTRIBUTE; + } +} +#endif /* !defined(IN_MINI_GLX) */ + + +/** + * Allocate a linked list of \c __GLcontextModes structures. The fields of + * each structure will be initialized to "reasonable" default values. In + * most cases this is the default value defined by table 3.4 of the GLX + * 1.3 specification. This means that most values are either initialized to + * zero or \c GLX_DONT_CARE (which is -1). As support for additional + * extensions is added, the new values will be initialized to appropriate + * values from the extension specification. + * + * \param count Number of structures to allocate. + * \param minimum_size Minimum size of a structure to allocate. This allows + * for differences in the version of the + * \c __GLcontextModes stucture used in libGL and in a + * DRI-based driver. + * \returns A pointer to the first element in a linked list of \c count + * stuctures on success, or \c NULL on failure. + * + * \warning Use of \c minimum_size does \b not guarantee binary compatibility. + * The fundamental assumption is that if the \c minimum_size + * specified by the driver and the size of the \c __GLcontextModes + * structure in libGL is the same, then the meaning of each byte in + * the structure is the same in both places. \b Be \b careful! + * Basically this means that fields have to be added in libGL and + * then propagated to drivers. Drivers should \b never arbitrarilly + * extend the \c __GLcontextModes data-structure. + */ +__GLcontextModes * +_gl_context_modes_create( unsigned count, size_t minimum_size ) +{ + const size_t size = (minimum_size > sizeof( __GLcontextModes )) + ? minimum_size : sizeof( __GLcontextModes ); + __GLcontextModes * base = NULL; + __GLcontextModes ** next; + unsigned i; + + next = & base; + for ( i = 0 ; i < count ; i++ ) { + *next = (__GLcontextModes *) _mesa_malloc( size ); + if ( *next == NULL ) { + _gl_context_modes_destroy( base ); + base = NULL; + break; + } + + (void) __glXMemset( *next, 0, size ); + (*next)->visualID = GLX_DONT_CARE; + (*next)->visualType = GLX_DONT_CARE; + (*next)->visualRating = GLX_NONE; + (*next)->transparentPixel = GLX_NONE; + (*next)->transparentRed = GLX_DONT_CARE; + (*next)->transparentGreen = GLX_DONT_CARE; + (*next)->transparentBlue = GLX_DONT_CARE; + (*next)->transparentAlpha = GLX_DONT_CARE; + (*next)->transparentIndex = GLX_DONT_CARE; + (*next)->xRenderable = GLX_DONT_CARE; + (*next)->fbconfigID = GLX_DONT_CARE; + (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML; + + next = & ((*next)->next); + } + + return base; +} + + +/** + * Destroy a linked list of \c __GLcontextModes structures created by + * \c _gl_context_modes_create. + * + * \param modes Linked list of structures to be destroyed. All structres + * in the list will be freed. + */ +void +_gl_context_modes_destroy( __GLcontextModes * modes ) +{ + while ( modes != NULL ) { + __GLcontextModes * const next = modes->next; + + _mesa_free( modes ); + modes = next; + } +} + + +/** + * Find a context mode matching a Visual ID. + * + * \param modes List list of context-mode structures to be searched. + * \param vid Visual ID to be found. + * \returns A pointer to a context-mode in \c modes if \c vid was found in + * the list, or \c NULL if it was not. + */ + +__GLcontextModes * +_gl_context_modes_find_visual( __GLcontextModes * modes, int vid ) +{ + while ( modes != NULL ) { + if ( modes->visualID == vid ) { + break; + } + + modes = modes->next; + } + + return modes; +} + + +/** + * Determine if two context-modes are the same. This is intended to be used + * by libGL implementations to compare to sets of driver generated FBconfigs. + * + * \param a Context-mode to be compared. + * \param b Context-mode to be compared. + * \returns \c GL_TRUE if the two context-modes are the same. \c GL_FALSE is + * returned otherwise. + */ +GLboolean +_gl_context_modes_are_same( const __GLcontextModes * a, + const __GLcontextModes * b ) +{ + return( (a->rgbMode == b->rgbMode) && + (a->floatMode == b->floatMode) && + (a->colorIndexMode == b->colorIndexMode) && + (a->doubleBufferMode == b->doubleBufferMode) && + (a->stereoMode == b->stereoMode) && + (a->redBits == b->redBits) && + (a->greenBits == b->greenBits) && + (a->blueBits == b->blueBits) && + (a->alphaBits == b->alphaBits) && +#if 0 /* For some reason these don't get set on the client-side in libGL. */ + (a->redMask == b->redMask) && + (a->greenMask == b->greenMask) && + (a->blueMask == b->blueMask) && + (a->alphaMask == b->alphaMask) && +#endif + (a->rgbBits == b->rgbBits) && + (a->indexBits == b->indexBits) && + (a->accumRedBits == b->accumRedBits) && + (a->accumGreenBits == b->accumGreenBits) && + (a->accumBlueBits == b->accumBlueBits) && + (a->accumAlphaBits == b->accumAlphaBits) && + (a->depthBits == b->depthBits) && + (a->stencilBits == b->stencilBits) && + (a->numAuxBuffers == b->numAuxBuffers) && + (a->level == b->level) && + (a->pixmapMode == b->pixmapMode) && + (a->visualRating == b->visualRating) && + + (a->transparentPixel == b->transparentPixel) && + + ((a->transparentPixel != GLX_TRANSPARENT_RGB) || + ((a->transparentRed == b->transparentRed) && + (a->transparentGreen == b->transparentGreen) && + (a->transparentBlue == b->transparentBlue) && + (a->transparentAlpha == b->transparentAlpha))) && + + ((a->transparentPixel != GLX_TRANSPARENT_INDEX) || + (a->transparentIndex == b->transparentIndex)) && + + (a->sampleBuffers == b->sampleBuffers) && + (a->samples == b->samples) && + ((a->drawableType & b->drawableType) != 0) && + (a->renderType == b->renderType) && + (a->maxPbufferWidth == b->maxPbufferWidth) && + (a->maxPbufferHeight == b->maxPbufferHeight) && + (a->maxPbufferPixels == b->maxPbufferPixels) && + (a->optimalPbufferWidth == b->optimalPbufferWidth) && + (a->optimalPbufferHeight == b->optimalPbufferHeight) && + (a->swapMethod == b->swapMethod) ); +} diff --git a/nx-X11/lib/SM/sm_client.c b/nx-X11/lib/SM/sm_client.c index 02f9ccdf6..499be5e3d 100644 --- a/nx-X11/lib/SM/sm_client.c +++ b/nx-X11/lib/SM/sm_client.c @@ -239,7 +239,9 @@ char *errorStringRet; SIZEOF (smRegisterClientMsg), WORD64COUNT (extra), smRegisterClientMsg, pMsg, pData); - STORE_ARRAY8 (pData, 0, NULL); + previousId = NULL; + + STORE_ARRAY8 (pData, 0, previousId); IceFlush (iceConn); diff --git a/nx-X11/lib/SM/sm_client.c.NX.original b/nx-X11/lib/SM/sm_client.c.NX.original new file mode 100644 index 000000000..499be5e3d --- /dev/null +++ b/nx-X11/lib/SM/sm_client.c.NX.original @@ -0,0 +1,633 @@ +/* $Xorg: sm_client.c,v 1.4 2001/02/09 02:03:30 xorgcvs Exp $ */ + +/* + +Copyright 1993, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +/* + * Author: Ralph Mor, X Consortium + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "SMlibint.h" +#include "globals.h" + +static void set_callbacks(); + + +SmcConn +SmcOpenConnection (networkIdsList, context, + xsmpMajorRev, xsmpMinorRev, mask, callbacks, + previousId, clientIdRet, errorLength, errorStringRet) + +char *networkIdsList; +SmPointer context; +int xsmpMajorRev; +int xsmpMinorRev; +unsigned long mask; +SmcCallbacks *callbacks; +char *previousId; +char **clientIdRet; +int errorLength; +char *errorStringRet; + +{ + SmcConn smcConn; + IceConn iceConn; + char *ids; + IceProtocolSetupStatus setupstat; + int majorVersion; + int minorVersion; + char *vendor = NULL; + char *release = NULL; + smRegisterClientMsg *pMsg; + char *pData; + int extra, len; + IceReplyWaitInfo replyWait; + _SmcRegisterClientReply reply; + Bool gotReply, ioErrorOccured; + + *clientIdRet = NULL; + + if (errorStringRet && errorLength > 0) + *errorStringRet = '\0'; + + if (!_SmcOpcode) + { + /* + * For now, there is only one version of XSMP, so we don't + * have to check {xsmpMajorRev, xsmpMinorRev}. In the future, + * we will check against _SmcVersions and generate the list + * of versions the application actually supports. + */ + + if ((_SmcOpcode = IceRegisterForProtocolSetup ("XSMP", + SmVendorString, SmReleaseString, _SmVersionCount, _SmcVersions, + _SmAuthCount, _SmAuthNames, _SmcAuthProcs, NULL)) < 0) + { + strncpy (errorStringRet, + "Could not register XSMP protocol with ICE", errorLength); + + return (NULL); + } + } + + if (networkIdsList == NULL || *networkIdsList == '\0') + { + if ((ids = (char *) getenv ("SESSION_MANAGER")) == NULL) + { + strncpy (errorStringRet, + "SESSION_MANAGER environment variable not defined", + errorLength); + + return (NULL); + } + } + else + { + ids = networkIdsList; + } + + if ((iceConn = IceOpenConnection ( + ids, context, 0, _SmcOpcode, errorLength, errorStringRet)) == NULL) + { + return (NULL); + } + + if ((smcConn = (SmcConn) malloc (sizeof (struct _SmcConn))) == NULL) + { + strncpy (errorStringRet, "Can't malloc", errorLength); + IceCloseConnection (iceConn); + return (NULL); + } + + setupstat = IceProtocolSetup (iceConn, _SmcOpcode, + (IcePointer) smcConn, + False /* mustAuthenticate */, + &majorVersion, &minorVersion, + &vendor, &release, errorLength, errorStringRet); + + if (setupstat == IceProtocolSetupFailure || + setupstat == IceProtocolSetupIOError) + { + IceCloseConnection (iceConn); + free ((char *) smcConn); + return (NULL); + } + else if (setupstat == IceProtocolAlreadyActive) + { + /* + * This case should never happen, because when we called + * IceOpenConnection, we required that the ICE connection + * may not already have XSMP active on it. + */ + + free ((char *) smcConn); + strncpy (errorStringRet, "Internal error in IceOpenConnection", + errorLength); + return (NULL); + } + + smcConn->iceConn = iceConn; + smcConn->proto_major_version = majorVersion; + smcConn->proto_minor_version = minorVersion; + smcConn->vendor = vendor; + smcConn->release = release; + smcConn->client_id = NULL; + + bzero ((char *) &smcConn->callbacks, sizeof (SmcCallbacks)); + set_callbacks (smcConn, mask, callbacks); + + smcConn->interact_waits = NULL; + smcConn->phase2_wait = NULL; + smcConn->prop_reply_waits = NULL; + + smcConn->save_yourself_in_progress = False; + smcConn->shutdown_in_progress = False; + + + /* + * Now register the client + */ + + len = previousId ? strlen (previousId) : 0; + extra = ARRAY8_BYTES (len); + + IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient, + SIZEOF (smRegisterClientMsg), WORD64COUNT (extra), + smRegisterClientMsg, pMsg, pData); + + STORE_ARRAY8 (pData, len, previousId); + + IceFlush (iceConn); + + replyWait.sequence_of_request = IceLastSentSequenceNumber (iceConn); + replyWait.major_opcode_of_request = _SmcOpcode; + replyWait.minor_opcode_of_request = SM_RegisterClient; + replyWait.reply = (IcePointer) &reply; + + gotReply = False; + ioErrorOccured = False; + + while (!gotReply && !ioErrorOccured) + { + ioErrorOccured = (IceProcessMessages ( + iceConn, &replyWait, &gotReply) == IceProcessMessagesIOError); + + if (ioErrorOccured) + { + strncpy (errorStringRet, "IO error occured opening connection", + errorLength); + + free (smcConn->vendor); + free (smcConn->release); + free ((char *) smcConn); + + return (NULL); + } + else if (gotReply) + { + if (reply.status == 1) + { + /* + * The client successfully registered. + */ + + *clientIdRet = reply.client_id; + + smcConn->client_id = (char *) malloc ( + strlen (*clientIdRet) + 1); + + strcpy (smcConn->client_id, *clientIdRet); + } + else + { + /* + * Could not register the client because the previous ID + * was bad. So now we register the client with the + * previous ID set to NULL. + */ + + extra = ARRAY8_BYTES (0); + + IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient, + SIZEOF (smRegisterClientMsg), WORD64COUNT (extra), + smRegisterClientMsg, pMsg, pData); + + previousId = NULL; + + STORE_ARRAY8 (pData, 0, previousId); + + IceFlush (iceConn); + + replyWait.sequence_of_request = + IceLastSentSequenceNumber (iceConn); + + gotReply = False; + } + } + } + + return (smcConn); +} + + + +SmcCloseStatus +SmcCloseConnection (smcConn, count, reasonMsgs) + +SmcConn smcConn; +int count; +char **reasonMsgs; + +{ + IceConn iceConn = smcConn->iceConn; + smCloseConnectionMsg *pMsg; + char *pData; + int extra, i; + IceCloseStatus closeStatus; + SmcCloseStatus statusRet; + + extra = 8; + + for (i = 0; i < count; i++) + extra += ARRAY8_BYTES (strlen (reasonMsgs[i])); + + IceGetHeaderExtra (iceConn, _SmcOpcode, SM_CloseConnection, + SIZEOF (smCloseConnectionMsg), WORD64COUNT (extra), + smCloseConnectionMsg, pMsg, pData); + + STORE_CARD32 (pData, count); + pData += 4; + + for (i = 0; i < count; i++) + STORE_ARRAY8 (pData, strlen (reasonMsgs[i]), reasonMsgs[i]); + + IceFlush (iceConn); + + IceProtocolShutdown (iceConn, _SmcOpcode); + IceSetShutdownNegotiation (iceConn, False); + closeStatus = IceCloseConnection (iceConn); + + if (smcConn->vendor) + free (smcConn->vendor); + + if (smcConn->release) + free (smcConn->release); + + if (smcConn->client_id) + free (smcConn->client_id); + + if (smcConn->prop_reply_waits) + { + _SmcPropReplyWait *ptr = smcConn->prop_reply_waits; + _SmcPropReplyWait *next; + + while (ptr) + { + next = ptr->next; + free ((char *) ptr); + ptr = next; + } + + } + + free ((char *) smcConn); + + if (closeStatus == IceClosedNow) + statusRet = SmcClosedNow; + else if (closeStatus == IceClosedASAP) + statusRet = SmcClosedASAP; + else + statusRet = SmcConnectionInUse; + + return (statusRet); +} + + + +void +SmcModifyCallbacks (smcConn, mask, callbacks) + +SmcConn smcConn; +unsigned long mask; +SmcCallbacks *callbacks; + +{ + set_callbacks (smcConn, mask, callbacks); +} + + + +void +SmcSetProperties (smcConn, numProps, props) + +SmcConn smcConn; +int numProps; +SmProp **props; + +{ + IceConn iceConn = smcConn->iceConn; + smSetPropertiesMsg *pMsg; + char *pBuf; + char *pStart; + int bytes; + + IceGetHeader (iceConn, _SmcOpcode, SM_SetProperties, + SIZEOF (smSetPropertiesMsg), smSetPropertiesMsg, pMsg); + + LISTOF_PROP_BYTES (numProps, props, bytes); + pMsg->length += WORD64COUNT (bytes); + + pBuf = pStart = IceAllocScratch (iceConn, bytes); + + STORE_LISTOF_PROPERTY (pBuf, numProps, props); + + IceWriteData (iceConn, bytes, pStart); + IceFlush (iceConn); +} + + + +void +SmcDeleteProperties (smcConn, numProps, propNames) + +SmcConn smcConn; +int numProps; +char **propNames; + +{ + IceConn iceConn = smcConn->iceConn; + smDeletePropertiesMsg *pMsg; + char *pData; + int extra, i; + + extra = 8; + + for (i = 0; i < numProps; i++) + extra += ARRAY8_BYTES (strlen (propNames[i])); + + IceGetHeaderExtra (iceConn, _SmcOpcode, SM_DeleteProperties, + SIZEOF (smDeletePropertiesMsg), WORD64COUNT (extra), + smDeletePropertiesMsg, pMsg, pData); + + STORE_CARD32 (pData, numProps); + pData += 4; + + for (i = 0; i < numProps; i++) + STORE_ARRAY8 (pData, strlen (propNames[i]), propNames[i]); + + IceFlush (iceConn); +} + + + +Status +SmcGetProperties (smcConn, propReplyProc, clientData) + +SmcConn smcConn; +SmcPropReplyProc propReplyProc; +SmPointer clientData; + +{ + IceConn iceConn = smcConn->iceConn; + _SmcPropReplyWait *wait, *ptr; + + if ((wait = (_SmcPropReplyWait *) malloc ( + sizeof (_SmcPropReplyWait))) == NULL) + { + return (0); + } + + wait->prop_reply_proc = propReplyProc; + wait->client_data = clientData; + wait->next = NULL; + + ptr = smcConn->prop_reply_waits; + while (ptr && ptr->next) + ptr = ptr->next; + + if (ptr == NULL) + smcConn->prop_reply_waits = wait; + else + ptr->next = wait; + + IceSimpleMessage (iceConn, _SmcOpcode, SM_GetProperties); + IceFlush (iceConn); + + return (1); +} + + + +Status +SmcInteractRequest (smcConn, dialogType, interactProc, clientData) + +SmcConn smcConn; +int dialogType; +SmcInteractProc interactProc; +SmPointer clientData; + +{ + IceConn iceConn = smcConn->iceConn; + smInteractRequestMsg *pMsg; + _SmcInteractWait *wait, *ptr; + + if ((wait = (_SmcInteractWait *) malloc ( + sizeof (_SmcInteractWait))) == NULL) + { + return (0); + } + + wait->interact_proc = interactProc; + wait->client_data = clientData; + wait->next = NULL; + + ptr = smcConn->interact_waits; + while (ptr && ptr->next) + ptr = ptr->next; + + if (ptr == NULL) + smcConn->interact_waits = wait; + else + ptr->next = wait; + + IceGetHeader (iceConn, _SmcOpcode, SM_InteractRequest, + SIZEOF (smInteractRequestMsg), smInteractRequestMsg, pMsg); + + pMsg->dialogType = dialogType; + + IceFlush (iceConn); + + return (1); +} + + + +void +SmcInteractDone (smcConn, cancelShutdown) + +SmcConn smcConn; +Bool cancelShutdown; + +{ + IceConn iceConn = smcConn->iceConn; + smInteractDoneMsg *pMsg; + + IceGetHeader (iceConn, _SmcOpcode, SM_InteractDone, + SIZEOF (smInteractDoneMsg), smInteractDoneMsg, pMsg); + + pMsg->cancelShutdown = cancelShutdown; + + IceFlush (iceConn); +} + + + +void +SmcRequestSaveYourself (smcConn, saveType, shutdown, interactStyle, + fast, global) + +SmcConn smcConn; +int saveType; +Bool shutdown; +int interactStyle; +Bool fast; +Bool global; + +{ + IceConn iceConn = smcConn->iceConn; + smSaveYourselfRequestMsg *pMsg; + + IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfRequest, + SIZEOF (smSaveYourselfRequestMsg), smSaveYourselfRequestMsg, pMsg); + + pMsg->saveType = saveType; + pMsg->shutdown = shutdown; + pMsg->interactStyle = interactStyle; + pMsg->fast = fast; + pMsg->global = global; + + IceFlush (iceConn); +} + + + +Status +SmcRequestSaveYourselfPhase2 (smcConn, saveYourselfPhase2Proc, clientData) + +SmcConn smcConn; +SmcSaveYourselfPhase2Proc saveYourselfPhase2Proc; +SmPointer clientData; + +{ + IceConn iceConn = smcConn->iceConn; + _SmcPhase2Wait *wait; + + if (smcConn->phase2_wait) + wait = smcConn->phase2_wait; + else + { + if ((wait = (_SmcPhase2Wait *) malloc ( + sizeof (_SmcPhase2Wait))) == NULL) + { + return (0); + } + } + + wait->phase2_proc = saveYourselfPhase2Proc; + wait->client_data = clientData; + + smcConn->phase2_wait = wait; + + IceSimpleMessage (iceConn, _SmcOpcode, SM_SaveYourselfPhase2Request); + IceFlush (iceConn); + + return (1); +} + + + +void +SmcSaveYourselfDone (smcConn, success) + +SmcConn smcConn; +Bool success; + +{ + IceConn iceConn = smcConn->iceConn; + smSaveYourselfDoneMsg *pMsg; + + IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfDone, + SIZEOF (smSaveYourselfDoneMsg), smSaveYourselfDoneMsg, pMsg); + + pMsg->success = success; + + IceFlush (iceConn); +} + + + +static void +set_callbacks (smcConn, mask, callbacks) + +SmcConn smcConn; +unsigned long mask; +SmcCallbacks *callbacks; + +{ + if (mask & SmcSaveYourselfProcMask) + { + smcConn->callbacks.save_yourself.callback = + callbacks->save_yourself.callback; + smcConn->callbacks.save_yourself.client_data = + callbacks->save_yourself.client_data; + } + + if (mask & SmcDieProcMask) + { + smcConn->callbacks.die.callback = callbacks->die.callback; + smcConn->callbacks.die.client_data = callbacks->die.client_data; + } + + if (mask & SmcSaveCompleteProcMask) + { + smcConn->callbacks.save_complete.callback = + callbacks->save_complete.callback; + smcConn->callbacks.save_complete.client_data = + callbacks->save_complete.client_data; + } + + if (mask & SmcShutdownCancelledProcMask) + { + smcConn->callbacks.shutdown_cancelled.callback = + callbacks->shutdown_cancelled.callback; + smcConn->callbacks.shutdown_cancelled.client_data = + callbacks->shutdown_cancelled.client_data; + } +} diff --git a/nx-X11/lib/SM/sm_client.c.SM.original b/nx-X11/lib/SM/sm_client.c.SM.original new file mode 100644 index 000000000..02f9ccdf6 --- /dev/null +++ b/nx-X11/lib/SM/sm_client.c.SM.original @@ -0,0 +1,631 @@ +/* $Xorg: sm_client.c,v 1.4 2001/02/09 02:03:30 xorgcvs Exp $ */ + +/* + +Copyright 1993, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +/* + * Author: Ralph Mor, X Consortium + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "SMlibint.h" +#include "globals.h" + +static void set_callbacks(); + + +SmcConn +SmcOpenConnection (networkIdsList, context, + xsmpMajorRev, xsmpMinorRev, mask, callbacks, + previousId, clientIdRet, errorLength, errorStringRet) + +char *networkIdsList; +SmPointer context; +int xsmpMajorRev; +int xsmpMinorRev; +unsigned long mask; +SmcCallbacks *callbacks; +char *previousId; +char **clientIdRet; +int errorLength; +char *errorStringRet; + +{ + SmcConn smcConn; + IceConn iceConn; + char *ids; + IceProtocolSetupStatus setupstat; + int majorVersion; + int minorVersion; + char *vendor = NULL; + char *release = NULL; + smRegisterClientMsg *pMsg; + char *pData; + int extra, len; + IceReplyWaitInfo replyWait; + _SmcRegisterClientReply reply; + Bool gotReply, ioErrorOccured; + + *clientIdRet = NULL; + + if (errorStringRet && errorLength > 0) + *errorStringRet = '\0'; + + if (!_SmcOpcode) + { + /* + * For now, there is only one version of XSMP, so we don't + * have to check {xsmpMajorRev, xsmpMinorRev}. In the future, + * we will check against _SmcVersions and generate the list + * of versions the application actually supports. + */ + + if ((_SmcOpcode = IceRegisterForProtocolSetup ("XSMP", + SmVendorString, SmReleaseString, _SmVersionCount, _SmcVersions, + _SmAuthCount, _SmAuthNames, _SmcAuthProcs, NULL)) < 0) + { + strncpy (errorStringRet, + "Could not register XSMP protocol with ICE", errorLength); + + return (NULL); + } + } + + if (networkIdsList == NULL || *networkIdsList == '\0') + { + if ((ids = (char *) getenv ("SESSION_MANAGER")) == NULL) + { + strncpy (errorStringRet, + "SESSION_MANAGER environment variable not defined", + errorLength); + + return (NULL); + } + } + else + { + ids = networkIdsList; + } + + if ((iceConn = IceOpenConnection ( + ids, context, 0, _SmcOpcode, errorLength, errorStringRet)) == NULL) + { + return (NULL); + } + + if ((smcConn = (SmcConn) malloc (sizeof (struct _SmcConn))) == NULL) + { + strncpy (errorStringRet, "Can't malloc", errorLength); + IceCloseConnection (iceConn); + return (NULL); + } + + setupstat = IceProtocolSetup (iceConn, _SmcOpcode, + (IcePointer) smcConn, + False /* mustAuthenticate */, + &majorVersion, &minorVersion, + &vendor, &release, errorLength, errorStringRet); + + if (setupstat == IceProtocolSetupFailure || + setupstat == IceProtocolSetupIOError) + { + IceCloseConnection (iceConn); + free ((char *) smcConn); + return (NULL); + } + else if (setupstat == IceProtocolAlreadyActive) + { + /* + * This case should never happen, because when we called + * IceOpenConnection, we required that the ICE connection + * may not already have XSMP active on it. + */ + + free ((char *) smcConn); + strncpy (errorStringRet, "Internal error in IceOpenConnection", + errorLength); + return (NULL); + } + + smcConn->iceConn = iceConn; + smcConn->proto_major_version = majorVersion; + smcConn->proto_minor_version = minorVersion; + smcConn->vendor = vendor; + smcConn->release = release; + smcConn->client_id = NULL; + + bzero ((char *) &smcConn->callbacks, sizeof (SmcCallbacks)); + set_callbacks (smcConn, mask, callbacks); + + smcConn->interact_waits = NULL; + smcConn->phase2_wait = NULL; + smcConn->prop_reply_waits = NULL; + + smcConn->save_yourself_in_progress = False; + smcConn->shutdown_in_progress = False; + + + /* + * Now register the client + */ + + len = previousId ? strlen (previousId) : 0; + extra = ARRAY8_BYTES (len); + + IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient, + SIZEOF (smRegisterClientMsg), WORD64COUNT (extra), + smRegisterClientMsg, pMsg, pData); + + STORE_ARRAY8 (pData, len, previousId); + + IceFlush (iceConn); + + replyWait.sequence_of_request = IceLastSentSequenceNumber (iceConn); + replyWait.major_opcode_of_request = _SmcOpcode; + replyWait.minor_opcode_of_request = SM_RegisterClient; + replyWait.reply = (IcePointer) &reply; + + gotReply = False; + ioErrorOccured = False; + + while (!gotReply && !ioErrorOccured) + { + ioErrorOccured = (IceProcessMessages ( + iceConn, &replyWait, &gotReply) == IceProcessMessagesIOError); + + if (ioErrorOccured) + { + strncpy (errorStringRet, "IO error occured opening connection", + errorLength); + + free (smcConn->vendor); + free (smcConn->release); + free ((char *) smcConn); + + return (NULL); + } + else if (gotReply) + { + if (reply.status == 1) + { + /* + * The client successfully registered. + */ + + *clientIdRet = reply.client_id; + + smcConn->client_id = (char *) malloc ( + strlen (*clientIdRet) + 1); + + strcpy (smcConn->client_id, *clientIdRet); + } + else + { + /* + * Could not register the client because the previous ID + * was bad. So now we register the client with the + * previous ID set to NULL. + */ + + extra = ARRAY8_BYTES (0); + + IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient, + SIZEOF (smRegisterClientMsg), WORD64COUNT (extra), + smRegisterClientMsg, pMsg, pData); + + STORE_ARRAY8 (pData, 0, NULL); + + IceFlush (iceConn); + + replyWait.sequence_of_request = + IceLastSentSequenceNumber (iceConn); + + gotReply = False; + } + } + } + + return (smcConn); +} + + + +SmcCloseStatus +SmcCloseConnection (smcConn, count, reasonMsgs) + +SmcConn smcConn; +int count; +char **reasonMsgs; + +{ + IceConn iceConn = smcConn->iceConn; + smCloseConnectionMsg *pMsg; + char *pData; + int extra, i; + IceCloseStatus closeStatus; + SmcCloseStatus statusRet; + + extra = 8; + + for (i = 0; i < count; i++) + extra += ARRAY8_BYTES (strlen (reasonMsgs[i])); + + IceGetHeaderExtra (iceConn, _SmcOpcode, SM_CloseConnection, + SIZEOF (smCloseConnectionMsg), WORD64COUNT (extra), + smCloseConnectionMsg, pMsg, pData); + + STORE_CARD32 (pData, count); + pData += 4; + + for (i = 0; i < count; i++) + STORE_ARRAY8 (pData, strlen (reasonMsgs[i]), reasonMsgs[i]); + + IceFlush (iceConn); + + IceProtocolShutdown (iceConn, _SmcOpcode); + IceSetShutdownNegotiation (iceConn, False); + closeStatus = IceCloseConnection (iceConn); + + if (smcConn->vendor) + free (smcConn->vendor); + + if (smcConn->release) + free (smcConn->release); + + if (smcConn->client_id) + free (smcConn->client_id); + + if (smcConn->prop_reply_waits) + { + _SmcPropReplyWait *ptr = smcConn->prop_reply_waits; + _SmcPropReplyWait *next; + + while (ptr) + { + next = ptr->next; + free ((char *) ptr); + ptr = next; + } + + } + + free ((char *) smcConn); + + if (closeStatus == IceClosedNow) + statusRet = SmcClosedNow; + else if (closeStatus == IceClosedASAP) + statusRet = SmcClosedASAP; + else + statusRet = SmcConnectionInUse; + + return (statusRet); +} + + + +void +SmcModifyCallbacks (smcConn, mask, callbacks) + +SmcConn smcConn; +unsigned long mask; +SmcCallbacks *callbacks; + +{ + set_callbacks (smcConn, mask, callbacks); +} + + + +void +SmcSetProperties (smcConn, numProps, props) + +SmcConn smcConn; +int numProps; +SmProp **props; + +{ + IceConn iceConn = smcConn->iceConn; + smSetPropertiesMsg *pMsg; + char *pBuf; + char *pStart; + int bytes; + + IceGetHeader (iceConn, _SmcOpcode, SM_SetProperties, + SIZEOF (smSetPropertiesMsg), smSetPropertiesMsg, pMsg); + + LISTOF_PROP_BYTES (numProps, props, bytes); + pMsg->length += WORD64COUNT (bytes); + + pBuf = pStart = IceAllocScratch (iceConn, bytes); + + STORE_LISTOF_PROPERTY (pBuf, numProps, props); + + IceWriteData (iceConn, bytes, pStart); + IceFlush (iceConn); +} + + + +void +SmcDeleteProperties (smcConn, numProps, propNames) + +SmcConn smcConn; +int numProps; +char **propNames; + +{ + IceConn iceConn = smcConn->iceConn; + smDeletePropertiesMsg *pMsg; + char *pData; + int extra, i; + + extra = 8; + + for (i = 0; i < numProps; i++) + extra += ARRAY8_BYTES (strlen (propNames[i])); + + IceGetHeaderExtra (iceConn, _SmcOpcode, SM_DeleteProperties, + SIZEOF (smDeletePropertiesMsg), WORD64COUNT (extra), + smDeletePropertiesMsg, pMsg, pData); + + STORE_CARD32 (pData, numProps); + pData += 4; + + for (i = 0; i < numProps; i++) + STORE_ARRAY8 (pData, strlen (propNames[i]), propNames[i]); + + IceFlush (iceConn); +} + + + +Status +SmcGetProperties (smcConn, propReplyProc, clientData) + +SmcConn smcConn; +SmcPropReplyProc propReplyProc; +SmPointer clientData; + +{ + IceConn iceConn = smcConn->iceConn; + _SmcPropReplyWait *wait, *ptr; + + if ((wait = (_SmcPropReplyWait *) malloc ( + sizeof (_SmcPropReplyWait))) == NULL) + { + return (0); + } + + wait->prop_reply_proc = propReplyProc; + wait->client_data = clientData; + wait->next = NULL; + + ptr = smcConn->prop_reply_waits; + while (ptr && ptr->next) + ptr = ptr->next; + + if (ptr == NULL) + smcConn->prop_reply_waits = wait; + else + ptr->next = wait; + + IceSimpleMessage (iceConn, _SmcOpcode, SM_GetProperties); + IceFlush (iceConn); + + return (1); +} + + + +Status +SmcInteractRequest (smcConn, dialogType, interactProc, clientData) + +SmcConn smcConn; +int dialogType; +SmcInteractProc interactProc; +SmPointer clientData; + +{ + IceConn iceConn = smcConn->iceConn; + smInteractRequestMsg *pMsg; + _SmcInteractWait *wait, *ptr; + + if ((wait = (_SmcInteractWait *) malloc ( + sizeof (_SmcInteractWait))) == NULL) + { + return (0); + } + + wait->interact_proc = interactProc; + wait->client_data = clientData; + wait->next = NULL; + + ptr = smcConn->interact_waits; + while (ptr && ptr->next) + ptr = ptr->next; + + if (ptr == NULL) + smcConn->interact_waits = wait; + else + ptr->next = wait; + + IceGetHeader (iceConn, _SmcOpcode, SM_InteractRequest, + SIZEOF (smInteractRequestMsg), smInteractRequestMsg, pMsg); + + pMsg->dialogType = dialogType; + + IceFlush (iceConn); + + return (1); +} + + + +void +SmcInteractDone (smcConn, cancelShutdown) + +SmcConn smcConn; +Bool cancelShutdown; + +{ + IceConn iceConn = smcConn->iceConn; + smInteractDoneMsg *pMsg; + + IceGetHeader (iceConn, _SmcOpcode, SM_InteractDone, + SIZEOF (smInteractDoneMsg), smInteractDoneMsg, pMsg); + + pMsg->cancelShutdown = cancelShutdown; + + IceFlush (iceConn); +} + + + +void +SmcRequestSaveYourself (smcConn, saveType, shutdown, interactStyle, + fast, global) + +SmcConn smcConn; +int saveType; +Bool shutdown; +int interactStyle; +Bool fast; +Bool global; + +{ + IceConn iceConn = smcConn->iceConn; + smSaveYourselfRequestMsg *pMsg; + + IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfRequest, + SIZEOF (smSaveYourselfRequestMsg), smSaveYourselfRequestMsg, pMsg); + + pMsg->saveType = saveType; + pMsg->shutdown = shutdown; + pMsg->interactStyle = interactStyle; + pMsg->fast = fast; + pMsg->global = global; + + IceFlush (iceConn); +} + + + +Status +SmcRequestSaveYourselfPhase2 (smcConn, saveYourselfPhase2Proc, clientData) + +SmcConn smcConn; +SmcSaveYourselfPhase2Proc saveYourselfPhase2Proc; +SmPointer clientData; + +{ + IceConn iceConn = smcConn->iceConn; + _SmcPhase2Wait *wait; + + if (smcConn->phase2_wait) + wait = smcConn->phase2_wait; + else + { + if ((wait = (_SmcPhase2Wait *) malloc ( + sizeof (_SmcPhase2Wait))) == NULL) + { + return (0); + } + } + + wait->phase2_proc = saveYourselfPhase2Proc; + wait->client_data = clientData; + + smcConn->phase2_wait = wait; + + IceSimpleMessage (iceConn, _SmcOpcode, SM_SaveYourselfPhase2Request); + IceFlush (iceConn); + + return (1); +} + + + +void +SmcSaveYourselfDone (smcConn, success) + +SmcConn smcConn; +Bool success; + +{ + IceConn iceConn = smcConn->iceConn; + smSaveYourselfDoneMsg *pMsg; + + IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfDone, + SIZEOF (smSaveYourselfDoneMsg), smSaveYourselfDoneMsg, pMsg); + + pMsg->success = success; + + IceFlush (iceConn); +} + + + +static void +set_callbacks (smcConn, mask, callbacks) + +SmcConn smcConn; +unsigned long mask; +SmcCallbacks *callbacks; + +{ + if (mask & SmcSaveYourselfProcMask) + { + smcConn->callbacks.save_yourself.callback = + callbacks->save_yourself.callback; + smcConn->callbacks.save_yourself.client_data = + callbacks->save_yourself.client_data; + } + + if (mask & SmcDieProcMask) + { + smcConn->callbacks.die.callback = callbacks->die.callback; + smcConn->callbacks.die.client_data = callbacks->die.client_data; + } + + if (mask & SmcSaveCompleteProcMask) + { + smcConn->callbacks.save_complete.callback = + callbacks->save_complete.callback; + smcConn->callbacks.save_complete.client_data = + callbacks->save_complete.client_data; + } + + if (mask & SmcShutdownCancelledProcMask) + { + smcConn->callbacks.shutdown_cancelled.callback = + callbacks->shutdown_cancelled.callback; + smcConn->callbacks.shutdown_cancelled.client_data = + callbacks->shutdown_cancelled.client_data; + } +} diff --git a/nx-X11/programs/Xserver/GL/glx/render2.c b/nx-X11/programs/Xserver/GL/glx/render2.c index 39d0c132a..f4491b276 100644 --- a/nx-X11/programs/Xserver/GL/glx/render2.c +++ b/nx-X11/programs/Xserver/GL/glx/render2.c @@ -43,7 +43,7 @@ #include "unpack.h" #include "g_disptab.h" #include "g_disptab_EXT.h" - +#include "indirect_size.h" void __glXDisp_Map1f(GLbyte *pc) { diff --git a/nx-X11/programs/Xserver/GL/glx/render2.c.NX.original b/nx-X11/programs/Xserver/GL/glx/render2.c.NX.original new file mode 100644 index 000000000..f4491b276 --- /dev/null +++ b/nx-X11/programs/Xserver/GL/glx/render2.c.NX.original @@ -0,0 +1,271 @@ +/* $XFree86: xc/programs/Xserver/GL/glx/render2.c,v 1.8 2004/02/03 23:04:08 alanh Exp $ */ +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +*/ + +/* #define NEED_REPLIES */ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include "unpack.h" +#include "g_disptab.h" +#include "g_disptab_EXT.h" +#include "indirect_size.h" + +void __glXDisp_Map1f(GLbyte *pc) +{ + GLint order, k; + GLfloat u1, u2, *points; + GLenum target; + + target = *(GLenum *)(pc + 0); + order = *(GLint *)(pc + 12); + u1 = *(GLfloat *)(pc + 4); + u2 = *(GLfloat *)(pc + 8); + points = (GLfloat *)(pc + 16); + k = __glMap1f_size(target); + + glMap1f(target, u1, u2, k, order, points); +} + +void __glXDisp_Map2f(GLbyte *pc) +{ + GLint uorder, vorder, ustride, vstride, k; + GLfloat u1, u2, v1, v2, *points; + GLenum target; + + target = *(GLenum *)(pc + 0); + uorder = *(GLint *)(pc + 12); + vorder = *(GLint *)(pc + 24); + u1 = *(GLfloat *)(pc + 4); + u2 = *(GLfloat *)(pc + 8); + v1 = *(GLfloat *)(pc + 16); + v2 = *(GLfloat *)(pc + 20); + points = (GLfloat *)(pc + 28); + + k = __glMap2f_size(target); + ustride = vorder * k; + vstride = k; + + glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); +} + +void __glXDisp_Map1d(GLbyte *pc) +{ + GLint order, k; +#ifdef __GLX_ALIGN64 + GLint compsize; +#endif + GLenum target; + GLdouble u1, u2, *points; + + target = *(GLenum*) (pc + 16); + order = *(GLint*) (pc + 20); + k = __glMap1d_size(target); + +#ifdef __GLX_ALIGN64 + if (order < 0 || k < 0) { + compsize = 0; + } else { + compsize = order * k; + } +#endif + + __GLX_GET_DOUBLE(u1,pc); + __GLX_GET_DOUBLE(u2,pc+8); + pc += 24; + +#ifdef __GLX_ALIGN64 + if (((unsigned long)pc) & 7) { + /* + ** Copy the doubles up 4 bytes, trashing the command but aligning + ** the data in the process + */ + __GLX_MEM_COPY(pc-4, pc, compsize*8); + points = (GLdouble*) (pc - 4); + } else { + points = (GLdouble*) pc; + } +#else + points = (GLdouble*) pc; +#endif + glMap1d(target, u1, u2, k, order, points); +} + +void __glXDisp_Map2d(GLbyte *pc) +{ + GLdouble u1, u2, v1, v2, *points; + GLint uorder, vorder, ustride, vstride, k; +#ifdef __GLX_ALIGN64 + GLint compsize; +#endif + GLenum target; + + target = *(GLenum *)(pc + 32); + uorder = *(GLint *)(pc + 36); + vorder = *(GLint *)(pc + 40); + k = __glMap2d_size(target); + +#ifdef __GLX_ALIGN64 + if (vorder < 0 || uorder < 0 || k < 0) { + compsize = 0; + } else { + compsize = uorder * vorder * k; + } +#endif + + __GLX_GET_DOUBLE(u1,pc); + __GLX_GET_DOUBLE(u2,pc+8); + __GLX_GET_DOUBLE(v1,pc+16); + __GLX_GET_DOUBLE(v2,pc+24); + pc += 44; + + ustride = vorder * k; + vstride = k; + +#ifdef __GLX_ALIGN64 + if (((unsigned long)pc) & 7) { + /* + ** Copy the doubles up 4 bytes, trashing the command but aligning + ** the data in the process + */ + __GLX_MEM_COPY(pc-4, pc, compsize*8); + points = (GLdouble*) (pc - 4); + } else { + points = (GLdouble*) pc; + } +#else + points = (GLdouble*) pc; +#endif + glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); +} + +void __glXDisp_CallLists(GLbyte *pc) +{ + GLenum type; + GLsizei n; + + type = *(GLenum *)(pc + 4); + n = *(GLsizei *)(pc + 0); + glCallLists(n, type, pc + 8); +} + +void __glXDisp_DrawArrays(GLbyte *pc) +{ + __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *)pc; + __GLXdispatchDrawArraysComponentHeader *compHeader; + GLint numVertexes = hdr->numVertexes; + GLint numComponents = hdr->numComponents; + GLenum primType = hdr->primType; + GLint stride = 0; + int i; + + pc += sizeof(__GLXdispatchDrawArraysHeader); + compHeader = (__GLXdispatchDrawArraysComponentHeader *)pc; + + /* compute stride (same for all component arrays) */ + for (i = 0; i < numComponents; i++) { + GLenum datatype = compHeader[i].datatype; + GLint numVals = compHeader[i].numVals; + + stride += __GLX_PAD(numVals * __glXTypeSize(datatype)); + } + + pc += numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader); + + /* set up component arrays */ + for (i = 0; i < numComponents; i++) { + GLenum datatype = compHeader[i].datatype; + GLint numVals = compHeader[i].numVals; + GLenum component = compHeader[i].component; + + switch (component) { + case GL_VERTEX_ARRAY: + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(numVals, datatype, stride, pc); + break; + case GL_NORMAL_ARRAY: + glEnableClientState(GL_NORMAL_ARRAY); + glNormalPointer(datatype, stride, pc); + break; + case GL_COLOR_ARRAY: + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(numVals, datatype, stride, pc); + break; + case GL_INDEX_ARRAY: + glEnableClientState(GL_INDEX_ARRAY); + glIndexPointer(datatype, stride, pc); + break; + case GL_TEXTURE_COORD_ARRAY: + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(numVals, datatype, stride, pc); + break; + case GL_EDGE_FLAG_ARRAY: + glEnableClientState(GL_EDGE_FLAG_ARRAY); + glEdgeFlagPointer(stride, (const GLboolean *)pc); + break; + case GL_SECONDARY_COLOR_ARRAY: + glEnableClientState(GL_SECONDARY_COLOR_ARRAY); + glSecondaryColorPointer(numVals, datatype, stride, pc); + break; + case GL_FOG_COORD_ARRAY: + glEnableClientState(GL_FOG_COORD_ARRAY); + glFogCoordPointer(datatype, stride, pc); + break; + default: + break; + } + + pc += __GLX_PAD(numVals * __glXTypeSize(datatype)); + } + + glDrawArrays(primType, 0, numVertexes); + + /* turn off anything we might have turned on */ + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_INDEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_EDGE_FLAG_ARRAY); + glDisableClientState(GL_SECONDARY_COLOR_ARRAY); + glDisableClientState(GL_FOG_COORD_ARRAY); +} + +void __glXDisp_DrawArraysEXT(GLbyte *pc) +{ + __glXDisp_DrawArrays(pc); +} diff --git a/nx-X11/programs/Xserver/GL/glx/render2.c.X.original b/nx-X11/programs/Xserver/GL/glx/render2.c.X.original new file mode 100644 index 000000000..39d0c132a --- /dev/null +++ b/nx-X11/programs/Xserver/GL/glx/render2.c.X.original @@ -0,0 +1,271 @@ +/* $XFree86: xc/programs/Xserver/GL/glx/render2.c,v 1.8 2004/02/03 23:04:08 alanh Exp $ */ +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +*/ + +/* #define NEED_REPLIES */ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include "unpack.h" +#include "g_disptab.h" +#include "g_disptab_EXT.h" + + +void __glXDisp_Map1f(GLbyte *pc) +{ + GLint order, k; + GLfloat u1, u2, *points; + GLenum target; + + target = *(GLenum *)(pc + 0); + order = *(GLint *)(pc + 12); + u1 = *(GLfloat *)(pc + 4); + u2 = *(GLfloat *)(pc + 8); + points = (GLfloat *)(pc + 16); + k = __glMap1f_size(target); + + glMap1f(target, u1, u2, k, order, points); +} + +void __glXDisp_Map2f(GLbyte *pc) +{ + GLint uorder, vorder, ustride, vstride, k; + GLfloat u1, u2, v1, v2, *points; + GLenum target; + + target = *(GLenum *)(pc + 0); + uorder = *(GLint *)(pc + 12); + vorder = *(GLint *)(pc + 24); + u1 = *(GLfloat *)(pc + 4); + u2 = *(GLfloat *)(pc + 8); + v1 = *(GLfloat *)(pc + 16); + v2 = *(GLfloat *)(pc + 20); + points = (GLfloat *)(pc + 28); + + k = __glMap2f_size(target); + ustride = vorder * k; + vstride = k; + + glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); +} + +void __glXDisp_Map1d(GLbyte *pc) +{ + GLint order, k; +#ifdef __GLX_ALIGN64 + GLint compsize; +#endif + GLenum target; + GLdouble u1, u2, *points; + + target = *(GLenum*) (pc + 16); + order = *(GLint*) (pc + 20); + k = __glMap1d_size(target); + +#ifdef __GLX_ALIGN64 + if (order < 0 || k < 0) { + compsize = 0; + } else { + compsize = order * k; + } +#endif + + __GLX_GET_DOUBLE(u1,pc); + __GLX_GET_DOUBLE(u2,pc+8); + pc += 24; + +#ifdef __GLX_ALIGN64 + if (((unsigned long)pc) & 7) { + /* + ** Copy the doubles up 4 bytes, trashing the command but aligning + ** the data in the process + */ + __GLX_MEM_COPY(pc-4, pc, compsize*8); + points = (GLdouble*) (pc - 4); + } else { + points = (GLdouble*) pc; + } +#else + points = (GLdouble*) pc; +#endif + glMap1d(target, u1, u2, k, order, points); +} + +void __glXDisp_Map2d(GLbyte *pc) +{ + GLdouble u1, u2, v1, v2, *points; + GLint uorder, vorder, ustride, vstride, k; +#ifdef __GLX_ALIGN64 + GLint compsize; +#endif + GLenum target; + + target = *(GLenum *)(pc + 32); + uorder = *(GLint *)(pc + 36); + vorder = *(GLint *)(pc + 40); + k = __glMap2d_size(target); + +#ifdef __GLX_ALIGN64 + if (vorder < 0 || uorder < 0 || k < 0) { + compsize = 0; + } else { + compsize = uorder * vorder * k; + } +#endif + + __GLX_GET_DOUBLE(u1,pc); + __GLX_GET_DOUBLE(u2,pc+8); + __GLX_GET_DOUBLE(v1,pc+16); + __GLX_GET_DOUBLE(v2,pc+24); + pc += 44; + + ustride = vorder * k; + vstride = k; + +#ifdef __GLX_ALIGN64 + if (((unsigned long)pc) & 7) { + /* + ** Copy the doubles up 4 bytes, trashing the command but aligning + ** the data in the process + */ + __GLX_MEM_COPY(pc-4, pc, compsize*8); + points = (GLdouble*) (pc - 4); + } else { + points = (GLdouble*) pc; + } +#else + points = (GLdouble*) pc; +#endif + glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); +} + +void __glXDisp_CallLists(GLbyte *pc) +{ + GLenum type; + GLsizei n; + + type = *(GLenum *)(pc + 4); + n = *(GLsizei *)(pc + 0); + glCallLists(n, type, pc + 8); +} + +void __glXDisp_DrawArrays(GLbyte *pc) +{ + __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *)pc; + __GLXdispatchDrawArraysComponentHeader *compHeader; + GLint numVertexes = hdr->numVertexes; + GLint numComponents = hdr->numComponents; + GLenum primType = hdr->primType; + GLint stride = 0; + int i; + + pc += sizeof(__GLXdispatchDrawArraysHeader); + compHeader = (__GLXdispatchDrawArraysComponentHeader *)pc; + + /* compute stride (same for all component arrays) */ + for (i = 0; i < numComponents; i++) { + GLenum datatype = compHeader[i].datatype; + GLint numVals = compHeader[i].numVals; + + stride += __GLX_PAD(numVals * __glXTypeSize(datatype)); + } + + pc += numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader); + + /* set up component arrays */ + for (i = 0; i < numComponents; i++) { + GLenum datatype = compHeader[i].datatype; + GLint numVals = compHeader[i].numVals; + GLenum component = compHeader[i].component; + + switch (component) { + case GL_VERTEX_ARRAY: + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(numVals, datatype, stride, pc); + break; + case GL_NORMAL_ARRAY: + glEnableClientState(GL_NORMAL_ARRAY); + glNormalPointer(datatype, stride, pc); + break; + case GL_COLOR_ARRAY: + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(numVals, datatype, stride, pc); + break; + case GL_INDEX_ARRAY: + glEnableClientState(GL_INDEX_ARRAY); + glIndexPointer(datatype, stride, pc); + break; + case GL_TEXTURE_COORD_ARRAY: + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(numVals, datatype, stride, pc); + break; + case GL_EDGE_FLAG_ARRAY: + glEnableClientState(GL_EDGE_FLAG_ARRAY); + glEdgeFlagPointer(stride, (const GLboolean *)pc); + break; + case GL_SECONDARY_COLOR_ARRAY: + glEnableClientState(GL_SECONDARY_COLOR_ARRAY); + glSecondaryColorPointer(numVals, datatype, stride, pc); + break; + case GL_FOG_COORD_ARRAY: + glEnableClientState(GL_FOG_COORD_ARRAY); + glFogCoordPointer(datatype, stride, pc); + break; + default: + break; + } + + pc += __GLX_PAD(numVals * __glXTypeSize(datatype)); + } + + glDrawArrays(primType, 0, numVertexes); + + /* turn off anything we might have turned on */ + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_INDEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_EDGE_FLAG_ARRAY); + glDisableClientState(GL_SECONDARY_COLOR_ARRAY); + glDisableClientState(GL_FOG_COORD_ARRAY); +} + +void __glXDisp_DrawArraysEXT(GLbyte *pc) +{ + __glXDisp_DrawArrays(pc); +} diff --git a/nx-X11/programs/Xserver/GL/glx/render2swap.c b/nx-X11/programs/Xserver/GL/glx/render2swap.c index 65ac5e18a..0225970cb 100644 --- a/nx-X11/programs/Xserver/GL/glx/render2swap.c +++ b/nx-X11/programs/Xserver/GL/glx/render2swap.c @@ -43,7 +43,7 @@ #include "unpack.h" #include "g_disptab.h" #include "g_disptab_EXT.h" - +#include "indirect_size.h" void __glXDispSwap_Map1f(GLbyte *pc) { diff --git a/nx-X11/programs/Xserver/GL/glx/render2swap.c.NX.original b/nx-X11/programs/Xserver/GL/glx/render2swap.c.NX.original new file mode 100644 index 000000000..0225970cb --- /dev/null +++ b/nx-X11/programs/Xserver/GL/glx/render2swap.c.NX.original @@ -0,0 +1,393 @@ +/* $XFree86: xc/programs/Xserver/GL/glx/render2swap.c,v 1.6 2002/01/14 22:47:08 tsi Exp $ */ +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +*/ + +/* #define NEED_REPLIES */ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "glxserver.h" +#include "unpack.h" +#include "g_disptab.h" +#include "g_disptab_EXT.h" +#include "indirect_size.h" + +void __glXDispSwap_Map1f(GLbyte *pc) +{ + GLint order, k; + GLfloat u1, u2, *points; + GLenum target; + GLint compsize; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + + __GLX_SWAP_INT(pc + 0); + __GLX_SWAP_INT(pc + 12); + __GLX_SWAP_FLOAT(pc + 4); + __GLX_SWAP_FLOAT(pc + 8); + + target = *(GLenum *)(pc + 0); + order = *(GLint *)(pc + 12); + u1 = *(GLfloat *)(pc + 4); + u2 = *(GLfloat *)(pc + 8); + points = (GLfloat *)(pc + 16); + k = __glMap1f_size(target); + + if (order <= 0 || k < 0) { + /* Erroneous command. */ + compsize = 0; + } else { + compsize = order * k; + } + __GLX_SWAP_FLOAT_ARRAY(points, compsize); + + glMap1f(target, u1, u2, k, order, points); +} + +void __glXDispSwap_Map2f(GLbyte *pc) +{ + GLint uorder, vorder, ustride, vstride, k; + GLfloat u1, u2, v1, v2, *points; + GLenum target; + GLint compsize; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + + __GLX_SWAP_INT(pc + 0); + __GLX_SWAP_INT(pc + 12); + __GLX_SWAP_INT(pc + 24); + __GLX_SWAP_FLOAT(pc + 4); + __GLX_SWAP_FLOAT(pc + 8); + __GLX_SWAP_FLOAT(pc + 16); + __GLX_SWAP_FLOAT(pc + 20); + + target = *(GLenum *)(pc + 0); + uorder = *(GLint *)(pc + 12); + vorder = *(GLint *)(pc + 24); + u1 = *(GLfloat *)(pc + 4); + u2 = *(GLfloat *)(pc + 8); + v1 = *(GLfloat *)(pc + 16); + v2 = *(GLfloat *)(pc + 20); + points = (GLfloat *)(pc + 28); + + k = __glMap2f_size(target); + ustride = vorder * k; + vstride = k; + + if (vorder <= 0 || uorder <= 0 || k < 0) { + /* Erroneous command. */ + compsize = 0; + } else { + compsize = uorder * vorder * k; + } + __GLX_SWAP_FLOAT_ARRAY(points, compsize); + + glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); +} + +void __glXDispSwap_Map1d(GLbyte *pc) +{ + GLint order, k, compsize; + GLenum target; + GLdouble u1, u2, *points; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + + __GLX_SWAP_DOUBLE(pc + 0); + __GLX_SWAP_DOUBLE(pc + 8); + __GLX_SWAP_INT(pc + 16); + __GLX_SWAP_INT(pc + 20); + + target = *(GLenum*) (pc + 16); + order = *(GLint*) (pc + 20); + k = __glMap1d_size(target); + if (order <= 0 || k < 0) { + /* Erroneous command. */ + compsize = 0; + } else { + compsize = order * k; + } + __GLX_GET_DOUBLE(u1,pc); + __GLX_GET_DOUBLE(u2,pc+8); + __GLX_SWAP_DOUBLE_ARRAY(pc+24, compsize); + pc += 24; + +#ifdef __GLX_ALIGN64 + if (((unsigned long)pc) & 7) { + /* + ** Copy the doubles up 4 bytes, trashing the command but aligning + ** the data in the process + */ + __GLX_MEM_COPY(pc-4, pc, compsize*8); + points = (GLdouble*) (pc - 4); + } else { + points = (GLdouble*) pc; + } +#else + points = (GLdouble*) pc; +#endif + glMap1d(target, u1, u2, k, order, points); +} + +void __glXDispSwap_Map2d(GLbyte *pc) +{ + GLdouble u1, u2, v1, v2, *points; + GLint uorder, vorder, ustride, vstride, k, compsize; + GLenum target; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + + __GLX_SWAP_DOUBLE(pc + 0); + __GLX_SWAP_DOUBLE(pc + 8); + __GLX_SWAP_DOUBLE(pc + 16); + __GLX_SWAP_DOUBLE(pc + 24); + __GLX_SWAP_INT(pc + 32); + __GLX_SWAP_INT(pc + 36); + __GLX_SWAP_INT(pc + 40); + + target = *(GLenum *)(pc + 32); + uorder = *(GLint *)(pc + 36); + vorder = *(GLint *)(pc + 40); + k = __glMap2d_size(target); + if (vorder <= 0 || uorder <= 0 || k < 0) { + /* Erroneous command. */ + compsize = 0; + } else { + compsize = uorder * vorder * k; + } + __GLX_GET_DOUBLE(u1,pc); + __GLX_GET_DOUBLE(u2,pc+8); + __GLX_GET_DOUBLE(v1,pc+16); + __GLX_GET_DOUBLE(v2,pc+24); + __GLX_SWAP_DOUBLE_ARRAY(pc+44, compsize); + pc += 44; + ustride = vorder * k; + vstride = k; + +#ifdef __GLX_ALIGN64 + if (((unsigned long)pc) & 7) { + /* + ** Copy the doubles up 4 bytes, trashing the command but aligning + ** the data in the process + */ + __GLX_MEM_COPY(pc-4, pc, compsize*8); + points = (GLdouble*) (pc - 4); + } else { + points = (GLdouble*) pc; + } +#else + points = (GLdouble*) pc; +#endif + glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); +} + +void __glXDispSwap_CallLists(GLbyte *pc) +{ + GLenum type; + GLsizei n; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + + __GLX_SWAP_INT(pc + 4); + __GLX_SWAP_INT(pc + 0); + type = *(GLenum *)(pc + 4); + n = *(GLsizei *)(pc + 0); + + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_2_BYTES: + case GL_3_BYTES: + case GL_4_BYTES: + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + __GLX_SWAP_SHORT_ARRAY(pc+8, n); + break; + case GL_INT: + case GL_UNSIGNED_INT: + __GLX_SWAP_INT_ARRAY(pc+8, n); + break; + case GL_FLOAT: + __GLX_SWAP_FLOAT_ARRAY(pc+8, n); + break; + } + + glCallLists(n, type, pc+8); +} + +static void swapArray(GLint numVals, GLenum datatype, + GLint stride, GLint numVertexes, GLbyte *pc) +{ + int i,j; + __GLX_DECLARE_SWAP_VARIABLES; + + switch (datatype) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + /* don't need to swap */ + return; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + for (i=0; inumVertexes; + GLint numComponents = hdr->numComponents; + GLenum primType = hdr->primType; + GLint stride = 0; + int i; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_INT(&numVertexes); + __GLX_SWAP_INT(&numComponents); + __GLX_SWAP_INT(&primType); + + pc += sizeof(__GLXdispatchDrawArraysHeader); + compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc; + + /* compute stride (same for all component arrays) */ + for (i=0; i +#endif + +#include "glxserver.h" +#include "unpack.h" +#include "g_disptab.h" +#include "g_disptab_EXT.h" + + +void __glXDispSwap_Map1f(GLbyte *pc) +{ + GLint order, k; + GLfloat u1, u2, *points; + GLenum target; + GLint compsize; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + + __GLX_SWAP_INT(pc + 0); + __GLX_SWAP_INT(pc + 12); + __GLX_SWAP_FLOAT(pc + 4); + __GLX_SWAP_FLOAT(pc + 8); + + target = *(GLenum *)(pc + 0); + order = *(GLint *)(pc + 12); + u1 = *(GLfloat *)(pc + 4); + u2 = *(GLfloat *)(pc + 8); + points = (GLfloat *)(pc + 16); + k = __glMap1f_size(target); + + if (order <= 0 || k < 0) { + /* Erroneous command. */ + compsize = 0; + } else { + compsize = order * k; + } + __GLX_SWAP_FLOAT_ARRAY(points, compsize); + + glMap1f(target, u1, u2, k, order, points); +} + +void __glXDispSwap_Map2f(GLbyte *pc) +{ + GLint uorder, vorder, ustride, vstride, k; + GLfloat u1, u2, v1, v2, *points; + GLenum target; + GLint compsize; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + + __GLX_SWAP_INT(pc + 0); + __GLX_SWAP_INT(pc + 12); + __GLX_SWAP_INT(pc + 24); + __GLX_SWAP_FLOAT(pc + 4); + __GLX_SWAP_FLOAT(pc + 8); + __GLX_SWAP_FLOAT(pc + 16); + __GLX_SWAP_FLOAT(pc + 20); + + target = *(GLenum *)(pc + 0); + uorder = *(GLint *)(pc + 12); + vorder = *(GLint *)(pc + 24); + u1 = *(GLfloat *)(pc + 4); + u2 = *(GLfloat *)(pc + 8); + v1 = *(GLfloat *)(pc + 16); + v2 = *(GLfloat *)(pc + 20); + points = (GLfloat *)(pc + 28); + + k = __glMap2f_size(target); + ustride = vorder * k; + vstride = k; + + if (vorder <= 0 || uorder <= 0 || k < 0) { + /* Erroneous command. */ + compsize = 0; + } else { + compsize = uorder * vorder * k; + } + __GLX_SWAP_FLOAT_ARRAY(points, compsize); + + glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); +} + +void __glXDispSwap_Map1d(GLbyte *pc) +{ + GLint order, k, compsize; + GLenum target; + GLdouble u1, u2, *points; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + + __GLX_SWAP_DOUBLE(pc + 0); + __GLX_SWAP_DOUBLE(pc + 8); + __GLX_SWAP_INT(pc + 16); + __GLX_SWAP_INT(pc + 20); + + target = *(GLenum*) (pc + 16); + order = *(GLint*) (pc + 20); + k = __glMap1d_size(target); + if (order <= 0 || k < 0) { + /* Erroneous command. */ + compsize = 0; + } else { + compsize = order * k; + } + __GLX_GET_DOUBLE(u1,pc); + __GLX_GET_DOUBLE(u2,pc+8); + __GLX_SWAP_DOUBLE_ARRAY(pc+24, compsize); + pc += 24; + +#ifdef __GLX_ALIGN64 + if (((unsigned long)pc) & 7) { + /* + ** Copy the doubles up 4 bytes, trashing the command but aligning + ** the data in the process + */ + __GLX_MEM_COPY(pc-4, pc, compsize*8); + points = (GLdouble*) (pc - 4); + } else { + points = (GLdouble*) pc; + } +#else + points = (GLdouble*) pc; +#endif + glMap1d(target, u1, u2, k, order, points); +} + +void __glXDispSwap_Map2d(GLbyte *pc) +{ + GLdouble u1, u2, v1, v2, *points; + GLint uorder, vorder, ustride, vstride, k, compsize; + GLenum target; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + + __GLX_SWAP_DOUBLE(pc + 0); + __GLX_SWAP_DOUBLE(pc + 8); + __GLX_SWAP_DOUBLE(pc + 16); + __GLX_SWAP_DOUBLE(pc + 24); + __GLX_SWAP_INT(pc + 32); + __GLX_SWAP_INT(pc + 36); + __GLX_SWAP_INT(pc + 40); + + target = *(GLenum *)(pc + 32); + uorder = *(GLint *)(pc + 36); + vorder = *(GLint *)(pc + 40); + k = __glMap2d_size(target); + if (vorder <= 0 || uorder <= 0 || k < 0) { + /* Erroneous command. */ + compsize = 0; + } else { + compsize = uorder * vorder * k; + } + __GLX_GET_DOUBLE(u1,pc); + __GLX_GET_DOUBLE(u2,pc+8); + __GLX_GET_DOUBLE(v1,pc+16); + __GLX_GET_DOUBLE(v2,pc+24); + __GLX_SWAP_DOUBLE_ARRAY(pc+44, compsize); + pc += 44; + ustride = vorder * k; + vstride = k; + +#ifdef __GLX_ALIGN64 + if (((unsigned long)pc) & 7) { + /* + ** Copy the doubles up 4 bytes, trashing the command but aligning + ** the data in the process + */ + __GLX_MEM_COPY(pc-4, pc, compsize*8); + points = (GLdouble*) (pc - 4); + } else { + points = (GLdouble*) pc; + } +#else + points = (GLdouble*) pc; +#endif + glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); +} + +void __glXDispSwap_CallLists(GLbyte *pc) +{ + GLenum type; + GLsizei n; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + + __GLX_SWAP_INT(pc + 4); + __GLX_SWAP_INT(pc + 0); + type = *(GLenum *)(pc + 4); + n = *(GLsizei *)(pc + 0); + + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_2_BYTES: + case GL_3_BYTES: + case GL_4_BYTES: + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + __GLX_SWAP_SHORT_ARRAY(pc+8, n); + break; + case GL_INT: + case GL_UNSIGNED_INT: + __GLX_SWAP_INT_ARRAY(pc+8, n); + break; + case GL_FLOAT: + __GLX_SWAP_FLOAT_ARRAY(pc+8, n); + break; + } + + glCallLists(n, type, pc+8); +} + +static void swapArray(GLint numVals, GLenum datatype, + GLint stride, GLint numVertexes, GLbyte *pc) +{ + int i,j; + __GLX_DECLARE_SWAP_VARIABLES; + + switch (datatype) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + /* don't need to swap */ + return; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + for (i=0; inumVertexes; + GLint numComponents = hdr->numComponents; + GLenum primType = hdr->primType; + GLint stride = 0; + int i; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_INT(&numVertexes); + __GLX_SWAP_INT(&numComponents); + __GLX_SWAP_INT(&primType); + + pc += sizeof(__GLXdispatchDrawArraysHeader); + compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc; + + /* compute stride (same for all component arrays) */ + for (i=0; i