diff options
Diffstat (limited to 'xorg-server/glx/glxcmds.c')
-rw-r--r-- | xorg-server/glx/glxcmds.c | 129 |
1 files changed, 71 insertions, 58 deletions
diff --git a/xorg-server/glx/glxcmds.c b/xorg-server/glx/glxcmds.c index 5b7a628cc..d5d14b7a6 100644 --- a/xorg-server/glx/glxcmds.c +++ b/xorg-server/glx/glxcmds.c @@ -31,6 +31,7 @@ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif +#include "glheader.h" #include <string.h> #include <assert.h> @@ -215,6 +216,12 @@ __glXdirectContextCreate(__GLXscreen * screen, return context; } +void FlushContext(__GLXcontext *cx) +{ + CALL_Flush( GET_DISPATCH(), () ); + cx->hasUnflushedCommands = GL_FALSE; +} + /** * Create a GL context with the given properties. This routine is used * to implement \c glXCreateContext, \c glXCreateNewContext, and @@ -500,7 +507,7 @@ __glXGetDrawable(__GLXcontext * glxc, GLXDrawable drawId, ClientPtr client, return NULL; } - if (pDraw->pScreen != glxc->pGlxScreen->pScreen) { + if (!glxc || pDraw->pScreen != glxc->pGlxScreen->pScreen) { client->errorValue = pDraw->pScreen->myNum; *error = BadMatch; return NULL; @@ -513,6 +520,12 @@ __glXGetDrawable(__GLXcontext * glxc, GLXDrawable drawId, ClientPtr client, pDraw, drawId, GLX_DRAWABLE_WINDOW, drawId, glxc->config); + if (!pGlxDraw) + { + client->errorValue = drawId; + *error = BadMatch; + return NULL; + } /* since we are creating the drawablePrivate, drawId should be new */ if (!AddResource(drawId, __glXDrawableRes, pGlxDraw)) { @@ -651,12 +664,12 @@ DoMakeCurrent(__GLXclientState * cl, StopUsingContext(prevglxc); - reply = (xGLXMakeCurrentReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0, - .contextTag = 0 - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = 0; + reply.contextTag = 0; + if (glxc) { StartUsingContext(cl, glxc); @@ -722,12 +735,12 @@ __glXDisp_IsDirect(__GLXclientState * cl, GLbyte * pc) if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err)) return err; - reply = (xGLXIsDirectReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0, - .isDirect = glxc->isDirect - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = 0; + reply.isDirect = glxc->isDirect; + if (client->swapped) { __glXSwapIsDirectReply(client, &reply); @@ -759,13 +772,13 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc) ** client if it wants to work with older clients; however, in this ** implementation the server just returns its version number. */ - reply = (xGLXQueryVersionReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0, - .majorVersion = glxMajorVersion, - .minorVersion = glxMinorVersion - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = 0; + reply.majorVersion = glxMajorVersion; + reply.minorVersion = glxMinorVersion; + if (client->swapped) { __glXSwapQueryVersionReply(client, &reply); @@ -939,14 +952,14 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc) if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; - reply = (xGLXGetVisualConfigsReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = (pGlxScreen->numVisuals * + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = (pGlxScreen->numVisuals * __GLX_SIZE_CARD32 * GLX_VIS_CONFIG_TOTAL) >> 2, - .numVisuals = pGlxScreen->numVisuals, - .numProps = GLX_VIS_CONFIG_TOTAL - }; + reply.numVisuals = pGlxScreen->numVisuals; + reply.numProps = GLX_VIS_CONFIG_TOTAL; + if (client->swapped) { __GLX_SWAP_SHORT(&reply.sequenceNumber); @@ -1054,13 +1067,13 @@ DoGetFBConfigs(__GLXclientState * cl, unsigned screen) if (!validGlxScreen(cl->client, screen, &pGlxScreen, &err)) return err; - reply = (xGLXGetFBConfigsReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = __GLX_FBCONFIG_ATTRIBS_LENGTH * pGlxScreen->numFBConfigs, - .numFBConfigs = pGlxScreen->numFBConfigs, - .numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = __GLX_FBCONFIG_ATTRIBS_LENGTH * pGlxScreen->numFBConfigs; + reply.numFBConfigs = pGlxScreen->numFBConfigs; + reply.numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS; + if (client->swapped) { __GLX_SWAP_SHORT(&reply.sequenceNumber); @@ -1689,12 +1702,12 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId) return err; nProps = 3; - reply = (xGLXQueryContextInfoEXTReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = nProps << 1, - .n = nProps - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = nProps << 1; + reply.n = nProps; + nReplyBytes = reply.length << 2; sendBuf = (int *) malloc((size_t) nReplyBytes); @@ -1898,12 +1911,12 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId) return error; numAttribs = 3; - reply = (xGLXGetDrawableAttributesReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = numAttribs << 1, - .numAttribs = numAttribs - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = numAttribs << 1; + reply.numAttribs = numAttribs; + attributes[0] = GLX_TEXTURE_TARGET_EXT; attributes[1] = pGlxDraw->target == GL_TEXTURE_2D ? GLX_TEXTURE_2D_EXT : @@ -2339,12 +2352,12 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc) n = strlen(pGlxScreen->GLXextensions) + 1; length = __GLX_PAD(n) >> 2; - reply = (xGLXQueryExtensionsStringReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = length, - .n = n - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = length; + reply.n = n; + /* Allocate buffer to make sure it's a multiple of 4 bytes big. */ buf = calloc(length, 4); @@ -2402,12 +2415,12 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc) n = strlen(ptr) + 1; length = __GLX_PAD(n) >> 2; - reply = (xGLXQueryServerStringReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = length, - .n = n - }; + + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.length = length; + reply.n = n; + buf = calloc(length, 4); if (buf == NULL) { |