aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/glx
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/glx')
-rw-r--r--xorg-server/glx/glxcmds.c26
-rw-r--r--xorg-server/glx/glxdri.c38
-rw-r--r--xorg-server/glx/glxdri2.c45
-rw-r--r--xorg-server/glx/glxdricommon.c428
-rw-r--r--xorg-server/glx/glxdriswrast.c32
-rw-r--r--xorg-server/glx/glxext.c1232
-rw-r--r--xorg-server/glx/glxscreens.c8
-rw-r--r--xorg-server/glx/indirect_util.c628
-rw-r--r--xorg-server/glx/single2.c790
-rw-r--r--xorg-server/glx/single2swap.c540
-rw-r--r--xorg-server/glx/unpack.h468
-rw-r--r--xorg-server/glx/xfont.c6
12 files changed, 2127 insertions, 2114 deletions
diff --git a/xorg-server/glx/glxcmds.c b/xorg-server/glx/glxcmds.c
index c0e8feec2..0ec118e97 100644
--- a/xorg-server/glx/glxcmds.c
+++ b/xorg-server/glx/glxcmds.c
@@ -200,7 +200,7 @@ __glXContextDestroy(__GLXcontext *context)
static void __glXdirectContextDestroy(__GLXcontext *context)
{
__glXContextDestroy(context);
- xfree(context);
+ free(context);
}
static __GLXcontext *__glXdirectContextCreate(__GLXscreen *screen,
@@ -209,7 +209,7 @@ static __GLXcontext *__glXdirectContextCreate(__GLXscreen *screen,
{
__GLXcontext *context;
- context = xcalloc (1, sizeof (__GLXcontext));
+ context = calloc(1, sizeof (__GLXcontext));
if (context == NULL)
return NULL;
@@ -411,9 +411,9 @@ static int AddCurrentContext(__GLXclientState *cl, __GLXcontext *glxc)
** Didn't find a free slot, so we'll have to grow the table.
*/
if (!num) {
- table = (__GLXcontext **) xalloc(sizeof(__GLXcontext *));
+ table = (__GLXcontext **) malloc(sizeof(__GLXcontext *));
} else {
- table = (__GLXcontext **) xrealloc(table,
+ table = (__GLXcontext **) realloc(table,
(num+1)*sizeof(__GLXcontext *));
}
table[num] = glxc;
@@ -1531,7 +1531,7 @@ DoQueryContext(__GLXclientState *cl, GLXContextID gcId)
reply.n = nProps;
nReplyBytes = reply.length << 2;
- sendBuf = (int *)xalloc((size_t)nReplyBytes);
+ sendBuf = (int *)malloc((size_t)nReplyBytes);
if (sendBuf == NULL) {
return __glXError(GLXBadContext); /* XXX: Is this correct? */
}
@@ -1549,7 +1549,7 @@ DoQueryContext(__GLXclientState *cl, GLXContextID gcId)
WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)&reply);
WriteToClient(client, nReplyBytes, (char *)sendBuf);
}
- xfree((char *)sendBuf);
+ free((char *)sendBuf);
return Success;
}
@@ -1951,9 +1951,9 @@ int __glXDisp_RenderLarge(__GLXclientState *cl, GLbyte *pc)
*/
if (cl->largeCmdBufSize < cmdlen) {
if (!cl->largeCmdBuf) {
- cl->largeCmdBuf = (GLbyte *) xalloc(cmdlen);
+ cl->largeCmdBuf = (GLbyte *) malloc(cmdlen);
} else {
- cl->largeCmdBuf = (GLbyte *) xrealloc(cl->largeCmdBuf, cmdlen);
+ cl->largeCmdBuf = (GLbyte *) realloc(cl->largeCmdBuf, cmdlen);
}
if (!cl->largeCmdBuf) {
return BadAlloc;
@@ -2355,7 +2355,7 @@ int __glXDisp_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
reply.n = n;
/* Allocate buffer to make sure it's a multiple of 4 bytes big.*/
- buf = (char *) xalloc(length << 2);
+ buf = (char *) malloc(length << 2);
if (buf == NULL)
return BadAlloc;
memcpy(buf, pGlxScreen->GLXextensions, n);
@@ -2367,7 +2367,7 @@ int __glXDisp_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
WriteToClient(client, (int)(length << 2), (char *)buf);
}
- xfree(buf);
+ free(buf);
return Success;
}
@@ -2411,7 +2411,7 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc)
reply.length = length;
reply.n = n;
- buf = (char *) xalloc(length << 2);
+ buf = (char *) malloc(length << 2);
if (buf == NULL) {
return BadAlloc;
}
@@ -2424,7 +2424,7 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc)
WriteToClient(client, (int)(length << 2), buf);
}
- xfree(buf);
+ free(buf);
return Success;
}
@@ -2436,7 +2436,7 @@ int __glXDisp_ClientInfo(__GLXclientState *cl, GLbyte *pc)
cl->GLClientmajorVersion = req->major;
cl->GLClientminorVersion = req->minor;
if (cl->GLClientextensions)
- xfree(cl->GLClientextensions);
+ free(cl->GLClientextensions);
buf = (const char *)(req+1);
cl->GLClientextensions = xstrdup(buf);
diff --git a/xorg-server/glx/glxdri.c b/xorg-server/glx/glxdri.c
index 4bb33bff3..e9e7ea5a9 100644
--- a/xorg-server/glx/glxdri.c
+++ b/xorg-server/glx/glxdri.c
@@ -245,7 +245,7 @@ __glXDRIdrawableDestroy(__GLXdrawable *drawable)
__glXDrawableRelease(drawable);
- xfree(private);
+ free(private);
}
static GLboolean
@@ -302,7 +302,7 @@ __glXDRIcontextDestroy(__GLXcontext *baseContext)
__glXleaveServer(GL_FALSE);
__glXContextDestroy(&context->base);
- xfree(context);
+ free(context);
}
static int
@@ -498,7 +498,7 @@ nooverride:
unsigned pitch = PixmapBytePad(pixmap->drawable.width,
pixmap->drawable.depth);
- data = xalloc(pitch * pixmap->drawable.height);
+ data = malloc(pitch * pixmap->drawable.height);
__glXenterServer(GL_FALSE);
pScreen->GetImage(&pixmap->drawable, 0 /*pixmap->drawable.x*/,
@@ -529,7 +529,7 @@ nooverride:
type,
data) );
- xfree(data);
+ free(data);
} else if (!override) {
int i, numRects;
BoxPtr p;
@@ -544,7 +544,7 @@ nooverride:
{
unsigned pitch = PixmapBytePad(p[i].x2 - p[i].x1,
pixmap->drawable.depth);
- void *data = xalloc(pitch * (p[i].y2 - p[i].y1));
+ void *data = malloc(pitch * (p[i].y2 - p[i].y1));
__glXenterServer(GL_FALSE);
pScreen->GetImage(&pixmap->drawable, /*pixmap->drawable.x +*/ p[i].x1,
@@ -570,7 +570,7 @@ nooverride:
type,
data) );
- xfree(data);
+ free(data);
}
}
@@ -610,7 +610,7 @@ __glXDRIscreenDestroy(__GLXscreen *baseScreen)
__glXScreenDestroy(baseScreen);
- xfree(screen);
+ free(screen);
}
static __GLXcontext *
@@ -637,7 +637,7 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
if (baseShareContext && baseShareContext->isDirect)
return NULL;
- context = xcalloc(1, sizeof *context);
+ context = calloc(1, sizeof *context);
if (context == NULL)
return NULL;
@@ -678,7 +678,7 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
__glXenterServer(GL_FALSE);
retval = DRIDestroyContext(baseScreen->pScreen, context->hwContextID);
__glXleaveServer(GL_FALSE);
- xfree(context);
+ free(context);
return NULL;
}
@@ -700,13 +700,13 @@ __glXDRIscreenCreateDrawable(ClientPtr client,
GLboolean retval;
drm_drawable_t hwDrawable;
- private = xcalloc(1, sizeof *private);
+ private = calloc(1, sizeof *private);
if (private == NULL)
return NULL;
if (!__glXDrawableInit(&private->base, screen,
pDraw, type, glxDrawId, glxConfig)) {
- xfree(private);
+ free(private);
return NULL;
}
@@ -722,7 +722,7 @@ __glXDRIscreenCreateDrawable(ClientPtr client,
__glXleaveServer(GL_FALSE);
if (!retval) {
- xfree(private);
+ free(private);
return NULL;
}
@@ -738,7 +738,7 @@ __glXDRIscreenCreateDrawable(ClientPtr client,
__glXenterServer(GL_FALSE);
DRIDestroyDrawable(screen->pScreen, serverClient, pDraw);
__glXleaveServer(GL_FALSE);
- xfree(private);
+ free(private);
return NULL;
}
@@ -775,7 +775,7 @@ getDrawableInfo(__DRIdrawable *driDrawable,
if (retval && *numClipRects > 0) {
size = sizeof (drm_clip_rect_t) * *numClipRects;
- *ppClipRects = xalloc (size);
+ *ppClipRects = malloc(size);
/* Clip cliprects to screen dimensions (redirected windows) */
if (*ppClipRects != NULL) {
@@ -795,7 +795,7 @@ getDrawableInfo(__DRIdrawable *driDrawable,
if (*numClipRects != j) {
*numClipRects = j;
- *ppClipRects = xrealloc (*ppClipRects,
+ *ppClipRects = realloc(*ppClipRects,
sizeof (drm_clip_rect_t) *
*numClipRects);
}
@@ -809,7 +809,7 @@ getDrawableInfo(__DRIdrawable *driDrawable,
if (retval && *numBackClipRects > 0) {
size = sizeof (drm_clip_rect_t) * *numBackClipRects;
- *ppBackClipRects = xalloc (size);
+ *ppBackClipRects = malloc(size);
if (*ppBackClipRects != NULL)
memcpy (*ppBackClipRects, pBackClipRects, size);
else
@@ -980,7 +980,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
return NULL;
}
- screen = xcalloc(1, sizeof *screen);
+ screen = calloc(1, sizeof *screen);
if (screen == NULL)
return NULL;
@@ -1151,7 +1151,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL);
if (buffer_size > 0) {
if (screen->base.GLXextensions != NULL) {
- xfree(screen->base.GLXextensions);
+ free(screen->base.GLXextensions);
}
screen->base.GLXextensions = xnfalloc(buffer_size);
@@ -1186,7 +1186,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
if (screen->driver)
dlclose(screen->driver);
- xfree(screen);
+ free(screen);
LogMessage(X_ERROR, "AIGLX: reverting to software rendering\n");
diff --git a/xorg-server/glx/glxdri2.c b/xorg-server/glx/glxdri2.c
index f1396b54d..a02e71a71 100644
--- a/xorg-server/glx/glxdri2.c
+++ b/xorg-server/glx/glxdri2.c
@@ -107,7 +107,7 @@ __glXDRIdrawableDestroy(__GLXdrawable *drawable)
__glXDrawableRelease(drawable);
- xfree(private);
+ free(private);
}
static void
@@ -248,7 +248,7 @@ __glXDRIcontextDestroy(__GLXcontext *baseContext)
(*screen->core->destroyContext)(context->driContext);
__glXContextDestroy(&context->base);
- xfree(context);
+ free(context);
}
static int
@@ -386,7 +386,7 @@ __glXDRIscreenDestroy(__GLXscreen *baseScreen)
__glXScreenDestroy(baseScreen);
- xfree(screen);
+ free(screen);
}
static __GLXcontext *
@@ -405,7 +405,7 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
else
driShare = NULL;
- context = xcalloc(1, sizeof *context);
+ context = calloc(1, sizeof *context);
if (context == NULL)
return NULL;
@@ -422,13 +422,24 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
config->driConfig,
driShare, context);
if (context->driContext == NULL) {
- xfree(context);
+ free(context);
return NULL;
}
return &context->base;
}
+static void
+__glXDRIinvalidateBuffers(DrawablePtr pDraw, void *priv)
+{
+#if __DRI2_FLUSH_VERSION >= 3
+ __GLXDRIdrawable *private = priv;
+ __GLXDRIscreen *screen = private->screen;
+
+ (*screen->flush->invalidate)(private->driDrawable);
+#endif
+}
+
static __GLXdrawable *
__glXDRIscreenCreateDrawable(ClientPtr client,
__GLXscreen *screen,
@@ -442,14 +453,14 @@ __glXDRIscreenCreateDrawable(ClientPtr client,
__GLXDRIconfig *config = (__GLXDRIconfig *) glxConfig;
__GLXDRIdrawable *private;
- private = xcalloc(1, sizeof *private);
+ private = calloc(1, sizeof *private);
if (private == NULL)
return NULL;
private->screen = driScreen;
if (!__glXDrawableInit(&private->base, screen,
pDraw, type, glxDrawId, glxConfig)) {
- xfree(private);
+ free(private);
return NULL;
}
@@ -459,8 +470,9 @@ __glXDRIscreenCreateDrawable(ClientPtr client,
private->base.waitGL = __glXDRIdrawableWaitGL;
private->base.waitX = __glXDRIdrawableWaitX;
- if (DRI2CreateDrawable(client, pDraw, drawId)) {
- xfree(private);
+ if (DRI2CreateDrawable(client, pDraw, drawId,
+ __glXDRIinvalidateBuffers, private)) {
+ free(private);
return NULL;
}
@@ -573,9 +585,18 @@ static const __DRIdri2LoaderExtension loaderExtension = {
dri2GetBuffersWithFormat,
};
+#ifdef __DRI_USE_INVALIDATE
+static const __DRIuseInvalidateExtension dri2UseInvalidate = {
+ { __DRI_USE_INVALIDATE, __DRI_USE_INVALIDATE_VERSION }
+};
+#endif
+
static const __DRIextension *loader_extensions[] = {
&systemTimeExtension.base,
&loaderExtension.base,
+#ifdef __DRI_USE_INVALIDATE
+ &dri2UseInvalidate,
+#endif
NULL
};
@@ -676,7 +697,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
const __DRIconfig **driConfigs;
int i;
- screen = xcalloc(1, sizeof *screen);
+ screen = calloc(1, sizeof *screen);
if (screen == NULL)
return NULL;
@@ -759,7 +780,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL);
if (buffer_size > 0) {
if (screen->base.GLXextensions != NULL) {
- xfree(screen->base.GLXextensions);
+ free(screen->base.GLXextensions);
}
screen->base.GLXextensions = xnfalloc(buffer_size);
@@ -793,7 +814,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
if (screen->driver)
dlclose(screen->driver);
- xfree(screen);
+ free(screen);
LogMessage(X_ERROR, "AIGLX: reverting to software rendering\n");
diff --git a/xorg-server/glx/glxdricommon.c b/xorg-server/glx/glxdricommon.c
index a68566c07..5b12520d3 100644
--- a/xorg-server/glx/glxdricommon.c
+++ b/xorg-server/glx/glxdricommon.c
@@ -1,214 +1,214 @@
-/*
- * Copyright © 2008 Red Hat, Inc
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of the
- * copyright holders not be used in advertising or publicity
- * pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#else
-
-#include "glheader.h"
-
-#endif
-
-#include <stdint.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <GL/gl.h>
-#include <GL/glxtokens.h>
-#include <GL/internal/dri_interface.h>
-#include <os.h>
-#include "glxserver.h"
-#include "glxcontext.h"
-#include "glxscreens.h"
-#include "glxdricommon.h"
-
-static int
-getUST(int64_t *ust)
-{
- struct timeval tv;
-
- if (ust == NULL)
- return -EFAULT;
-
-#ifdef _MSC_VER
- __asm int 3;
-#else
- if (gettimeofday(&tv, NULL) == 0) {
- ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
- return 0;
- } else {
- return -errno;
- }
- #endif
-}
-
-const __DRIsystemTimeExtension systemTimeExtension = {
- { __DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION },
- getUST,
- NULL,
-};
-
-#define __ATTRIB(attrib, field) \
- { attrib, offsetof(__GLXconfig, field) }
-
-static const struct { unsigned int attrib, offset; } attribMap[] = {
- __ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits),
- __ATTRIB(__DRI_ATTRIB_LEVEL, level),
- __ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits),
- __ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits),
- __ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits),
- __ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits),
- __ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits),
- __ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits),
- __ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits),
- __ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits),
- __ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits),
- __ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits),
- __ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers),
- __ATTRIB(__DRI_ATTRIB_SAMPLES, samples),
- __ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode),
- __ATTRIB(__DRI_ATTRIB_STEREO, stereoMode),
- __ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers),
- __ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel),
- __ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentPixel),
- __ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed),
- __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen),
- __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue),
- __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha),
- __ATTRIB(__DRI_ATTRIB_RED_MASK, redMask),
- __ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask),
- __ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask),
- __ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask),
- __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth),
- __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight),
- __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels),
- __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth),
- __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight),
- __ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod),
- __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
- __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba),
- __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE, bindToMipmapTexture),
- __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),
-};
-
-#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
-
-static void
-setScalar(__GLXconfig *config, unsigned int attrib, unsigned int value)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(attribMap); i++)
- if (attribMap[i].attrib == attrib) {
- *(unsigned int *) ((char *) config + attribMap[i].offset) = value;
- return;
- }
-}
-
-static __GLXconfig *
-createModeFromConfig(const __DRIcoreExtension *core,
- const __DRIconfig *driConfig,
- unsigned int visualType, unsigned int drawableType)
-{
- __GLXDRIconfig *config;
- unsigned int attrib, value;
- int i;
-
- config = xalloc(sizeof *config);
-
- config->driConfig = driConfig;
-
- i = 0;
- while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) {
- switch (attrib) {
- case __DRI_ATTRIB_RENDER_TYPE:
- config->config.renderType = 0;
- if (value & __DRI_ATTRIB_RGBA_BIT)
- config->config.renderType |= GLX_RGBA_BIT;
- if (value & __DRI_ATTRIB_COLOR_INDEX_BIT)
- config->config.renderType |= GLX_COLOR_INDEX_BIT;
- break;
- case __DRI_ATTRIB_CONFIG_CAVEAT:
- if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG)
- config->config.visualRating = GLX_NON_CONFORMANT_CONFIG;
- else if (value & __DRI_ATTRIB_SLOW_BIT)
- config->config.visualRating = GLX_SLOW_CONFIG;
- else
- config->config.visualRating = GLX_NONE;
- break;
- case __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS:
- config->config.bindToTextureTargets = 0;
- if (value & __DRI_ATTRIB_TEXTURE_1D_BIT)
- config->config.bindToTextureTargets |= GLX_TEXTURE_1D_BIT_EXT;
- if (value & __DRI_ATTRIB_TEXTURE_2D_BIT)
- config->config.bindToTextureTargets |= GLX_TEXTURE_2D_BIT_EXT;
- if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT)
- config->config.bindToTextureTargets |= GLX_TEXTURE_RECTANGLE_BIT_EXT;
- break;
- default:
- setScalar(&config->config, attrib, value);
- break;
- }
- }
-
- config->config.next = NULL;
- config->config.xRenderable = GL_TRUE;
- config->config.visualType = visualType;
- config->config.drawableType = drawableType;
-
- return &config->config;
-}
-
-__GLXconfig *
-glxConvertConfigs(const __DRIcoreExtension *core,
- const __DRIconfig **configs, unsigned int drawableType)
-{
- __GLXconfig head, *tail;
- int i;
-
- tail = &head;
- head.next = NULL;
-
- for (i = 0; configs[i]; i++) {
- tail->next = createModeFromConfig(core,
- configs[i], GLX_TRUE_COLOR,
- drawableType);
- if (tail->next == NULL)
- break;
-
- tail = tail->next;
- }
-
- for (i = 0; configs[i]; i++) {
- tail->next = createModeFromConfig(core,
- configs[i], GLX_DIRECT_COLOR,
- drawableType);
- if (tail->next == NULL)
- break;
-
- tail = tail->next;
- }
-
- return head.next;
-}
+/*
+ * Copyright © 2008 Red Hat, Inc
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#else
+
+#include "glheader.h"
+
+#endif
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <GL/gl.h>
+#include <GL/glxtokens.h>
+#include <GL/internal/dri_interface.h>
+#include <os.h>
+#include "glxserver.h"
+#include "glxcontext.h"
+#include "glxscreens.h"
+#include "glxdricommon.h"
+
+static int
+getUST(int64_t *ust)
+{
+ struct timeval tv;
+
+ if (ust == NULL)
+ return -EFAULT;
+
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ if (gettimeofday(&tv, NULL) == 0) {
+ ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
+ return 0;
+ } else {
+ return -errno;
+ }
+ #endif
+}
+
+const __DRIsystemTimeExtension systemTimeExtension = {
+ { __DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION },
+ getUST,
+ NULL,
+};
+
+#define __ATTRIB(attrib, field) \
+ { attrib, offsetof(__GLXconfig, field) }
+
+static const struct { unsigned int attrib, offset; } attribMap[] = {
+ __ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits),
+ __ATTRIB(__DRI_ATTRIB_LEVEL, level),
+ __ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits),
+ __ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits),
+ __ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits),
+ __ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits),
+ __ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits),
+ __ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits),
+ __ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits),
+ __ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits),
+ __ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits),
+ __ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits),
+ __ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers),
+ __ATTRIB(__DRI_ATTRIB_SAMPLES, samples),
+ __ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode),
+ __ATTRIB(__DRI_ATTRIB_STEREO, stereoMode),
+ __ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers),
+ __ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel),
+ __ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentPixel),
+ __ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed),
+ __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen),
+ __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue),
+ __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha),
+ __ATTRIB(__DRI_ATTRIB_RED_MASK, redMask),
+ __ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask),
+ __ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask),
+ __ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask),
+ __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth),
+ __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight),
+ __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels),
+ __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth),
+ __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight),
+ __ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod),
+ __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
+ __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba),
+ __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE, bindToMipmapTexture),
+ __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),
+};
+
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
+static void
+setScalar(__GLXconfig *config, unsigned int attrib, unsigned int value)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(attribMap); i++)
+ if (attribMap[i].attrib == attrib) {
+ *(unsigned int *) ((char *) config + attribMap[i].offset) = value;
+ return;
+ }
+}
+
+static __GLXconfig *
+createModeFromConfig(const __DRIcoreExtension *core,
+ const __DRIconfig *driConfig,
+ unsigned int visualType, unsigned int drawableType)
+{
+ __GLXDRIconfig *config;
+ unsigned int attrib, value;
+ int i;
+
+ config = malloc(sizeof *config);
+
+ config->driConfig = driConfig;
+
+ i = 0;
+ while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) {
+ switch (attrib) {
+ case __DRI_ATTRIB_RENDER_TYPE:
+ config->config.renderType = 0;
+ if (value & __DRI_ATTRIB_RGBA_BIT)
+ config->config.renderType |= GLX_RGBA_BIT;
+ if (value & __DRI_ATTRIB_COLOR_INDEX_BIT)
+ config->config.renderType |= GLX_COLOR_INDEX_BIT;
+ break;
+ case __DRI_ATTRIB_CONFIG_CAVEAT:
+ if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG)
+ config->config.visualRating = GLX_NON_CONFORMANT_CONFIG;
+ else if (value & __DRI_ATTRIB_SLOW_BIT)
+ config->config.visualRating = GLX_SLOW_CONFIG;
+ else
+ config->config.visualRating = GLX_NONE;
+ break;
+ case __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS:
+ config->config.bindToTextureTargets = 0;
+ if (value & __DRI_ATTRIB_TEXTURE_1D_BIT)
+ config->config.bindToTextureTargets |= GLX_TEXTURE_1D_BIT_EXT;
+ if (value & __DRI_ATTRIB_TEXTURE_2D_BIT)
+ config->config.bindToTextureTargets |= GLX_TEXTURE_2D_BIT_EXT;
+ if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT)
+ config->config.bindToTextureTargets |= GLX_TEXTURE_RECTANGLE_BIT_EXT;
+ break;
+ default:
+ setScalar(&config->config, attrib, value);
+ break;
+ }
+ }
+
+ config->config.next = NULL;
+ config->config.xRenderable = GL_TRUE;
+ config->config.visualType = visualType;
+ config->config.drawableType = drawableType;
+
+ return &config->config;
+}
+
+__GLXconfig *
+glxConvertConfigs(const __DRIcoreExtension *core,
+ const __DRIconfig **configs, unsigned int drawableType)
+{
+ __GLXconfig head, *tail;
+ int i;
+
+ tail = &head;
+ head.next = NULL;
+
+ for (i = 0; configs[i]; i++) {
+ tail->next = createModeFromConfig(core,
+ configs[i], GLX_TRUE_COLOR,
+ drawableType);
+ if (tail->next == NULL)
+ break;
+
+ tail = tail->next;
+ }
+
+ for (i = 0; configs[i]; i++) {
+ tail->next = createModeFromConfig(core,
+ configs[i], GLX_DIRECT_COLOR,
+ drawableType);
+ if (tail->next == NULL)
+ break;
+
+ tail = tail->next;
+ }
+
+ return head.next;
+}
diff --git a/xorg-server/glx/glxdriswrast.c b/xorg-server/glx/glxdriswrast.c
index 3852b5243..ed4b373c7 100644
--- a/xorg-server/glx/glxdriswrast.c
+++ b/xorg-server/glx/glxdriswrast.c
@@ -112,7 +112,7 @@ __glXDRIdrawableDestroy(__GLXdrawable *drawable)
__glXDrawableRelease(drawable);
- xfree(private);
+ free(private);
}
static GLboolean
@@ -146,7 +146,7 @@ __glXDRIcontextDestroy(__GLXcontext *baseContext)
(*screen->core->destroyContext)(context->driContext);
__glXContextDestroy(&context->base);
- xfree(context);
+ free(context);
}
static int
@@ -266,7 +266,7 @@ __glXDRIscreenDestroy(__GLXscreen *baseScreen)
__glXScreenDestroy(baseScreen);
- xfree(screen);
+ free(screen);
}
static __GLXcontext *
@@ -286,7 +286,7 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
else
driShare = NULL;
- context = xcalloc(1, sizeof *context);
+ context = calloc(1, sizeof *context);
if (context == NULL)
return NULL;
@@ -304,14 +304,6 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
return &context->base;
}
-static void
-glxChangeGC(GCPtr gc, BITS32 mask, CARD32 val)
-{
- CARD32 v[1];
- v[0] = val;
- dixChangeGC(NullClient, gc, mask, v, NULL);
-}
-
static __GLXdrawable *
__glXDRIscreenCreateDrawable(ClientPtr client,
__GLXscreen *screen,
@@ -321,20 +313,21 @@ __glXDRIscreenCreateDrawable(ClientPtr client,
XID glxDrawId,
__GLXconfig *glxConfig)
{
+ ChangeGCVal gcvals[2];
__GLXDRIscreen *driScreen = (__GLXDRIscreen *) screen;
__GLXDRIconfig *config = (__GLXDRIconfig *) glxConfig;
__GLXDRIdrawable *private;
ScreenPtr pScreen = driScreen->base.pScreen;
- private = xcalloc(1, sizeof *private);
+ private = calloc(1, sizeof *private);
if (private == NULL)
return NULL;
private->screen = driScreen;
if (!__glXDrawableInit(&private->base, screen,
pDraw, type, glxDrawId, glxConfig)) {
- xfree(private);
+ free(private);
return NULL;
}
@@ -345,9 +338,10 @@ __glXDRIscreenCreateDrawable(ClientPtr client,
private->gc = CreateScratchGC(pScreen, pDraw->depth);
private->swapgc = CreateScratchGC(pScreen, pDraw->depth);
- glxChangeGC(private->gc, GCFunction, GXcopy);
- glxChangeGC(private->swapgc, GCFunction, GXcopy);
- glxChangeGC(private->swapgc, GCGraphicsExposures, FALSE);
+ gcvals[0].val = GXcopy;
+ ChangeGC(NullClient, private->gc, GCFunction, gcvals);
+ gcvals[1].val = FALSE;
+ ChangeGC(NullClient, private->gc, GCFunction | GCGraphicsExposures, gcvals);
private->driDrawable =
(*driScreen->swrast->createNewDrawable)(driScreen->driScreen,
@@ -462,7 +456,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
const __DRIconfig **driConfigs;
int i;
- screen = xcalloc(1, sizeof *screen);
+ screen = calloc(1, sizeof *screen);
if (screen == NULL)
return NULL;
@@ -559,7 +553,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
dlclose(screen->driver);
#endif
- xfree(screen);
+ free(screen);
LogMessage(X_ERROR, "GLX: could not load software renderer\n");
diff --git a/xorg-server/glx/glxext.c b/xorg-server/glx/glxext.c
index 53838077a..1f2174e93 100644
--- a/xorg-server/glx/glxext.c
+++ b/xorg-server/glx/glxext.c
@@ -1,616 +1,616 @@
-/*
- * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
- * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice including the dates of first publication and
- * either this permission notice or a reference to
- * http://oss.sgi.com/projects/FreeB/
- * 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
- * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
- * shall not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization from
- * Silicon Graphics, Inc.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#else
-
-#include "glheader.h"
-
-#endif
-
-#include <string.h>
-#include "glxserver.h"
-#include <windowstr.h>
-#include <propertyst.h>
-#include <registry.h>
-#include "privates.h"
-#include <os.h>
-#include "g_disptab.h"
-#include "unpack.h"
-#include "glxutil.h"
-#include "glxext.h"
-#include "indirect_table.h"
-#include "indirect_util.h"
-
-/*
-** The last context used by the server. It is the context that is current
-** from the server's perspective.
-*/
-__GLXcontext *__glXLastContext;
-__GLXcontext *__glXContextList;
-
-/*
-** X resources.
-*/
-RESTYPE __glXContextRes;
-RESTYPE __glXDrawableRes;
-RESTYPE __glXSwapBarrierRes;
-
-/*
-** Reply for most singles.
-*/
-xGLXSingleReply __glXReply;
-
-static int glxClientPrivateKeyIndex;
-static DevPrivateKey glxClientPrivateKey = &glxClientPrivateKeyIndex;
-
-/*
-** Client that called into GLX dispatch.
-*/
-ClientPtr __pGlxClient;
-
-/*
-** Forward declarations.
-*/
-static int __glXDispatch(ClientPtr);
-
-/*
-** Called when the extension is reset.
-*/
-static void ResetExtension(ExtensionEntry* extEntry)
-{
- __glXFlushContextCache();
-}
-
-/*
-** Reset state used to keep track of large (multi-request) commands.
-*/
-void __glXResetLargeCommandStatus(__GLXclientState *cl)
-{
- cl->largeCmdBytesSoFar = 0;
- cl->largeCmdBytesTotal = 0;
- cl->largeCmdRequestsSoFar = 0;
- cl->largeCmdRequestsTotal = 0;
-}
-
-/*
-** This procedure is called when the client who created the context goes
-** away OR when glXDestroyContext is called. In either case, all we do is
-** flag that the ID is no longer valid, and (maybe) free the context.
-** use.
-*/
-static int ContextGone(__GLXcontext* cx, XID id)
-{
- cx->idExists = GL_FALSE;
- if (!cx->isCurrent) {
- __glXFreeContext(cx);
- }
-
- return True;
-}
-
-static __GLXcontext *glxPendingDestroyContexts;
-static __GLXcontext *glxAllContexts;
-static int glxServerLeaveCount;
-static int glxBlockClients;
-
-/*
-** Destroy routine that gets called when a drawable is freed. A drawable
-** contains the ancillary buffers needed for rendering.
-*/
-static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid)
-{
- __GLXcontext *c;
- __GLXcontext *cnext;
-
- /* If this drawable was created using glx 1.3 drawable
- * constructors, we added it as a glx drawable resource under both
- * its glx drawable ID and it X drawable ID. Remove the other
- * resource now so we don't a callback for freed memory. */
- if (glxPriv->drawId != glxPriv->pDraw->id) {
- if (xid == glxPriv->drawId)
- FreeResourceByType(glxPriv->pDraw->id, __glXDrawableRes, TRUE);
- else
- FreeResourceByType(glxPriv->drawId, __glXDrawableRes, TRUE);
- }
-
- for (c = glxAllContexts; c; c = cnext) {
- cnext=c->next; /* Save because c is going to be freed */
- if (c->isCurrent && (c->drawPriv == glxPriv || c->readPriv == glxPriv)) {
- int i;
-
- (*c->loseCurrent)(c);
- c->isCurrent = GL_FALSE;
- if (c == __glXLastContext)
- __glXFlushContextCache();
-
- for (i = 1; i < currentMaxClients; i++) {
- if (clients[i]) {
- __GLXclientState *cl = glxGetClient(clients[i]);
-
- if (cl->inUse) {
- int j;
-
- for (j = 0; j < cl->numCurrentContexts; j++) {
- if (cl->currentContexts[j] == c)
- cl->currentContexts[j] = NULL;
- }
- }
- }
- }
-
- if (!c->idExists) {
- __glXFreeContext(c);
- }
- }
- if (c->drawPriv == glxPriv)
- c->drawPriv = NULL;
- if (c->readPriv == glxPriv)
- c->readPriv = NULL;
- }
-
- glxPriv->destroy(glxPriv);
-
- return True;
-}
-
-void __glXAddToContextList(__GLXcontext *cx)
-{
- cx->next = glxAllContexts;
- glxAllContexts = cx;
-}
-
-static void __glXRemoveFromContextList(__GLXcontext *cx)
-{
- __GLXcontext *c, *prev;
-
- if (cx == glxAllContexts)
- glxAllContexts = cx->next;
- else {
- prev = glxAllContexts;
- for (c = glxAllContexts; c; c = c->next) {
- if (c == cx)
- prev->next = c->next;
- prev = c;
- }
- }
-}
-
-/*
-** Free a context.
-*/
-GLboolean __glXFreeContext(__GLXcontext *cx)
-{
- if (cx->idExists || cx->isCurrent) return GL_FALSE;
-
- if (cx->feedbackBuf) xfree(cx->feedbackBuf);
- if (cx->selectBuf) xfree(cx->selectBuf);
- if (cx == __glXLastContext) {
- __glXFlushContextCache();
- }
-
- __glXRemoveFromContextList(cx);
-
- /* We can get here through both regular dispatching from
- * __glXDispatch() or as a callback from the resource manager. In
- * the latter case we need to lift the DRI lock manually. */
-
- if (!glxBlockClients) {
- __glXleaveServer(GL_FALSE);
- cx->destroy(cx);
- __glXenterServer(GL_FALSE);
- } else {
- cx->next = glxPendingDestroyContexts;
- glxPendingDestroyContexts = cx;
- }
-
- return GL_TRUE;
-}
-
-extern RESTYPE __glXSwapBarrierRes;
-
-static int SwapBarrierGone(int screen, XID drawable)
-{
- __GLXscreen *pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
-
- if (pGlxScreen->swapBarrierFuncs) {
- pGlxScreen->swapBarrierFuncs->bindSwapBarrierFunc(screen, drawable, 0);
- }
- FreeResourceByType(drawable, __glXSwapBarrierRes, FALSE);
- return True;
-}
-
-/************************************************************************/
-
-/*
-** These routines can be used to check whether a particular GL command
-** has caused an error. Specifically, we use them to check whether a
-** given query has caused an error, in which case a zero-length data
-** reply is sent to the client.
-*/
-
-static GLboolean errorOccured = GL_FALSE;
-
-/*
-** The GL was will call this routine if an error occurs.
-*/
-void __glXErrorCallBack(GLenum code)
-{
- errorOccured = GL_TRUE;
-}
-
-/*
-** Clear the error flag before calling the GL command.
-*/
-void __glXClearErrorOccured(void)
-{
- errorOccured = GL_FALSE;
-}
-
-/*
-** Check if the GL command caused an error.
-*/
-GLboolean __glXErrorOccured(void)
-{
- return errorOccured;
-}
-
-static int __glXErrorBase;
-int __glXEventBase;
-
-int __glXError(int error)
-{
- return __glXErrorBase + error;
-}
-
-__GLXclientState *
-glxGetClient(ClientPtr pClient)
-{
- return dixLookupPrivate(&pClient->devPrivates, glxClientPrivateKey);
-}
-
-static void
-glxClientCallback (CallbackListPtr *list,
- pointer closure,
- pointer data)
-{
- NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
- ClientPtr pClient = clientinfo->client;
- __GLXclientState *cl = glxGetClient(pClient);
- __GLXcontext *cx;
- int i;
-
- switch (pClient->clientState) {
- case ClientStateRunning:
- /*
- ** By default, assume that the client supports
- ** GLX major version 1 minor version 0 protocol.
- */
- cl->GLClientmajorVersion = 1;
- cl->GLClientminorVersion = 0;
- cl->client = pClient;
- break;
-
- case ClientStateGone:
- for (i = 0; i < cl->numCurrentContexts; i++) {
- cx = cl->currentContexts[i];
- if (cx) {
- cx->isCurrent = GL_FALSE;
- if (!cx->idExists)
- __glXFreeContext(cx);
- }
- }
-
- if (cl->returnBuf) xfree(cl->returnBuf);
- if (cl->largeCmdBuf) xfree(cl->largeCmdBuf);
- if (cl->currentContexts) xfree(cl->currentContexts);
- if (cl->GLClientextensions) xfree(cl->GLClientextensions);
- break;
-
- default:
- break;
- }
-}
-
-/************************************************************************/
-
-static __GLXprovider *__glXProviderStack;
-
-void GlxPushProvider(__GLXprovider *provider)
-{
- provider->next = __glXProviderStack;
- __glXProviderStack = provider;
-}
-
-/*
-** Initialize the GLX extension.
-*/
-void GlxExtensionInit(void)
-{
- ExtensionEntry *extEntry;
- ScreenPtr pScreen;
- int i;
- __GLXprovider *p;
- Bool glx_provided = False;
-
- __glXContextRes = CreateNewResourceType((DeleteType)ContextGone,
- "GLXContext");
- __glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone,
- "GLXDrawable");
- __glXSwapBarrierRes = CreateNewResourceType((DeleteType)SwapBarrierGone,
- "GLXSwapBarrier");
- if (!__glXContextRes || !__glXDrawableRes || !__glXSwapBarrierRes)
- return;
-
- if (!dixRequestPrivate(glxClientPrivateKey, sizeof (__GLXclientState)))
- return;
- if (!AddCallback (&ClientStateCallback, glxClientCallback, 0))
- return;
-
- for (i = 0; i < screenInfo.numScreens; i++) {
- pScreen = screenInfo.screens[i];
-
- for (p = __glXProviderStack; p != NULL; p = p->next) {
- __GLXscreen *glxScreen;
-
- glxScreen = p->screenProbe(pScreen);
- if (glxScreen != NULL) {
- if (glxScreen->GLXminor < glxMinorVersion)
- glxMinorVersion = glxScreen->GLXminor;
- LogMessage(X_INFO,
- "GLX: Initialized %s GL provider for screen %d\n",
- p->name, i);
- break;
- }
-
- }
-
- if (!p)
- LogMessage(X_INFO,
- "GLX: no usable GL providers found for screen %d\n", i);
- else
- glx_provided = True;
- }
-
- /* don't register extension if GL is not provided on any screen */
- if (!glx_provided)
- return;
-
- /*
- ** Add extension to server extensions.
- */
- extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS,
- __GLX_NUMBER_ERRORS, __glXDispatch,
- __glXDispatch, ResetExtension,
- StandardMinorOpcode);
- if (!extEntry) {
- FatalError("__glXExtensionInit: AddExtensions failed\n");
- return;
- }
- if (!AddExtensionAlias(GLX_EXTENSION_ALIAS, extEntry)) {
- ErrorF("__glXExtensionInit: AddExtensionAlias failed\n");
- return;
- }
-
- __glXErrorBase = extEntry->errorBase;
- __glXEventBase = extEntry->eventBase;
-}
-
-/************************************************************************/
-
-void __glXFlushContextCache(void)
-{
- __glXLastContext = 0;
-}
-
-/*
-** Make a context the current one for the GL (in this implementation, there
-** is only one instance of the GL, and we use it to serve all GL clients by
-** switching it between different contexts). While we are at it, look up
-** a context by its tag and return its (__GLXcontext *).
-*/
-__GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag,
- int *error)
-{
- __GLXcontext *cx;
-
- /*
- ** See if the context tag is legal; it is managed by the extension,
- ** so if it's invalid, we have an implementation error.
- */
- cx = (__GLXcontext *) __glXLookupContextByTag(cl, tag);
- if (!cx) {
- cl->client->errorValue = tag;
- *error = __glXError(GLXBadContextTag);
- return 0;
- }
-
- if (!cx->isDirect) {
- if (cx->drawPriv == NULL) {
- /*
- ** The drawable has vanished. It must be a window, because only
- ** windows can be destroyed from under us; GLX pixmaps are
- ** refcounted and don't go away until no one is using them.
- */
- *error = __glXError(GLXBadCurrentWindow);
- return 0;
- }
- }
-
- if (cx->wait && (*cx->wait)(cx, cl, error))
- return NULL;
-
- if (cx == __glXLastContext) {
- /* No need to re-bind */
- return cx;
- }
-
- /* Make this context the current one for the GL. */
- if (!cx->isDirect) {
- if (!(*cx->forceCurrent)(cx)) {
- /* Bind failed, and set the error code. Bummer */
- cl->client->errorValue = cx->id;
- *error = __glXError(GLXBadContextState);
- return 0;
- }
- }
- __glXLastContext = cx;
- return cx;
-}
-
-/************************************************************************/
-
-void glxSuspendClients(void)
-{
- int i;
-
- for (i = 1; i < currentMaxClients; i++) {
- if (clients[i] && glxGetClient(clients[i])->inUse)
- IgnoreClient(clients[i]);
- }
-
- glxBlockClients = TRUE;
-}
-
-void glxResumeClients(void)
-{
- __GLXcontext *cx, *next;
- int i;
-
- glxBlockClients = FALSE;
-
- for (i = 1; i < currentMaxClients; i++) {
- if (clients[i] && glxGetClient(clients[i])->inUse)
- AttendClient(clients[i]);
- }
-
- __glXleaveServer(GL_FALSE);
- for (cx = glxPendingDestroyContexts; cx != NULL; cx = next) {
- next = cx->next;
-
- cx->destroy(cx);
- }
- glxPendingDestroyContexts = NULL;
- __glXenterServer(GL_FALSE);
-}
-
-static void
-__glXnopEnterServer(GLboolean rendering)
-{
-}
-
-static void
-__glXnopLeaveServer(GLboolean rendering)
-{
-}
-
-static void (*__glXenterServerFunc)(GLboolean) = __glXnopEnterServer;
-static void (*__glXleaveServerFunc)(GLboolean) = __glXnopLeaveServer;
-
-void __glXsetEnterLeaveServerFuncs(void (*enter)(GLboolean),
- void (*leave)(GLboolean))
-{
- __glXenterServerFunc = enter;
- __glXleaveServerFunc = leave;
-}
-
-
-void __glXenterServer(GLboolean rendering)
-{
- glxServerLeaveCount--;
-
- if (glxServerLeaveCount == 0)
- (*__glXenterServerFunc)(rendering);
-}
-
-void __glXleaveServer(GLboolean rendering)
-{
- if (glxServerLeaveCount == 0)
- (*__glXleaveServerFunc)(rendering);
-
- glxServerLeaveCount++;
-}
-
-/*
-** Top level dispatcher; all commands are executed from here down.
-*/
-static int __glXDispatch(ClientPtr client)
-{
- REQUEST(xGLXSingleReq);
- CARD8 opcode;
- __GLXdispatchSingleProcPtr proc;
- __GLXclientState *cl;
- int retval;
-
- opcode = stuff->glxCode;
- cl = glxGetClient(client);
- /* Mark it in use so we suspend it on VT switch. */
- cl->inUse = TRUE;
-
- /*
- ** If we're expecting a glXRenderLarge request, this better be one.
- */
- if ((cl->largeCmdRequestsSoFar != 0) && (opcode != X_GLXRenderLarge)) {
- client->errorValue = stuff->glxCode;
- return __glXError(GLXBadLargeRequest);
- }
-
- /* If we're currently blocking GLX clients, just put this guy to
- * sleep, reset the request and return. */
- if (glxBlockClients) {
- ResetCurrentRequest(client);
- client->sequence--;
- IgnoreClient(client);
- return(client->noClientException);
- }
-
- /*
- ** Use the opcode to index into the procedure table.
- */
- proc = (__GLXdispatchSingleProcPtr) __glXGetProtocolDecodeFunction(& Single_dispatch_info,
- opcode,
- client->swapped);
- if (proc != NULL) {
- GLboolean rendering = opcode <= X_GLXRenderLarge;
- __glXleaveServer(rendering);
-
- __pGlxClient = client;
-
- retval = (*proc)(cl, (GLbyte *) stuff);
-
- __glXenterServer(rendering);
- }
- else {
- retval = BadRequest;
- }
-
- return retval;
-}
+/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#else
+
+#include "glheader.h"
+
+#endif
+
+#include <string.h>
+#include "glxserver.h"
+#include <windowstr.h>
+#include <propertyst.h>
+#include <registry.h>
+#include "privates.h"
+#include <os.h>
+#include "g_disptab.h"
+#include "unpack.h"
+#include "glxutil.h"
+#include "glxext.h"
+#include "indirect_table.h"
+#include "indirect_util.h"
+
+/*
+** The last context used by the server. It is the context that is current
+** from the server's perspective.
+*/
+__GLXcontext *__glXLastContext;
+__GLXcontext *__glXContextList;
+
+/*
+** X resources.
+*/
+RESTYPE __glXContextRes;
+RESTYPE __glXDrawableRes;
+RESTYPE __glXSwapBarrierRes;
+
+/*
+** Reply for most singles.
+*/
+xGLXSingleReply __glXReply;
+
+static int glxClientPrivateKeyIndex;
+static DevPrivateKey glxClientPrivateKey = &glxClientPrivateKeyIndex;
+
+/*
+** Client that called into GLX dispatch.
+*/
+ClientPtr __pGlxClient;
+
+/*
+** Forward declarations.
+*/
+static int __glXDispatch(ClientPtr);
+
+/*
+** Called when the extension is reset.
+*/
+static void ResetExtension(ExtensionEntry* extEntry)
+{
+ __glXFlushContextCache();
+}
+
+/*
+** Reset state used to keep track of large (multi-request) commands.
+*/
+void __glXResetLargeCommandStatus(__GLXclientState *cl)
+{
+ cl->largeCmdBytesSoFar = 0;
+ cl->largeCmdBytesTotal = 0;
+ cl->largeCmdRequestsSoFar = 0;
+ cl->largeCmdRequestsTotal = 0;
+}
+
+/*
+** This procedure is called when the client who created the context goes
+** away OR when glXDestroyContext is called. In either case, all we do is
+** flag that the ID is no longer valid, and (maybe) free the context.
+** use.
+*/
+static int ContextGone(__GLXcontext* cx, XID id)
+{
+ cx->idExists = GL_FALSE;
+ if (!cx->isCurrent) {
+ __glXFreeContext(cx);
+ }
+
+ return True;
+}
+
+static __GLXcontext *glxPendingDestroyContexts;
+static __GLXcontext *glxAllContexts;
+static int glxServerLeaveCount;
+static int glxBlockClients;
+
+/*
+** Destroy routine that gets called when a drawable is freed. A drawable
+** contains the ancillary buffers needed for rendering.
+*/
+static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid)
+{
+ __GLXcontext *c;
+ __GLXcontext *cnext;
+
+ /* If this drawable was created using glx 1.3 drawable
+ * constructors, we added it as a glx drawable resource under both
+ * its glx drawable ID and it X drawable ID. Remove the other
+ * resource now so we don't a callback for freed memory. */
+ if (glxPriv->drawId != glxPriv->pDraw->id) {
+ if (xid == glxPriv->drawId)
+ FreeResourceByType(glxPriv->pDraw->id, __glXDrawableRes, TRUE);
+ else
+ FreeResourceByType(glxPriv->drawId, __glXDrawableRes, TRUE);
+ }
+
+ for (c = glxAllContexts; c; c = cnext) {
+ cnext=c->next; /* Save because c is going to be freed */
+ if (c->isCurrent && (c->drawPriv == glxPriv || c->readPriv == glxPriv)) {
+ int i;
+
+ (*c->loseCurrent)(c);
+ c->isCurrent = GL_FALSE;
+ if (c == __glXLastContext)
+ __glXFlushContextCache();
+
+ for (i = 1; i < currentMaxClients; i++) {
+ if (clients[i]) {
+ __GLXclientState *cl = glxGetClient(clients[i]);
+
+ if (cl->inUse) {
+ int j;
+
+ for (j = 0; j < cl->numCurrentContexts; j++) {
+ if (cl->currentContexts[j] == c)
+ cl->currentContexts[j] = NULL;
+ }
+ }
+ }
+ }
+
+ if (!c->idExists) {
+ __glXFreeContext(c);
+ }
+ }
+ if (c->drawPriv == glxPriv)
+ c->drawPriv = NULL;
+ if (c->readPriv == glxPriv)
+ c->readPriv = NULL;
+ }
+
+ glxPriv->destroy(glxPriv);
+
+ return True;
+}
+
+void __glXAddToContextList(__GLXcontext *cx)
+{
+ cx->next = glxAllContexts;
+ glxAllContexts = cx;
+}
+
+static void __glXRemoveFromContextList(__GLXcontext *cx)
+{
+ __GLXcontext *c, *prev;
+
+ if (cx == glxAllContexts)
+ glxAllContexts = cx->next;
+ else {
+ prev = glxAllContexts;
+ for (c = glxAllContexts; c; c = c->next) {
+ if (c == cx)
+ prev->next = c->next;
+ prev = c;
+ }
+ }
+}
+
+/*
+** Free a context.
+*/
+GLboolean __glXFreeContext(__GLXcontext *cx)
+{
+ if (cx->idExists || cx->isCurrent) return GL_FALSE;
+
+ if (cx->feedbackBuf) free(cx->feedbackBuf);
+ if (cx->selectBuf) free(cx->selectBuf);
+ if (cx == __glXLastContext) {
+ __glXFlushContextCache();
+ }
+
+ __glXRemoveFromContextList(cx);
+
+ /* We can get here through both regular dispatching from
+ * __glXDispatch() or as a callback from the resource manager. In
+ * the latter case we need to lift the DRI lock manually. */
+
+ if (!glxBlockClients) {
+ __glXleaveServer(GL_FALSE);
+ cx->destroy(cx);
+ __glXenterServer(GL_FALSE);
+ } else {
+ cx->next = glxPendingDestroyContexts;
+ glxPendingDestroyContexts = cx;
+ }
+
+ return GL_TRUE;
+}
+
+extern RESTYPE __glXSwapBarrierRes;
+
+static int SwapBarrierGone(int screen, XID drawable)
+{
+ __GLXscreen *pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
+
+ if (pGlxScreen->swapBarrierFuncs) {
+ pGlxScreen->swapBarrierFuncs->bindSwapBarrierFunc(screen, drawable, 0);
+ }
+ FreeResourceByType(drawable, __glXSwapBarrierRes, FALSE);
+ return True;
+}
+
+/************************************************************************/
+
+/*
+** These routines can be used to check whether a particular GL command
+** has caused an error. Specifically, we use them to check whether a
+** given query has caused an error, in which case a zero-length data
+** reply is sent to the client.
+*/
+
+static GLboolean errorOccured = GL_FALSE;
+
+/*
+** The GL was will call this routine if an error occurs.
+*/
+void __glXErrorCallBack(GLenum code)
+{
+ errorOccured = GL_TRUE;
+}
+
+/*
+** Clear the error flag before calling the GL command.
+*/
+void __glXClearErrorOccured(void)
+{
+ errorOccured = GL_FALSE;
+}
+
+/*
+** Check if the GL command caused an error.
+*/
+GLboolean __glXErrorOccured(void)
+{
+ return errorOccured;
+}
+
+static int __glXErrorBase;
+int __glXEventBase;
+
+int __glXError(int error)
+{
+ return __glXErrorBase + error;
+}
+
+__GLXclientState *
+glxGetClient(ClientPtr pClient)
+{
+ return dixLookupPrivate(&pClient->devPrivates, glxClientPrivateKey);
+}
+
+static void
+glxClientCallback (CallbackListPtr *list,
+ pointer closure,
+ pointer data)
+{
+ NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
+ ClientPtr pClient = clientinfo->client;
+ __GLXclientState *cl = glxGetClient(pClient);
+ __GLXcontext *cx;
+ int i;
+
+ switch (pClient->clientState) {
+ case ClientStateRunning:
+ /*
+ ** By default, assume that the client supports
+ ** GLX major version 1 minor version 0 protocol.
+ */
+ cl->GLClientmajorVersion = 1;
+ cl->GLClientminorVersion = 0;
+ cl->client = pClient;
+ break;
+
+ case ClientStateGone:
+ for (i = 0; i < cl->numCurrentContexts; i++) {
+ cx = cl->currentContexts[i];
+ if (cx) {
+ cx->isCurrent = GL_FALSE;
+ if (!cx->idExists)
+ __glXFreeContext(cx);
+ }
+ }
+
+ if (cl->returnBuf) free(cl->returnBuf);
+ if (cl->largeCmdBuf) free(cl->largeCmdBuf);
+ if (cl->currentContexts) free(cl->currentContexts);
+ if (cl->GLClientextensions) free(cl->GLClientextensions);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/************************************************************************/
+
+static __GLXprovider *__glXProviderStack;
+
+void GlxPushProvider(__GLXprovider *provider)
+{
+ provider->next = __glXProviderStack;
+ __glXProviderStack = provider;
+}
+
+/*
+** Initialize the GLX extension.
+*/
+void GlxExtensionInit(void)
+{
+ ExtensionEntry *extEntry;
+ ScreenPtr pScreen;
+ int i;
+ __GLXprovider *p;
+ Bool glx_provided = False;
+
+ __glXContextRes = CreateNewResourceType((DeleteType)ContextGone,
+ "GLXContext");
+ __glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone,
+ "GLXDrawable");
+ __glXSwapBarrierRes = CreateNewResourceType((DeleteType)SwapBarrierGone,
+ "GLXSwapBarrier");
+ if (!__glXContextRes || !__glXDrawableRes || !__glXSwapBarrierRes)
+ return;
+
+ if (!dixRequestPrivate(glxClientPrivateKey, sizeof (__GLXclientState)))
+ return;
+ if (!AddCallback (&ClientStateCallback, glxClientCallback, 0))
+ return;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
+
+ for (p = __glXProviderStack; p != NULL; p = p->next) {
+ __GLXscreen *glxScreen;
+
+ glxScreen = p->screenProbe(pScreen);
+ if (glxScreen != NULL) {
+ if (glxScreen->GLXminor < glxMinorVersion)
+ glxMinorVersion = glxScreen->GLXminor;
+ LogMessage(X_INFO,
+ "GLX: Initialized %s GL provider for screen %d\n",
+ p->name, i);
+ break;
+ }
+
+ }
+
+ if (!p)
+ LogMessage(X_INFO,
+ "GLX: no usable GL providers found for screen %d\n", i);
+ else
+ glx_provided = True;
+ }
+
+ /* don't register extension if GL is not provided on any screen */
+ if (!glx_provided)
+ return;
+
+ /*
+ ** Add extension to server extensions.
+ */
+ extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS,
+ __GLX_NUMBER_ERRORS, __glXDispatch,
+ __glXDispatch, ResetExtension,
+ StandardMinorOpcode);
+ if (!extEntry) {
+ FatalError("__glXExtensionInit: AddExtensions failed\n");
+ return;
+ }
+ if (!AddExtensionAlias(GLX_EXTENSION_ALIAS, extEntry)) {
+ ErrorF("__glXExtensionInit: AddExtensionAlias failed\n");
+ return;
+ }
+
+ __glXErrorBase = extEntry->errorBase;
+ __glXEventBase = extEntry->eventBase;
+}
+
+/************************************************************************/
+
+void __glXFlushContextCache(void)
+{
+ __glXLastContext = 0;
+}
+
+/*
+** Make a context the current one for the GL (in this implementation, there
+** is only one instance of the GL, and we use it to serve all GL clients by
+** switching it between different contexts). While we are at it, look up
+** a context by its tag and return its (__GLXcontext *).
+*/
+__GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag,
+ int *error)
+{
+ __GLXcontext *cx;
+
+ /*
+ ** See if the context tag is legal; it is managed by the extension,
+ ** so if it's invalid, we have an implementation error.
+ */
+ cx = (__GLXcontext *) __glXLookupContextByTag(cl, tag);
+ if (!cx) {
+ cl->client->errorValue = tag;
+ *error = __glXError(GLXBadContextTag);
+ return 0;
+ }
+
+ if (!cx->isDirect) {
+ if (cx->drawPriv == NULL) {
+ /*
+ ** The drawable has vanished. It must be a window, because only
+ ** windows can be destroyed from under us; GLX pixmaps are
+ ** refcounted and don't go away until no one is using them.
+ */
+ *error = __glXError(GLXBadCurrentWindow);
+ return 0;
+ }
+ }
+
+ if (cx->wait && (*cx->wait)(cx, cl, error))
+ return NULL;
+
+ if (cx == __glXLastContext) {
+ /* No need to re-bind */
+ return cx;
+ }
+
+ /* Make this context the current one for the GL. */
+ if (!cx->isDirect) {
+ if (!(*cx->forceCurrent)(cx)) {
+ /* Bind failed, and set the error code. Bummer */
+ cl->client->errorValue = cx->id;
+ *error = __glXError(GLXBadContextState);
+ return 0;
+ }
+ }
+ __glXLastContext = cx;
+ return cx;
+}
+
+/************************************************************************/
+
+void glxSuspendClients(void)
+{
+ int i;
+
+ for (i = 1; i < currentMaxClients; i++) {
+ if (clients[i] && glxGetClient(clients[i])->inUse)
+ IgnoreClient(clients[i]);
+ }
+
+ glxBlockClients = TRUE;
+}
+
+void glxResumeClients(void)
+{
+ __GLXcontext *cx, *next;
+ int i;
+
+ glxBlockClients = FALSE;
+
+ for (i = 1; i < currentMaxClients; i++) {
+ if (clients[i] && glxGetClient(clients[i])->inUse)
+ AttendClient(clients[i]);
+ }
+
+ __glXleaveServer(GL_FALSE);
+ for (cx = glxPendingDestroyContexts; cx != NULL; cx = next) {
+ next = cx->next;
+
+ cx->destroy(cx);
+ }
+ glxPendingDestroyContexts = NULL;
+ __glXenterServer(GL_FALSE);
+}
+
+static void
+__glXnopEnterServer(GLboolean rendering)
+{
+}
+
+static void
+__glXnopLeaveServer(GLboolean rendering)
+{
+}
+
+static void (*__glXenterServerFunc)(GLboolean) = __glXnopEnterServer;
+static void (*__glXleaveServerFunc)(GLboolean) = __glXnopLeaveServer;
+
+void __glXsetEnterLeaveServerFuncs(void (*enter)(GLboolean),
+ void (*leave)(GLboolean))
+{
+ __glXenterServerFunc = enter;
+ __glXleaveServerFunc = leave;
+}
+
+
+void __glXenterServer(GLboolean rendering)
+{
+ glxServerLeaveCount--;
+
+ if (glxServerLeaveCount == 0)
+ (*__glXenterServerFunc)(rendering);
+}
+
+void __glXleaveServer(GLboolean rendering)
+{
+ if (glxServerLeaveCount == 0)
+ (*__glXleaveServerFunc)(rendering);
+
+ glxServerLeaveCount++;
+}
+
+/*
+** Top level dispatcher; all commands are executed from here down.
+*/
+static int __glXDispatch(ClientPtr client)
+{
+ REQUEST(xGLXSingleReq);
+ CARD8 opcode;
+ __GLXdispatchSingleProcPtr proc;
+ __GLXclientState *cl;
+ int retval;
+
+ opcode = stuff->glxCode;
+ cl = glxGetClient(client);
+ /* Mark it in use so we suspend it on VT switch. */
+ cl->inUse = TRUE;
+
+ /*
+ ** If we're expecting a glXRenderLarge request, this better be one.
+ */
+ if ((cl->largeCmdRequestsSoFar != 0) && (opcode != X_GLXRenderLarge)) {
+ client->errorValue = stuff->glxCode;
+ return __glXError(GLXBadLargeRequest);
+ }
+
+ /* If we're currently blocking GLX clients, just put this guy to
+ * sleep, reset the request and return. */
+ if (glxBlockClients) {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ IgnoreClient(client);
+ return Success;
+ }
+
+ /*
+ ** Use the opcode to index into the procedure table.
+ */
+ proc = (__GLXdispatchSingleProcPtr) __glXGetProtocolDecodeFunction(& Single_dispatch_info,
+ opcode,
+ client->swapped);
+ if (proc != NULL) {
+ GLboolean rendering = opcode <= X_GLXRenderLarge;
+ __glXleaveServer(rendering);
+
+ __pGlxClient = client;
+
+ retval = (*proc)(cl, (GLbyte *) stuff);
+
+ __glXenterServer(rendering);
+ }
+ else {
+ retval = BadRequest;
+ }
+
+ return retval;
+}
diff --git a/xorg-server/glx/glxscreens.c b/xorg-server/glx/glxscreens.c
index 1462a0ad5..1d647596a 100644
--- a/xorg-server/glx/glxscreens.c
+++ b/xorg-server/glx/glxscreens.c
@@ -382,7 +382,7 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
pGlxScreen->numFBConfigs = i;
pGlxScreen->visuals =
- xcalloc(pGlxScreen->numFBConfigs, sizeof (__GLXconfig *));
+ calloc(pGlxScreen->numFBConfigs, sizeof (__GLXconfig *));
/* First, try to choose featureful FBconfigs for the existing X visuals.
* Note that if multiple X visuals end up with the same FBconfig being
@@ -444,7 +444,7 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
void __glXScreenDestroy(__GLXscreen *screen)
{
- xfree(screen->GLXvendor);
- xfree(screen->GLXextensions);
- xfree(screen->GLextensions);
+ free(screen->GLXvendor);
+ free(screen->GLXextensions);
+ free(screen->GLextensions);
}
diff --git a/xorg-server/glx/indirect_util.c b/xorg-server/glx/indirect_util.c
index 2f48ab2b0..f71fe6dd2 100644
--- a/xorg-server/glx/indirect_util.c
+++ b/xorg-server/glx/indirect_util.c
@@ -1,314 +1,314 @@
-/*
- * (C) Copyright IBM Corporation 2005
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sub license,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#else
-
-#include "glheader.h"
-
-#endif
-
-#include <string.h>
-
-#include <X11/Xmd.h>
-#include <GL/gl.h>
-#include <GL/glxproto.h>
-#include <inttypes.h>
-#include "indirect_size.h"
-#include "indirect_size_get.h"
-#include "indirect_dispatch.h"
-#include "glxserver.h"
-#include "glxbyteorder.h"
-#include "singlesize.h"
-#include "glapitable.h"
-#include "glapi.h"
-#include "glthread.h"
-#include "dispatch.h"
-#include "glxext.h"
-#include "indirect_table.h"
-#include "indirect_util.h"
-
-
-#define __GLX_PAD(a) (((a)+3)&~3)
-
-extern xGLXSingleReply __glXReply;
-
-
-GLint
-__glGetBooleanv_variable_size( GLenum e )
-{
- if ( e == GL_COMPRESSED_TEXTURE_FORMATS ) {
- GLint temp;
-
- CALL_GetIntegerv( GET_DISPATCH(),
- (GL_NUM_COMPRESSED_TEXTURE_FORMATS, & temp) );
- return temp;
- }
- else {
- return 0;
- }
-}
-
-
-/**
- * Get a properly aligned buffer to hold reply data.
- *
- * \warning
- * This function assumes that \c local_buffer is already properly aligned.
- * It also assumes that \c alignment is a power of two.
- */
-void *
-__glXGetAnswerBuffer( __GLXclientState * cl, size_t required_size,
- void * local_buffer, size_t local_size, unsigned alignment )
-{
- void * buffer = local_buffer;
- const unsigned mask = alignment - 1;
-
- if ( local_size < required_size ) {
- const size_t worst_case_size = required_size + alignment;
- intptr_t temp_buf;
-
- if ( cl->returnBufSize < worst_case_size ) {
- void * temp = xrealloc( cl->returnBuf, worst_case_size );
-
- if ( temp == NULL ) {
- return NULL;
- }
-
- cl->returnBuf = temp;
- cl->returnBufSize = worst_case_size;
- }
-
- temp_buf = (intptr_t) cl->returnBuf;
- temp_buf = (temp_buf + mask) & ~mask;
- buffer = (void *) temp_buf;
- }
-
- return buffer;
-}
-
-
-/**
- * Send a GLX reply to the client.
- *
- * Technically speaking, there are several different ways to encode a GLX
- * reply. The primary difference is whether or not certain fields (e.g.,
- * retval, size, and "pad3") are set. This function gets around that by
- * always setting all of the fields to "reasonable" values. This does no
- * harm to clients, but it does make the server-side code much more compact.
- */
-void
-__glXSendReply( ClientPtr client, const void * data, size_t elements,
- size_t element_size, GLboolean always_array, CARD32 retval )
-{
- size_t reply_ints = 0;
-
- if ( __glXErrorOccured() ) {
- elements = 0;
- }
- else if ( (elements > 1) || always_array ) {
- reply_ints = bytes_to_int32(elements * element_size);
- }
-
- __glXReply.length = reply_ints;
- __glXReply.type = X_Reply;
- __glXReply.sequenceNumber = client->sequence;
- __glXReply.size = elements;
- __glXReply.retval = retval;
-
-
- /* It is faster on almost always every architecture to just copy the 8
- * bytes, even when not necessary, than check to see of the value of
- * elements requires it. Copying the data when not needed will do no
- * harm.
- */
-
- (void) memcpy( & __glXReply.pad3, data, 8 );
- WriteToClient( client, sz_xGLXSingleReply, (char *) & __glXReply );
-
- if ( reply_ints != 0 ) {
- WriteToClient( client, reply_ints * 4, (char *) data );
- }
-}
-
-
-/**
- * Send a GLX reply to the client.
- *
- * Technically speaking, there are several different ways to encode a GLX
- * reply. The primary difference is whether or not certain fields (e.g.,
- * retval, size, and "pad3") are set. This function gets around that by
- * always setting all of the fields to "reasonable" values. This does no
- * harm to clients, but it does make the server-side code much more compact.
- *
- * \warning
- * This function assumes that values stored in \c data will be byte-swapped
- * by the caller if necessary.
- */
-void
-__glXSendReplySwap( ClientPtr client, const void * data, size_t elements,
- size_t element_size, GLboolean always_array, CARD32 retval )
-{
- size_t reply_ints = 0;
-
- if ( __glXErrorOccured() ) {
- elements = 0;
- }
- else if ( (elements > 1) || always_array ) {
- reply_ints = bytes_to_int32(elements * element_size);
- }
-
- __glXReply.length = bswap_32( reply_ints );
- __glXReply.type = X_Reply;
- __glXReply.sequenceNumber = bswap_16( client->sequence );
- __glXReply.size = bswap_32( elements );
- __glXReply.retval = bswap_32( retval );
-
-
- /* It is faster on almost always every architecture to just copy the 8
- * bytes, even when not necessary, than check to see of the value of
- * elements requires it. Copying the data when not needed will do no
- * harm.
- */
-
- (void) memcpy( & __glXReply.pad3, data, 8 );
- WriteToClient( client, sz_xGLXSingleReply, (char *) & __glXReply );
-
- if ( reply_ints != 0 ) {
- WriteToClient( client, reply_ints * 4, (char *) data );
- }
-}
-
-
-static int
-get_decode_index(const struct __glXDispatchInfo *dispatch_info,
- unsigned opcode)
-{
- int remaining_bits;
- int next_remain;
- const int_fast16_t * const tree = dispatch_info->dispatch_tree;
- int_fast16_t index;
-
-
- remaining_bits = dispatch_info->bits;
- if (opcode >= (1U << remaining_bits)) {
- return -1;
- }
-
- index = 0;
- for (/* empty */; remaining_bits > 0; remaining_bits = next_remain) {
- unsigned mask;
- unsigned child_index;
-
-
- /* Calculate the slice of bits used by this node.
- *
- * If remaining_bits = 8 and tree[index] = 3, the mask of just the
- * remaining bits is 0x00ff and the mask for the remaining bits after
- * this node is 0x001f. By taking 0x00ff & ~0x001f, we get 0x00e0.
- * This masks the 3 bits that we would want for this node.
- */
-
- next_remain = remaining_bits - tree[index];
- mask = ((1 << remaining_bits) - 1) &
- ~((1 << next_remain) - 1);
-
-
- /* Using the mask, calculate the index of the opcode in the node.
- * With that index, fetch the index of the next node.
- */
-
- child_index = (opcode & mask) >> next_remain;
- index = tree[index + 1 + child_index];
-
-
- /* If the next node is an empty leaf, the opcode is for a non-existant
- * function. We're done.
- *
- * If the next node is a non-empty leaf, look up the function pointer
- * and return it.
- */
-
- if (index == EMPTY_LEAF) {
- return -1;
- }
- else if (IS_LEAF_INDEX(index)) {
- unsigned func_index;
-
-
- /* The value stored in the tree for a leaf node is the base of
- * the function pointers for that leaf node. The offset for the
- * function for a particular opcode is the remaining bits in the
- * opcode.
- */
-
- func_index = -index;
- func_index += opcode & ((1 << next_remain) - 1);
- return func_index;
- }
- }
-
- /* We should *never* get here!!!
- */
- return -1;
-}
-
-
-void *
-__glXGetProtocolDecodeFunction(const struct __glXDispatchInfo *dispatch_info,
- int opcode, int swapped_version)
-{
- const int func_index = get_decode_index(dispatch_info, opcode);
-
- return (func_index < 0)
- ? NULL
- : (void *) dispatch_info->dispatch_functions[func_index][swapped_version];
-}
-
-
-int
-__glXGetProtocolSizeData(const struct __glXDispatchInfo *dispatch_info,
- int opcode, __GLXrenderSizeData *data)
-{
- if (dispatch_info->size_table != NULL) {
- const int func_index = get_decode_index(dispatch_info, opcode);
-
- if ((func_index >= 0)
- && (dispatch_info->size_table[func_index][0] != 0)) {
- const int var_offset =
- dispatch_info->size_table[func_index][1];
-
- data->bytes = dispatch_info->size_table[func_index][0];
- data->varsize = (var_offset != ~0)
- ? dispatch_info->size_func_table[var_offset]
- : NULL;
-
- return 0;
- }
- }
-
- return -1;
-}
+/*
+ * (C) Copyright IBM Corporation 2005
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#else
+
+#include "glheader.h"
+
+#endif
+
+#include <string.h>
+
+#include <X11/Xmd.h>
+#include <GL/gl.h>
+#include <GL/glxproto.h>
+#include <inttypes.h>
+#include "indirect_size.h"
+#include "indirect_size_get.h"
+#include "indirect_dispatch.h"
+#include "glxserver.h"
+#include "glxbyteorder.h"
+#include "singlesize.h"
+#include "glapitable.h"
+#include "glapi.h"
+#include "glthread.h"
+#include "dispatch.h"
+#include "glxext.h"
+#include "indirect_table.h"
+#include "indirect_util.h"
+
+
+#define __GLX_PAD(a) (((a)+3)&~3)
+
+extern xGLXSingleReply __glXReply;
+
+
+GLint
+__glGetBooleanv_variable_size( GLenum e )
+{
+ if ( e == GL_COMPRESSED_TEXTURE_FORMATS ) {
+ GLint temp;
+
+ CALL_GetIntegerv( GET_DISPATCH(),
+ (GL_NUM_COMPRESSED_TEXTURE_FORMATS, & temp) );
+ return temp;
+ }
+ else {
+ return 0;
+ }
+}
+
+
+/**
+ * Get a properly aligned buffer to hold reply data.
+ *
+ * \warning
+ * This function assumes that \c local_buffer is already properly aligned.
+ * It also assumes that \c alignment is a power of two.
+ */
+void *
+__glXGetAnswerBuffer( __GLXclientState * cl, size_t required_size,
+ void * local_buffer, size_t local_size, unsigned alignment )
+{
+ void * buffer = local_buffer;
+ const unsigned mask = alignment - 1;
+
+ if ( local_size < required_size ) {
+ const size_t worst_case_size = required_size + alignment;
+ intptr_t temp_buf;
+
+ if ( cl->returnBufSize < worst_case_size ) {
+ void * temp = realloc( cl->returnBuf, worst_case_size );
+
+ if ( temp == NULL ) {
+ return NULL;
+ }
+
+ cl->returnBuf = temp;
+ cl->returnBufSize = worst_case_size;
+ }
+
+ temp_buf = (intptr_t) cl->returnBuf;
+ temp_buf = (temp_buf + mask) & ~mask;
+ buffer = (void *) temp_buf;
+ }
+
+ return buffer;
+}
+
+
+/**
+ * Send a GLX reply to the client.
+ *
+ * Technically speaking, there are several different ways to encode a GLX
+ * reply. The primary difference is whether or not certain fields (e.g.,
+ * retval, size, and "pad3") are set. This function gets around that by
+ * always setting all of the fields to "reasonable" values. This does no
+ * harm to clients, but it does make the server-side code much more compact.
+ */
+void
+__glXSendReply( ClientPtr client, const void * data, size_t elements,
+ size_t element_size, GLboolean always_array, CARD32 retval )
+{
+ size_t reply_ints = 0;
+
+ if ( __glXErrorOccured() ) {
+ elements = 0;
+ }
+ else if ( (elements > 1) || always_array ) {
+ reply_ints = bytes_to_int32(elements * element_size);
+ }
+
+ __glXReply.length = reply_ints;
+ __glXReply.type = X_Reply;
+ __glXReply.sequenceNumber = client->sequence;
+ __glXReply.size = elements;
+ __glXReply.retval = retval;
+
+
+ /* It is faster on almost always every architecture to just copy the 8
+ * bytes, even when not necessary, than check to see of the value of
+ * elements requires it. Copying the data when not needed will do no
+ * harm.
+ */
+
+ (void) memcpy( & __glXReply.pad3, data, 8 );
+ WriteToClient( client, sz_xGLXSingleReply, (char *) & __glXReply );
+
+ if ( reply_ints != 0 ) {
+ WriteToClient( client, reply_ints * 4, (char *) data );
+ }
+}
+
+
+/**
+ * Send a GLX reply to the client.
+ *
+ * Technically speaking, there are several different ways to encode a GLX
+ * reply. The primary difference is whether or not certain fields (e.g.,
+ * retval, size, and "pad3") are set. This function gets around that by
+ * always setting all of the fields to "reasonable" values. This does no
+ * harm to clients, but it does make the server-side code much more compact.
+ *
+ * \warning
+ * This function assumes that values stored in \c data will be byte-swapped
+ * by the caller if necessary.
+ */
+void
+__glXSendReplySwap( ClientPtr client, const void * data, size_t elements,
+ size_t element_size, GLboolean always_array, CARD32 retval )
+{
+ size_t reply_ints = 0;
+
+ if ( __glXErrorOccured() ) {
+ elements = 0;
+ }
+ else if ( (elements > 1) || always_array ) {
+ reply_ints = bytes_to_int32(elements * element_size);
+ }
+
+ __glXReply.length = bswap_32( reply_ints );
+ __glXReply.type = X_Reply;
+ __glXReply.sequenceNumber = bswap_16( client->sequence );
+ __glXReply.size = bswap_32( elements );
+ __glXReply.retval = bswap_32( retval );
+
+
+ /* It is faster on almost always every architecture to just copy the 8
+ * bytes, even when not necessary, than check to see of the value of
+ * elements requires it. Copying the data when not needed will do no
+ * harm.
+ */
+
+ (void) memcpy( & __glXReply.pad3, data, 8 );
+ WriteToClient( client, sz_xGLXSingleReply, (char *) & __glXReply );
+
+ if ( reply_ints != 0 ) {
+ WriteToClient( client, reply_ints * 4, (char *) data );
+ }
+}
+
+
+static int
+get_decode_index(const struct __glXDispatchInfo *dispatch_info,
+ unsigned opcode)
+{
+ int remaining_bits;
+ int next_remain;
+ const int_fast16_t * const tree = dispatch_info->dispatch_tree;
+ int_fast16_t index;
+
+
+ remaining_bits = dispatch_info->bits;
+ if (opcode >= (1U << remaining_bits)) {
+ return -1;
+ }
+
+ index = 0;
+ for (/* empty */; remaining_bits > 0; remaining_bits = next_remain) {
+ unsigned mask;
+ unsigned child_index;
+
+
+ /* Calculate the slice of bits used by this node.
+ *
+ * If remaining_bits = 8 and tree[index] = 3, the mask of just the
+ * remaining bits is 0x00ff and the mask for the remaining bits after
+ * this node is 0x001f. By taking 0x00ff & ~0x001f, we get 0x00e0.
+ * This masks the 3 bits that we would want for this node.
+ */
+
+ next_remain = remaining_bits - tree[index];
+ mask = ((1 << remaining_bits) - 1) &
+ ~((1 << next_remain) - 1);
+
+
+ /* Using the mask, calculate the index of the opcode in the node.
+ * With that index, fetch the index of the next node.
+ */
+
+ child_index = (opcode & mask) >> next_remain;
+ index = tree[index + 1 + child_index];
+
+
+ /* If the next node is an empty leaf, the opcode is for a non-existant
+ * function. We're done.
+ *
+ * If the next node is a non-empty leaf, look up the function pointer
+ * and return it.
+ */
+
+ if (index == EMPTY_LEAF) {
+ return -1;
+ }
+ else if (IS_LEAF_INDEX(index)) {
+ unsigned func_index;
+
+
+ /* The value stored in the tree for a leaf node is the base of
+ * the function pointers for that leaf node. The offset for the
+ * function for a particular opcode is the remaining bits in the
+ * opcode.
+ */
+
+ func_index = -index;
+ func_index += opcode & ((1 << next_remain) - 1);
+ return func_index;
+ }
+ }
+
+ /* We should *never* get here!!!
+ */
+ return -1;
+}
+
+
+void *
+__glXGetProtocolDecodeFunction(const struct __glXDispatchInfo *dispatch_info,
+ int opcode, int swapped_version)
+{
+ const int func_index = get_decode_index(dispatch_info, opcode);
+
+ return (func_index < 0)
+ ? NULL
+ : (void *) dispatch_info->dispatch_functions[func_index][swapped_version];
+}
+
+
+int
+__glXGetProtocolSizeData(const struct __glXDispatchInfo *dispatch_info,
+ int opcode, __GLXrenderSizeData *data)
+{
+ if (dispatch_info->size_table != NULL) {
+ const int func_index = get_decode_index(dispatch_info, opcode);
+
+ if ((func_index >= 0)
+ && (dispatch_info->size_table[func_index][0] != 0)) {
+ const int var_offset =
+ dispatch_info->size_table[func_index][1];
+
+ data->bytes = dispatch_info->size_table[func_index][0];
+ data->varsize = (var_offset != ~0)
+ ? dispatch_info->size_func_table[var_offset]
+ : NULL;
+
+ return 0;
+ }
+ }
+
+ return -1;
+}
diff --git a/xorg-server/glx/single2.c b/xorg-server/glx/single2.c
index f6e474c46..4d8aeaa83 100644
--- a/xorg-server/glx/single2.c
+++ b/xorg-server/glx/single2.c
@@ -1,395 +1,395 @@
-/*
- * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
- * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice including the dates of first publication and
- * either this permission notice or a reference to
- * http://oss.sgi.com/projects/FreeB/
- * 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
- * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
- * shall not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization from
- * Silicon Graphics, Inc.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#else
-
-#include "glheader.h"
-
-#endif
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "glxserver.h"
-#include "glxutil.h"
-#include "glxext.h"
-#include "indirect_dispatch.h"
-#include "unpack.h"
-#include "glapitable.h"
-#include "glapi.h"
-#include "glthread.h"
-#include "dispatch.h"
-
-int __glXDisp_FeedbackBuffer(__GLXclientState *cl, GLbyte *pc)
-{
- GLsizei size;
- GLenum type;
- __GLXcontext *cx;
- int error;
-
- cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
- if (!cx) {
- return error;
- }
-
- pc += __GLX_SINGLE_HDR_SIZE;
- size = *(GLsizei *)(pc+0);
- type = *(GLenum *)(pc+4);
- if (cx->feedbackBufSize < size) {
- cx->feedbackBuf = (GLfloat *) xrealloc(cx->feedbackBuf,
- (size_t)size
- * __GLX_SIZE_FLOAT32);
- if (!cx->feedbackBuf) {
- cl->client->errorValue = size;
- return BadAlloc;
- }
- cx->feedbackBufSize = size;
- }
- CALL_FeedbackBuffer( GET_DISPATCH(), (size, type, cx->feedbackBuf) );
- __GLX_NOTE_UNFLUSHED_CMDS(cx);
- return Success;
-}
-
-int __glXDisp_SelectBuffer(__GLXclientState *cl, GLbyte *pc)
-{
- __GLXcontext *cx;
- GLsizei size;
- int error;
-
- cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
- if (!cx) {
- return error;
- }
-
- pc += __GLX_SINGLE_HDR_SIZE;
- size = *(GLsizei *)(pc+0);
- if (cx->selectBufSize < size) {
- cx->selectBuf = (GLuint *) xrealloc(cx->selectBuf,
- (size_t) size
- * __GLX_SIZE_CARD32);
- if (!cx->selectBuf) {
- cl->client->errorValue = size;
- return BadAlloc;
- }
- cx->selectBufSize = size;
- }
- CALL_SelectBuffer( GET_DISPATCH(), (size, cx->selectBuf) );
- __GLX_NOTE_UNFLUSHED_CMDS(cx);
- return Success;
-}
-
-int __glXDisp_RenderMode(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client;
- xGLXRenderModeReply reply;
- __GLXcontext *cx;
- GLint nitems=0, retBytes=0, retval, newModeCheck;
- GLubyte *retBuffer = NULL;
- GLenum newMode;
- int error;
-
- cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
- if (!cx) {
- return error;
- }
-
- pc += __GLX_SINGLE_HDR_SIZE;
- newMode = *(GLenum*) pc;
- retval = CALL_RenderMode( GET_DISPATCH(), (newMode) );
-
- /* Check that render mode worked */
- CALL_GetIntegerv( GET_DISPATCH(), (GL_RENDER_MODE, &newModeCheck) );
- if (newModeCheck != newMode) {
- /* Render mode change failed. Bail */
- newMode = newModeCheck;
- goto noChangeAllowed;
- }
-
- /*
- ** Render mode might have still failed if we get here. But in this
- ** case we can't really tell, nor does it matter. If it did fail, it
- ** will return 0, and thus we won't send any data across the wire.
- */
-
- switch (cx->renderMode) {
- case GL_RENDER:
- cx->renderMode = newMode;
- break;
- case GL_FEEDBACK:
- if (retval < 0) {
- /* Overflow happened. Copy the entire buffer */
- nitems = cx->feedbackBufSize;
- } else {
- nitems = retval;
- }
- retBytes = nitems * __GLX_SIZE_FLOAT32;
- retBuffer = (GLubyte*) cx->feedbackBuf;
- cx->renderMode = newMode;
- break;
- case GL_SELECT:
- if (retval < 0) {
- /* Overflow happened. Copy the entire buffer */
- nitems = cx->selectBufSize;
- } else {
- GLuint *bp = cx->selectBuf;
- GLint i;
-
- /*
- ** Figure out how many bytes of data need to be sent. Parse
- ** the selection buffer to determine this fact as the
- ** return value is the number of hits, not the number of
- ** items in the buffer.
- */
- nitems = 0;
- i = retval;
- while (--i >= 0) {
- GLuint n;
-
- /* Parse select data for this hit */
- n = *bp;
- bp += 3 + n;
- }
- nitems = bp - cx->selectBuf;
- }
- retBytes = nitems * __GLX_SIZE_CARD32;
- retBuffer = (GLubyte*) cx->selectBuf;
- cx->renderMode = newMode;
- break;
- }
-
- /*
- ** First reply is the number of elements returned in the feedback or
- ** selection array, as per the API for glRenderMode itself.
- */
- noChangeAllowed:;
- client = cl->client;
- reply.length = nitems;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.retval = retval;
- reply.size = nitems;
- reply.newMode = newMode;
- WriteToClient(client, sz_xGLXRenderModeReply, (char *)&reply);
- if (retBytes) {
- WriteToClient(client, retBytes, (char *)retBuffer);
- }
- return Success;
-}
-
-int __glXDisp_Flush(__GLXclientState *cl, GLbyte *pc)
-{
- __GLXcontext *cx;
- int error;
-
- cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
- if (!cx) {
- return error;
- }
-
- CALL_Flush( GET_DISPATCH(), () );
- __GLX_NOTE_FLUSHED_CMDS(cx);
- return Success;
-}
-
-int __glXDisp_Finish(__GLXclientState *cl, GLbyte *pc)
-{
- __GLXcontext *cx;
- ClientPtr client;
- int error;
-
- cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
- if (!cx) {
- return error;
- }
-
- /* Do a local glFinish */
- CALL_Finish( GET_DISPATCH(), () );
- __GLX_NOTE_FLUSHED_CMDS(cx);
-
- /* Send empty reply packet to indicate finish is finished */
- client = cl->client;
- __GLX_BEGIN_REPLY(0);
- __GLX_SEND_HEADER();
- return Success;
-}
-
-#define SEPARATOR " "
-
-char *__glXcombine_strings(const char *cext_string, const char *sext_string)
-{
- size_t clen, slen;
- char *combo_string, *token, *s1;
- const char *s2, *end;
-
- /* safeguard to prevent potentially fatal errors in the string functions */
- if (!cext_string)
- cext_string = "";
- if (!sext_string)
- sext_string = "";
-
- /*
- ** String can't be longer than min(cstring, sstring)
- ** pull tokens out of shortest string
- ** include space in combo_string for final separator and null terminator
- */
- clen = strlen(cext_string);
- slen = strlen(sext_string);
- if (clen > slen) {
- combo_string = (char *) xalloc(slen + 2);
- s1 = (char *) xalloc(slen + 2);
- if (s1) strcpy(s1, sext_string);
- s2 = cext_string;
- } else {
- combo_string = (char *) xalloc(clen + 2);
- s1 = (char *) xalloc(clen + 2);
- if (s1) strcpy(s1, cext_string);
- s2 = sext_string;
- }
- if (!combo_string || !s1) {
- if (combo_string)
- xfree(combo_string);
- if (s1)
- xfree(s1);
- return NULL;
- }
- combo_string[0] = '\0';
-
- /* Get first extension token */
- token = strtok( s1, SEPARATOR);
- while ( token != NULL ) {
-
- /*
- ** if token in second string then save it
- ** beware of extension names which are prefixes of other extension names
- */
- const char *p = s2;
- end = p + strlen(p);
- while (p < end) {
- size_t n = strcspn(p, SEPARATOR);
- if ((strlen(token) == n) && (strncmp(token, p, n) == 0)) {
- combo_string = strcat(combo_string, token);
- combo_string = strcat(combo_string, SEPARATOR);
- }
- p += (n + 1);
- }
-
- /* Get next extension token */
- token = strtok( NULL, SEPARATOR);
- }
- xfree(s1);
- return combo_string;
-}
-
-int DoGetString(__GLXclientState *cl, GLbyte *pc, GLboolean need_swap)
-{
- ClientPtr client;
- __GLXcontext *cx;
- GLenum name;
- const char *string;
- __GLX_DECLARE_SWAP_VARIABLES;
- int error;
- char *buf = NULL, *buf1 = NULL;
- GLint length = 0;
-
- /* If the client has the opposite byte order, swap the contextTag and
- * the name.
- */
- if ( need_swap ) {
- __GLX_SWAP_INT(pc + 4);
- __GLX_SWAP_INT(pc + __GLX_SINGLE_HDR_SIZE);
- }
-
- cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
- if (!cx) {
- return error;
- }
-
- pc += __GLX_SINGLE_HDR_SIZE;
- name = *(GLenum *)(pc + 0);
- string = (const char *) CALL_GetString( GET_DISPATCH(), (name) );
- client = cl->client;
-
- if (string == NULL)
- string = "";
-
- /*
- ** Restrict extensions to those that are supported by both the
- ** implementation and the connection. That is, return the
- ** intersection of client, server, and core extension strings.
- */
- if (name == GL_EXTENSIONS) {
- buf1 = __glXcombine_strings(string,
- cl->GLClientextensions);
- buf = __glXcombine_strings(buf1,
- cx->pGlxScreen->GLextensions);
- if (buf1 != NULL) {
- xfree(buf1);
- }
- string = buf;
- }
- else if ( name == GL_VERSION ) {
- if ( atof( string ) > atof( GLServerVersion ) ) {
- buf = xalloc( strlen( string ) + strlen( GLServerVersion ) + 4 );
- if ( buf == NULL ) {
- string = GLServerVersion;
- }
- else {
- sprintf( buf, "%s (%s)", GLServerVersion, string );
- string = buf;
- }
- }
- }
- if (string) {
- length = strlen((const char *) string) + 1;
- }
-
- __GLX_BEGIN_REPLY(length);
- __GLX_PUT_SIZE(length);
-
- if ( need_swap ) {
- __GLX_SWAP_REPLY_SIZE();
- __GLX_SWAP_REPLY_HEADER();
- }
-
- __GLX_SEND_HEADER();
- WriteToClient(client, length, (char *) string);
- if (buf != NULL)
- xfree(buf);
-
- return Success;
-}
-
-int __glXDisp_GetString(__GLXclientState *cl, GLbyte *pc)
-{
- return DoGetString(cl, pc, GL_FALSE);
-}
+/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#else
+
+#include "glheader.h"
+
+#endif
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "glxserver.h"
+#include "glxutil.h"
+#include "glxext.h"
+#include "indirect_dispatch.h"
+#include "unpack.h"
+#include "glapitable.h"
+#include "glapi.h"
+#include "glthread.h"
+#include "dispatch.h"
+
+int __glXDisp_FeedbackBuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei size;
+ GLenum type;
+ __GLXcontext *cx;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ size = *(GLsizei *)(pc+0);
+ type = *(GLenum *)(pc+4);
+ if (cx->feedbackBufSize < size) {
+ cx->feedbackBuf = (GLfloat *) realloc(cx->feedbackBuf,
+ (size_t)size
+ * __GLX_SIZE_FLOAT32);
+ if (!cx->feedbackBuf) {
+ cl->client->errorValue = size;
+ return BadAlloc;
+ }
+ cx->feedbackBufSize = size;
+ }
+ CALL_FeedbackBuffer( GET_DISPATCH(), (size, type, cx->feedbackBuf) );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDisp_SelectBuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ GLsizei size;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ size = *(GLsizei *)(pc+0);
+ if (cx->selectBufSize < size) {
+ cx->selectBuf = (GLuint *) realloc(cx->selectBuf,
+ (size_t) size
+ * __GLX_SIZE_CARD32);
+ if (!cx->selectBuf) {
+ cl->client->errorValue = size;
+ return BadAlloc;
+ }
+ cx->selectBufSize = size;
+ }
+ CALL_SelectBuffer( GET_DISPATCH(), (size, cx->selectBuf) );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDisp_RenderMode(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client;
+ xGLXRenderModeReply reply;
+ __GLXcontext *cx;
+ GLint nitems=0, retBytes=0, retval, newModeCheck;
+ GLubyte *retBuffer = NULL;
+ GLenum newMode;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ newMode = *(GLenum*) pc;
+ retval = CALL_RenderMode( GET_DISPATCH(), (newMode) );
+
+ /* Check that render mode worked */
+ CALL_GetIntegerv( GET_DISPATCH(), (GL_RENDER_MODE, &newModeCheck) );
+ if (newModeCheck != newMode) {
+ /* Render mode change failed. Bail */
+ newMode = newModeCheck;
+ goto noChangeAllowed;
+ }
+
+ /*
+ ** Render mode might have still failed if we get here. But in this
+ ** case we can't really tell, nor does it matter. If it did fail, it
+ ** will return 0, and thus we won't send any data across the wire.
+ */
+
+ switch (cx->renderMode) {
+ case GL_RENDER:
+ cx->renderMode = newMode;
+ break;
+ case GL_FEEDBACK:
+ if (retval < 0) {
+ /* Overflow happened. Copy the entire buffer */
+ nitems = cx->feedbackBufSize;
+ } else {
+ nitems = retval;
+ }
+ retBytes = nitems * __GLX_SIZE_FLOAT32;
+ retBuffer = (GLubyte*) cx->feedbackBuf;
+ cx->renderMode = newMode;
+ break;
+ case GL_SELECT:
+ if (retval < 0) {
+ /* Overflow happened. Copy the entire buffer */
+ nitems = cx->selectBufSize;
+ } else {
+ GLuint *bp = cx->selectBuf;
+ GLint i;
+
+ /*
+ ** Figure out how many bytes of data need to be sent. Parse
+ ** the selection buffer to determine this fact as the
+ ** return value is the number of hits, not the number of
+ ** items in the buffer.
+ */
+ nitems = 0;
+ i = retval;
+ while (--i >= 0) {
+ GLuint n;
+
+ /* Parse select data for this hit */
+ n = *bp;
+ bp += 3 + n;
+ }
+ nitems = bp - cx->selectBuf;
+ }
+ retBytes = nitems * __GLX_SIZE_CARD32;
+ retBuffer = (GLubyte*) cx->selectBuf;
+ cx->renderMode = newMode;
+ break;
+ }
+
+ /*
+ ** First reply is the number of elements returned in the feedback or
+ ** selection array, as per the API for glRenderMode itself.
+ */
+ noChangeAllowed:;
+ client = cl->client;
+ reply.length = nitems;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.retval = retval;
+ reply.size = nitems;
+ reply.newMode = newMode;
+ WriteToClient(client, sz_xGLXRenderModeReply, (char *)&reply);
+ if (retBytes) {
+ WriteToClient(client, retBytes, (char *)retBuffer);
+ }
+ return Success;
+}
+
+int __glXDisp_Flush(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ CALL_Flush( GET_DISPATCH(), () );
+ __GLX_NOTE_FLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDisp_Finish(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ ClientPtr client;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ /* Do a local glFinish */
+ CALL_Finish( GET_DISPATCH(), () );
+ __GLX_NOTE_FLUSHED_CMDS(cx);
+
+ /* Send empty reply packet to indicate finish is finished */
+ client = cl->client;
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+#define SEPARATOR " "
+
+char *__glXcombine_strings(const char *cext_string, const char *sext_string)
+{
+ size_t clen, slen;
+ char *combo_string, *token, *s1;
+ const char *s2, *end;
+
+ /* safeguard to prevent potentially fatal errors in the string functions */
+ if (!cext_string)
+ cext_string = "";
+ if (!sext_string)
+ sext_string = "";
+
+ /*
+ ** String can't be longer than min(cstring, sstring)
+ ** pull tokens out of shortest string
+ ** include space in combo_string for final separator and null terminator
+ */
+ clen = strlen(cext_string);
+ slen = strlen(sext_string);
+ if (clen > slen) {
+ combo_string = (char *) malloc(slen + 2);
+ s1 = (char *) malloc(slen + 2);
+ if (s1) strcpy(s1, sext_string);
+ s2 = cext_string;
+ } else {
+ combo_string = (char *) malloc(clen + 2);
+ s1 = (char *) malloc(clen + 2);
+ if (s1) strcpy(s1, cext_string);
+ s2 = sext_string;
+ }
+ if (!combo_string || !s1) {
+ if (combo_string)
+ free(combo_string);
+ if (s1)
+ free(s1);
+ return NULL;
+ }
+ combo_string[0] = '\0';
+
+ /* Get first extension token */
+ token = strtok( s1, SEPARATOR);
+ while ( token != NULL ) {
+
+ /*
+ ** if token in second string then save it
+ ** beware of extension names which are prefixes of other extension names
+ */
+ const char *p = s2;
+ end = p + strlen(p);
+ while (p < end) {
+ size_t n = strcspn(p, SEPARATOR);
+ if ((strlen(token) == n) && (strncmp(token, p, n) == 0)) {
+ combo_string = strcat(combo_string, token);
+ combo_string = strcat(combo_string, SEPARATOR);
+ }
+ p += (n + 1);
+ }
+
+ /* Get next extension token */
+ token = strtok( NULL, SEPARATOR);
+ }
+ free(s1);
+ return combo_string;
+}
+
+int DoGetString(__GLXclientState *cl, GLbyte *pc, GLboolean need_swap)
+{
+ ClientPtr client;
+ __GLXcontext *cx;
+ GLenum name;
+ const char *string;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ int error;
+ char *buf = NULL, *buf1 = NULL;
+ GLint length = 0;
+
+ /* If the client has the opposite byte order, swap the contextTag and
+ * the name.
+ */
+ if ( need_swap ) {
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + __GLX_SINGLE_HDR_SIZE);
+ }
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ name = *(GLenum *)(pc + 0);
+ string = (const char *) CALL_GetString( GET_DISPATCH(), (name) );
+ client = cl->client;
+
+ if (string == NULL)
+ string = "";
+
+ /*
+ ** Restrict extensions to those that are supported by both the
+ ** implementation and the connection. That is, return the
+ ** intersection of client, server, and core extension strings.
+ */
+ if (name == GL_EXTENSIONS) {
+ buf1 = __glXcombine_strings(string,
+ cl->GLClientextensions);
+ buf = __glXcombine_strings(buf1,
+ cx->pGlxScreen->GLextensions);
+ if (buf1 != NULL) {
+ free(buf1);
+ }
+ string = buf;
+ }
+ else if ( name == GL_VERSION ) {
+ if ( atof( string ) > atof( GLServerVersion ) ) {
+ buf = malloc( strlen( string ) + strlen( GLServerVersion ) + 4 );
+ if ( buf == NULL ) {
+ string = GLServerVersion;
+ }
+ else {
+ sprintf( buf, "%s (%s)", GLServerVersion, string );
+ string = buf;
+ }
+ }
+ }
+ if (string) {
+ length = strlen((const char *) string) + 1;
+ }
+
+ __GLX_BEGIN_REPLY(length);
+ __GLX_PUT_SIZE(length);
+
+ if ( need_swap ) {
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SWAP_REPLY_HEADER();
+ }
+
+ __GLX_SEND_HEADER();
+ WriteToClient(client, length, (char *) string);
+ if (buf != NULL)
+ free(buf);
+
+ return Success;
+}
+
+int __glXDisp_GetString(__GLXclientState *cl, GLbyte *pc)
+{
+ return DoGetString(cl, pc, GL_FALSE);
+}
diff --git a/xorg-server/glx/single2swap.c b/xorg-server/glx/single2swap.c
index e27e97aee..933325de8 100644
--- a/xorg-server/glx/single2swap.c
+++ b/xorg-server/glx/single2swap.c
@@ -1,270 +1,270 @@
-/*
- * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
- * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice including the dates of first publication and
- * either this permission notice or a reference to
- * http://oss.sgi.com/projects/FreeB/
- * 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
- * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
- * shall not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization from
- * Silicon Graphics, Inc.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#else
-
-#include "glheader.h"
-
-#endif
-
-#include "glxserver.h"
-#include "glxutil.h"
-#include "glxext.h"
-#include "indirect_dispatch.h"
-#include "unpack.h"
-#include "glapitable.h"
-#include "glapi.h"
-#include "glthread.h"
-#include "dispatch.h"
-
-int __glXDispSwap_FeedbackBuffer(__GLXclientState *cl, GLbyte *pc)
-{
- GLsizei size;
- GLenum type;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLXcontext *cx;
- int error;
-
- __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
- cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
- if (!cx) {
- return error;
- }
-
- pc += __GLX_SINGLE_HDR_SIZE;
- __GLX_SWAP_INT(pc+0);
- __GLX_SWAP_INT(pc+4);
- size = *(GLsizei *)(pc+0);
- type = *(GLenum *)(pc+4);
- if (cx->feedbackBufSize < size) {
- cx->feedbackBuf = (GLfloat *) xrealloc(cx->feedbackBuf,
- (size_t) size
- * __GLX_SIZE_FLOAT32);
- if (!cx->feedbackBuf) {
- cl->client->errorValue = size;
- return BadAlloc;
- }
- cx->feedbackBufSize = size;
- }
- CALL_FeedbackBuffer( GET_DISPATCH(), (size, type, cx->feedbackBuf) );
- __GLX_NOTE_UNFLUSHED_CMDS(cx);
- return Success;
-}
-
-int __glXDispSwap_SelectBuffer(__GLXclientState *cl, GLbyte *pc)
-{
- __GLXcontext *cx;
- GLsizei size;
- __GLX_DECLARE_SWAP_VARIABLES;
- int error;
-
- __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
- cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
- if (!cx) {
- return error;
- }
-
- pc += __GLX_SINGLE_HDR_SIZE;
- __GLX_SWAP_INT(pc+0);
- size = *(GLsizei *)(pc+0);
- if (cx->selectBufSize < size) {
- cx->selectBuf = (GLuint *) xrealloc(cx->selectBuf,
- (size_t) size
- * __GLX_SIZE_CARD32);
- if (!cx->selectBuf) {
- cl->client->errorValue = size;
- return BadAlloc;
- }
- cx->selectBufSize = size;
- }
- CALL_SelectBuffer( GET_DISPATCH(), (size, cx->selectBuf) );
- __GLX_NOTE_UNFLUSHED_CMDS(cx);
- return Success;
-}
-
-int __glXDispSwap_RenderMode(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client;
- __GLXcontext *cx;
- xGLXRenderModeReply reply;
- GLint nitems=0, retBytes=0, retval, newModeCheck;
- GLubyte *retBuffer = NULL;
- GLenum newMode;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
- int error;
-
- __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
- cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
- if (!cx) {
- return error;
- }
-
- pc += __GLX_SINGLE_HDR_SIZE;
- __GLX_SWAP_INT(pc);
- newMode = *(GLenum*) pc;
- retval = CALL_RenderMode( GET_DISPATCH(), (newMode) );
-
- /* Check that render mode worked */
- CALL_GetIntegerv( GET_DISPATCH(), (GL_RENDER_MODE, &newModeCheck) );
- if (newModeCheck != newMode) {
- /* Render mode change failed. Bail */
- newMode = newModeCheck;
- goto noChangeAllowed;
- }
-
- /*
- ** Render mode might have still failed if we get here. But in this
- ** case we can't really tell, nor does it matter. If it did fail, it
- ** will return 0, and thus we won't send any data across the wire.
- */
-
- switch (cx->renderMode) {
- case GL_RENDER:
- cx->renderMode = newMode;
- break;
- case GL_FEEDBACK:
- if (retval < 0) {
- /* Overflow happened. Copy the entire buffer */
- nitems = cx->feedbackBufSize;
- } else {
- nitems = retval;
- }
- retBytes = nitems * __GLX_SIZE_FLOAT32;
- retBuffer = (GLubyte*) cx->feedbackBuf;
- __GLX_SWAP_FLOAT_ARRAY((GLbyte *)retBuffer, nitems);
- cx->renderMode = newMode;
- break;
- case GL_SELECT:
- if (retval < 0) {
- /* Overflow happened. Copy the entire buffer */
- nitems = cx->selectBufSize;
- } else {
- GLuint *bp = cx->selectBuf;
- GLint i;
-
- /*
- ** Figure out how many bytes of data need to be sent. Parse
- ** the selection buffer to determine this fact as the
- ** return value is the number of hits, not the number of
- ** items in the buffer.
- */
- nitems = 0;
- i = retval;
- while (--i >= 0) {
- GLuint n;
-
- /* Parse select data for this hit */
- n = *bp;
- bp += 3 + n;
- }
- nitems = bp - cx->selectBuf;
- }
- retBytes = nitems * __GLX_SIZE_CARD32;
- retBuffer = (GLubyte*) cx->selectBuf;
- __GLX_SWAP_INT_ARRAY((GLbyte *)retBuffer, nitems);
- cx->renderMode = newMode;
- break;
- }
-
- /*
- ** First reply is the number of elements returned in the feedback or
- ** selection array, as per the API for glRenderMode itself.
- */
- noChangeAllowed:;
- client = cl->client;
- reply.length = nitems;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.retval = retval;
- reply.size = nitems;
- reply.newMode = newMode;
- __GLX_SWAP_SHORT(&reply.sequenceNumber);
- __GLX_SWAP_INT(&reply.length);
- __GLX_SWAP_INT(&reply.retval);
- __GLX_SWAP_INT(&reply.size);
- __GLX_SWAP_INT(&reply.newMode);
- WriteToClient(client, sz_xGLXRenderModeReply, (char *)&reply);
- if (retBytes) {
- WriteToClient(client, retBytes, (char *)retBuffer);
- }
- return Success;
-}
-
-int __glXDispSwap_Flush(__GLXclientState *cl, GLbyte *pc)
-{
- __GLXcontext *cx;
- int error;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
- cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
- if (!cx) {
- return error;
- }
-
- CALL_Flush( GET_DISPATCH(), () );
- __GLX_NOTE_FLUSHED_CMDS(cx);
- return Success;
-}
-
-int __glXDispSwap_Finish(__GLXclientState *cl, GLbyte *pc)
-{
- __GLXcontext *cx;
- ClientPtr client;
- int error;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
- cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
- if (!cx) {
- return error;
- }
-
- /* Do a local glFinish */
- CALL_Finish( GET_DISPATCH(), () );
- __GLX_NOTE_FLUSHED_CMDS(cx);
-
- /* Send empty reply packet to indicate finish is finished */
- client = cl->client;
- __GLX_BEGIN_REPLY(0);
- __GLX_PUT_RETVAL(0);
- __GLX_SWAP_REPLY_HEADER();
- __GLX_SEND_HEADER();
-
- return Success;
-}
-
-int __glXDispSwap_GetString(__GLXclientState *cl, GLbyte *pc)
-{
- return DoGetString(cl, pc, GL_TRUE);
-}
+/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#else
+
+#include "glheader.h"
+
+#endif
+
+#include "glxserver.h"
+#include "glxutil.h"
+#include "glxext.h"
+#include "indirect_dispatch.h"
+#include "unpack.h"
+#include "glapitable.h"
+#include "glapi.h"
+#include "glthread.h"
+#include "dispatch.h"
+
+int __glXDispSwap_FeedbackBuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei size;
+ GLenum type;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLXcontext *cx;
+ int error;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc+0);
+ __GLX_SWAP_INT(pc+4);
+ size = *(GLsizei *)(pc+0);
+ type = *(GLenum *)(pc+4);
+ if (cx->feedbackBufSize < size) {
+ cx->feedbackBuf = (GLfloat *) realloc(cx->feedbackBuf,
+ (size_t) size
+ * __GLX_SIZE_FLOAT32);
+ if (!cx->feedbackBuf) {
+ cl->client->errorValue = size;
+ return BadAlloc;
+ }
+ cx->feedbackBufSize = size;
+ }
+ CALL_FeedbackBuffer( GET_DISPATCH(), (size, type, cx->feedbackBuf) );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDispSwap_SelectBuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ GLsizei size;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ int error;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc+0);
+ size = *(GLsizei *)(pc+0);
+ if (cx->selectBufSize < size) {
+ cx->selectBuf = (GLuint *) realloc(cx->selectBuf,
+ (size_t) size
+ * __GLX_SIZE_CARD32);
+ if (!cx->selectBuf) {
+ cl->client->errorValue = size;
+ return BadAlloc;
+ }
+ cx->selectBufSize = size;
+ }
+ CALL_SelectBuffer( GET_DISPATCH(), (size, cx->selectBuf) );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDispSwap_RenderMode(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client;
+ __GLXcontext *cx;
+ xGLXRenderModeReply reply;
+ GLint nitems=0, retBytes=0, retval, newModeCheck;
+ GLubyte *retBuffer = NULL;
+ GLenum newMode;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+ int error;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc);
+ newMode = *(GLenum*) pc;
+ retval = CALL_RenderMode( GET_DISPATCH(), (newMode) );
+
+ /* Check that render mode worked */
+ CALL_GetIntegerv( GET_DISPATCH(), (GL_RENDER_MODE, &newModeCheck) );
+ if (newModeCheck != newMode) {
+ /* Render mode change failed. Bail */
+ newMode = newModeCheck;
+ goto noChangeAllowed;
+ }
+
+ /*
+ ** Render mode might have still failed if we get here. But in this
+ ** case we can't really tell, nor does it matter. If it did fail, it
+ ** will return 0, and thus we won't send any data across the wire.
+ */
+
+ switch (cx->renderMode) {
+ case GL_RENDER:
+ cx->renderMode = newMode;
+ break;
+ case GL_FEEDBACK:
+ if (retval < 0) {
+ /* Overflow happened. Copy the entire buffer */
+ nitems = cx->feedbackBufSize;
+ } else {
+ nitems = retval;
+ }
+ retBytes = nitems * __GLX_SIZE_FLOAT32;
+ retBuffer = (GLubyte*) cx->feedbackBuf;
+ __GLX_SWAP_FLOAT_ARRAY((GLbyte *)retBuffer, nitems);
+ cx->renderMode = newMode;
+ break;
+ case GL_SELECT:
+ if (retval < 0) {
+ /* Overflow happened. Copy the entire buffer */
+ nitems = cx->selectBufSize;
+ } else {
+ GLuint *bp = cx->selectBuf;
+ GLint i;
+
+ /*
+ ** Figure out how many bytes of data need to be sent. Parse
+ ** the selection buffer to determine this fact as the
+ ** return value is the number of hits, not the number of
+ ** items in the buffer.
+ */
+ nitems = 0;
+ i = retval;
+ while (--i >= 0) {
+ GLuint n;
+
+ /* Parse select data for this hit */
+ n = *bp;
+ bp += 3 + n;
+ }
+ nitems = bp - cx->selectBuf;
+ }
+ retBytes = nitems * __GLX_SIZE_CARD32;
+ retBuffer = (GLubyte*) cx->selectBuf;
+ __GLX_SWAP_INT_ARRAY((GLbyte *)retBuffer, nitems);
+ cx->renderMode = newMode;
+ break;
+ }
+
+ /*
+ ** First reply is the number of elements returned in the feedback or
+ ** selection array, as per the API for glRenderMode itself.
+ */
+ noChangeAllowed:;
+ client = cl->client;
+ reply.length = nitems;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.retval = retval;
+ reply.size = nitems;
+ reply.newMode = newMode;
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.retval);
+ __GLX_SWAP_INT(&reply.size);
+ __GLX_SWAP_INT(&reply.newMode);
+ WriteToClient(client, sz_xGLXRenderModeReply, (char *)&reply);
+ if (retBytes) {
+ WriteToClient(client, retBytes, (char *)retBuffer);
+ }
+ return Success;
+}
+
+int __glXDispSwap_Flush(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ CALL_Flush( GET_DISPATCH(), () );
+ __GLX_NOTE_FLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDispSwap_Finish(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ ClientPtr client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ /* Do a local glFinish */
+ CALL_Finish( GET_DISPATCH(), () );
+ __GLX_NOTE_FLUSHED_CMDS(cx);
+
+ /* Send empty reply packet to indicate finish is finished */
+ client = cl->client;
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_RETVAL(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+
+ return Success;
+}
+
+int __glXDispSwap_GetString(__GLXclientState *cl, GLbyte *pc)
+{
+ return DoGetString(cl, pc, GL_TRUE);
+}
diff --git a/xorg-server/glx/unpack.h b/xorg-server/glx/unpack.h
index 90cb71bd7..7e6a55105 100644
--- a/xorg-server/glx/unpack.h
+++ b/xorg-server/glx/unpack.h
@@ -1,234 +1,234 @@
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef __GLX_unpack_h__
-#define __GLX_unpack_h__
-
-/*
- * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
- * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice including the dates of first publication and
- * either this permission notice or a reference to
- * http://oss.sgi.com/projects/FreeB/
- * 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
- * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
- * shall not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization from
- * Silicon Graphics, Inc.
- */
-
-#define __GLX_PAD(s) (((s)+3) & (GLuint)~3)
-
-/*
-** Fetch the context-id out of a SingleReq request pointed to by pc.
-*/
-#define __GLX_GET_SINGLE_CONTEXT_TAG(pc) (((xGLXSingleReq*)pc)->contextTag)
-#define __GLX_GET_VENDPRIV_CONTEXT_TAG(pc) (((xGLXVendorPrivateReq*)pc)->contextTag)
-
-/*
-** Fetch a double from potentially unaligned memory.
-*/
-#ifdef __GLX_ALIGN64
-#define __GLX_MEM_COPY(dst,src,n) if (src != NULL && dst != NULL) memcpy(dst,src,n)
-#define __GLX_GET_DOUBLE(dst,src) __GLX_MEM_COPY(&dst,src,8)
-#else
-#define __GLX_GET_DOUBLE(dst,src) (dst) = *((GLdouble*)(src))
-#endif
-
-extern void __glXMemInit(void);
-
-extern xGLXSingleReply __glXReply;
-
-#define __GLX_BEGIN_REPLY(size) \
- __glXReply.length = __GLX_PAD(size) >> 2; \
- __glXReply.type = X_Reply; \
- __glXReply.sequenceNumber = client->sequence;
-
-#define __GLX_SEND_HEADER() \
- WriteToClient( client, sz_xGLXSingleReply, (char *)&__glXReply);
-
-#define __GLX_PUT_RETVAL(a) \
- __glXReply.retval = (a);
-
-#define __GLX_PUT_SIZE(a) \
- __glXReply.size = (a);
-
-#define __GLX_PUT_RENDERMODE(m) \
- __glXReply.pad3 = (m)
-
-/*
-** Get a buffer to hold returned data, with the given alignment. If we have
-** to realloc, allocate size+align, in case the pointer has to be bumped for
-** alignment. The answerBuffer should already be aligned.
-**
-** NOTE: the cast (long)res below assumes a long is large enough to hold a
-** pointer.
-*/
-#define __GLX_GET_ANSWER_BUFFER(res,cl,size,align) \
- if ((size) > sizeof(answerBuffer)) { \
- int bump; \
- if ((cl)->returnBufSize < (size)+(align)) { \
- (cl)->returnBuf = (GLbyte*)Xrealloc((cl)->returnBuf, \
- (size)+(align)); \
- if (!(cl)->returnBuf) { \
- return BadAlloc; \
- } \
- (cl)->returnBufSize = (size)+(align); \
- } \
- res = (char*)cl->returnBuf; \
- bump = (long)(res) % (align); \
- if (bump) res += (align) - (bump); \
- } else { \
- res = (char *)answerBuffer; \
- }
-
-#define __GLX_PUT_BYTE() \
- *(GLbyte *)&__glXReply.pad3 = *(GLbyte *)answer
-
-#define __GLX_PUT_SHORT() \
- *(GLshort *)&__glXReply.pad3 = *(GLshort *)answer
-
-#define __GLX_PUT_INT() \
- *(GLint *)&__glXReply.pad3 = *(GLint *)answer
-
-#define __GLX_PUT_FLOAT() \
- *(GLfloat *)&__glXReply.pad3 = *(GLfloat *)answer
-
-#define __GLX_PUT_DOUBLE() \
- *(GLdouble *)&__glXReply.pad3 = *(GLdouble *)answer
-
-#define __GLX_SEND_BYTE_ARRAY(len) \
- WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT8), (char *)answer)
-
-#define __GLX_SEND_SHORT_ARRAY(len) \
- WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT16), (char *)answer)
-
-#define __GLX_SEND_INT_ARRAY(len) \
- WriteToClient(client, (len)*__GLX_SIZE_INT32, (char *)answer)
-
-#define __GLX_SEND_FLOAT_ARRAY(len) \
- WriteToClient(client, (len)*__GLX_SIZE_FLOAT32, (char *)answer)
-
-#define __GLX_SEND_DOUBLE_ARRAY(len) \
- WriteToClient(client, (len)*__GLX_SIZE_FLOAT64, (char *)answer)
-
-
-#define __GLX_SEND_VOID_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
-#define __GLX_SEND_UBYTE_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
-#define __GLX_SEND_USHORT_ARRAY(len) __GLX_SEND_SHORT_ARRAY(len)
-#define __GLX_SEND_UINT_ARRAY(len) __GLX_SEND_INT_ARRAY(len)
-
-/*
-** PERFORMANCE NOTE:
-** Machine dependent optimizations abound here; these swapping macros can
-** conceivably be replaced with routines that do the job faster.
-*/
-#define __GLX_DECLARE_SWAP_VARIABLES \
- GLbyte sw
-
-#define __GLX_DECLARE_SWAP_ARRAY_VARIABLES \
- GLbyte *swapPC; \
- GLbyte *swapEnd
-
-
-#define __GLX_SWAP_INT(pc) \
- sw = ((GLbyte *)(pc))[0]; \
- ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
- ((GLbyte *)(pc))[3] = sw; \
- sw = ((GLbyte *)(pc))[1]; \
- ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
- ((GLbyte *)(pc))[2] = sw;
-
-#define __GLX_SWAP_SHORT(pc) \
- sw = ((GLbyte *)(pc))[0]; \
- ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[1]; \
- ((GLbyte *)(pc))[1] = sw;
-
-#define __GLX_SWAP_DOUBLE(pc) \
- sw = ((GLbyte *)(pc))[0]; \
- ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[7]; \
- ((GLbyte *)(pc))[7] = sw; \
- sw = ((GLbyte *)(pc))[1]; \
- ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[6]; \
- ((GLbyte *)(pc))[6] = sw; \
- sw = ((GLbyte *)(pc))[2]; \
- ((GLbyte *)(pc))[2] = ((GLbyte *)(pc))[5]; \
- ((GLbyte *)(pc))[5] = sw; \
- sw = ((GLbyte *)(pc))[3]; \
- ((GLbyte *)(pc))[3] = ((GLbyte *)(pc))[4]; \
- ((GLbyte *)(pc))[4] = sw;
-
-#define __GLX_SWAP_FLOAT(pc) \
- sw = ((GLbyte *)(pc))[0]; \
- ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
- ((GLbyte *)(pc))[3] = sw; \
- sw = ((GLbyte *)(pc))[1]; \
- ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
- ((GLbyte *)(pc))[2] = sw;
-
-#define __GLX_SWAP_INT_ARRAY(pc, count) \
- swapPC = ((GLbyte *)(pc)); \
- swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT32;\
- while (swapPC < swapEnd) { \
- __GLX_SWAP_INT(swapPC); \
- swapPC += __GLX_SIZE_INT32; \
- }
-
-#define __GLX_SWAP_SHORT_ARRAY(pc, count) \
- swapPC = ((GLbyte *)(pc)); \
- swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT16;\
- while (swapPC < swapEnd) { \
- __GLX_SWAP_SHORT(swapPC); \
- swapPC += __GLX_SIZE_INT16; \
- }
-
-#define __GLX_SWAP_DOUBLE_ARRAY(pc, count) \
- swapPC = ((GLbyte *)(pc)); \
- swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT64;\
- while (swapPC < swapEnd) { \
- __GLX_SWAP_DOUBLE(swapPC); \
- swapPC += __GLX_SIZE_FLOAT64; \
- }
-
-#define __GLX_SWAP_FLOAT_ARRAY(pc, count) \
- swapPC = ((GLbyte *)(pc)); \
- swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT32;\
- while (swapPC < swapEnd) { \
- __GLX_SWAP_FLOAT(swapPC); \
- swapPC += __GLX_SIZE_FLOAT32; \
- }
-
-#define __GLX_SWAP_REPLY_HEADER() \
- __GLX_SWAP_SHORT(&__glXReply.sequenceNumber); \
- __GLX_SWAP_INT(&__glXReply.length);
-
-#define __GLX_SWAP_REPLY_RETVAL() \
- __GLX_SWAP_INT(&__glXReply.retval)
-
-#define __GLX_SWAP_REPLY_SIZE() \
- __GLX_SWAP_INT(&__glXReply.size)
-
-#endif /* !__GLX_unpack_h__ */
-
-
-
-
-
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef __GLX_unpack_h__
+#define __GLX_unpack_h__
+
+/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#define __GLX_PAD(s) (((s)+3) & (GLuint)~3)
+
+/*
+** Fetch the context-id out of a SingleReq request pointed to by pc.
+*/
+#define __GLX_GET_SINGLE_CONTEXT_TAG(pc) (((xGLXSingleReq*)pc)->contextTag)
+#define __GLX_GET_VENDPRIV_CONTEXT_TAG(pc) (((xGLXVendorPrivateReq*)pc)->contextTag)
+
+/*
+** Fetch a double from potentially unaligned memory.
+*/
+#ifdef __GLX_ALIGN64
+#define __GLX_MEM_COPY(dst,src,n) if (src != NULL && dst != NULL) memcpy(dst,src,n)
+#define __GLX_GET_DOUBLE(dst,src) __GLX_MEM_COPY(&dst,src,8)
+#else
+#define __GLX_GET_DOUBLE(dst,src) (dst) = *((GLdouble*)(src))
+#endif
+
+extern void __glXMemInit(void);
+
+extern xGLXSingleReply __glXReply;
+
+#define __GLX_BEGIN_REPLY(size) \
+ __glXReply.length = __GLX_PAD(size) >> 2; \
+ __glXReply.type = X_Reply; \
+ __glXReply.sequenceNumber = client->sequence;
+
+#define __GLX_SEND_HEADER() \
+ WriteToClient( client, sz_xGLXSingleReply, (char *)&__glXReply);
+
+#define __GLX_PUT_RETVAL(a) \
+ __glXReply.retval = (a);
+
+#define __GLX_PUT_SIZE(a) \
+ __glXReply.size = (a);
+
+#define __GLX_PUT_RENDERMODE(m) \
+ __glXReply.pad3 = (m)
+
+/*
+** Get a buffer to hold returned data, with the given alignment. If we have
+** to realloc, allocate size+align, in case the pointer has to be bumped for
+** alignment. The answerBuffer should already be aligned.
+**
+** NOTE: the cast (long)res below assumes a long is large enough to hold a
+** pointer.
+*/
+#define __GLX_GET_ANSWER_BUFFER(res,cl,size,align) \
+ if ((size) > sizeof(answerBuffer)) { \
+ int bump; \
+ if ((cl)->returnBufSize < (size)+(align)) { \
+ (cl)->returnBuf = (GLbyte*)realloc((cl)->returnBuf, \
+ (size)+(align)); \
+ if (!(cl)->returnBuf) { \
+ return BadAlloc; \
+ } \
+ (cl)->returnBufSize = (size)+(align); \
+ } \
+ res = (char*)cl->returnBuf; \
+ bump = (long)(res) % (align); \
+ if (bump) res += (align) - (bump); \
+ } else { \
+ res = (char *)answerBuffer; \
+ }
+
+#define __GLX_PUT_BYTE() \
+ *(GLbyte *)&__glXReply.pad3 = *(GLbyte *)answer
+
+#define __GLX_PUT_SHORT() \
+ *(GLshort *)&__glXReply.pad3 = *(GLshort *)answer
+
+#define __GLX_PUT_INT() \
+ *(GLint *)&__glXReply.pad3 = *(GLint *)answer
+
+#define __GLX_PUT_FLOAT() \
+ *(GLfloat *)&__glXReply.pad3 = *(GLfloat *)answer
+
+#define __GLX_PUT_DOUBLE() \
+ *(GLdouble *)&__glXReply.pad3 = *(GLdouble *)answer
+
+#define __GLX_SEND_BYTE_ARRAY(len) \
+ WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT8), (char *)answer)
+
+#define __GLX_SEND_SHORT_ARRAY(len) \
+ WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT16), (char *)answer)
+
+#define __GLX_SEND_INT_ARRAY(len) \
+ WriteToClient(client, (len)*__GLX_SIZE_INT32, (char *)answer)
+
+#define __GLX_SEND_FLOAT_ARRAY(len) \
+ WriteToClient(client, (len)*__GLX_SIZE_FLOAT32, (char *)answer)
+
+#define __GLX_SEND_DOUBLE_ARRAY(len) \
+ WriteToClient(client, (len)*__GLX_SIZE_FLOAT64, (char *)answer)
+
+
+#define __GLX_SEND_VOID_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
+#define __GLX_SEND_UBYTE_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
+#define __GLX_SEND_USHORT_ARRAY(len) __GLX_SEND_SHORT_ARRAY(len)
+#define __GLX_SEND_UINT_ARRAY(len) __GLX_SEND_INT_ARRAY(len)
+
+/*
+** PERFORMANCE NOTE:
+** Machine dependent optimizations abound here; these swapping macros can
+** conceivably be replaced with routines that do the job faster.
+*/
+#define __GLX_DECLARE_SWAP_VARIABLES \
+ GLbyte sw
+
+#define __GLX_DECLARE_SWAP_ARRAY_VARIABLES \
+ GLbyte *swapPC; \
+ GLbyte *swapEnd
+
+
+#define __GLX_SWAP_INT(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
+ ((GLbyte *)(pc))[3] = sw; \
+ sw = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
+ ((GLbyte *)(pc))[2] = sw;
+
+#define __GLX_SWAP_SHORT(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = sw;
+
+#define __GLX_SWAP_DOUBLE(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[7]; \
+ ((GLbyte *)(pc))[7] = sw; \
+ sw = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[6]; \
+ ((GLbyte *)(pc))[6] = sw; \
+ sw = ((GLbyte *)(pc))[2]; \
+ ((GLbyte *)(pc))[2] = ((GLbyte *)(pc))[5]; \
+ ((GLbyte *)(pc))[5] = sw; \
+ sw = ((GLbyte *)(pc))[3]; \
+ ((GLbyte *)(pc))[3] = ((GLbyte *)(pc))[4]; \
+ ((GLbyte *)(pc))[4] = sw;
+
+#define __GLX_SWAP_FLOAT(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
+ ((GLbyte *)(pc))[3] = sw; \
+ sw = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
+ ((GLbyte *)(pc))[2] = sw;
+
+#define __GLX_SWAP_INT_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT32;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_INT(swapPC); \
+ swapPC += __GLX_SIZE_INT32; \
+ }
+
+#define __GLX_SWAP_SHORT_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT16;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_SHORT(swapPC); \
+ swapPC += __GLX_SIZE_INT16; \
+ }
+
+#define __GLX_SWAP_DOUBLE_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT64;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_DOUBLE(swapPC); \
+ swapPC += __GLX_SIZE_FLOAT64; \
+ }
+
+#define __GLX_SWAP_FLOAT_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT32;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_FLOAT(swapPC); \
+ swapPC += __GLX_SIZE_FLOAT32; \
+ }
+
+#define __GLX_SWAP_REPLY_HEADER() \
+ __GLX_SWAP_SHORT(&__glXReply.sequenceNumber); \
+ __GLX_SWAP_INT(&__glXReply.length);
+
+#define __GLX_SWAP_REPLY_RETVAL() \
+ __GLX_SWAP_INT(&__glXReply.retval)
+
+#define __GLX_SWAP_REPLY_SIZE() \
+ __GLX_SWAP_INT(&__glXReply.size)
+
+#endif /* !__GLX_unpack_h__ */
+
+
+
+
+
diff --git a/xorg-server/glx/xfont.c b/xorg-server/glx/xfont.c
index a2573d4dd..af0b21831 100644
--- a/xorg-server/glx/xfont.c
+++ b/xorg-server/glx/xfont.c
@@ -50,8 +50,6 @@
#include <windowstr.h>
#include <dixfontstr.h>
-extern XID clientErrorValue; /* imported kludge from dix layer */
-
/*
** Make a single GL bitmap from a single X glyph
*/
@@ -80,7 +78,7 @@ static int __glXMakeBitmapFromGlyph(FontPtr font, CharInfoPtr pci)
p = buf;
allocbuf = 0;
} else {
- p = (unsigned char *) xalloc(allocBytes);
+ p = (unsigned char *) malloc(allocBytes);
if (!p)
return BadAlloc;
allocbuf = p;
@@ -104,7 +102,7 @@ static int __glXMakeBitmapFromGlyph(FontPtr font, CharInfoPtr pci)
allocbuf ? allocbuf : buf) );
if (allocbuf) {
- xfree(allocbuf);
+ free(allocbuf);
}
return Success;
#undef __GL_CHAR_BUF_SIZE