diff options
Diffstat (limited to 'GL/glx/glxcmds.c')
-rw-r--r-- | GL/glx/glxcmds.c | 75 |
1 files changed, 29 insertions, 46 deletions
diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c index b52528dd4..fdd36e218 100644 --- a/GL/glx/glxcmds.c +++ b/GL/glx/glxcmds.c @@ -1746,9 +1746,10 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc) pc += sz_xGLXRenderReq; left = (req->length << 2) - sz_xGLXRenderReq; while (left > 0) { - __GLXrenderSizeData *entry; + __GLXrenderSizeData entry; int extra; - void (* proc)(GLbyte *); + __GLXdispatchRenderProcPtr proc; + int err; /* ** Verify that the header length and the overall length agree. @@ -1761,41 +1762,27 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc) /* ** Check for core opcodes and grab entry data. */ - if ( (opcode >= __GLX_MIN_RENDER_OPCODE) && - (opcode <= __GLX_MAX_RENDER_OPCODE) ) { - entry = &__glXRenderSizeTable[opcode]; - proc = __glXRenderTable[opcode]; -#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT - } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) && - (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) { - entry = - &__glXRenderSizeTable_EXT[opcode - - __GLX_MIN_RENDER_OPCODE_EXT]; - proc = __glXRenderTable_EXT[opcode - - __GLX_MIN_RENDER_OPCODE_EXT]; -#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */ - } else { + err = __glXGetProtocolSizeData(& Render_dispatch_info, opcode, & entry); + proc = (__GLXdispatchRenderProcPtr) + __glXGetProtocolDecodeFunction(& Render_dispatch_info, opcode, 0); + + if ((err < 0) || (proc == NULL)) { client->errorValue = commandsDone; return __glXError(GLXBadRenderRequest); } - if (!entry->bytes) { - /* unused opcode */ - client->errorValue = commandsDone; - return __glXError(GLXBadRenderRequest); - } - if (entry->varsize) { + if (entry.varsize) { /* variable size command */ - extra = (*entry->varsize)(pc + __GLX_RENDER_HDR_SIZE, False); + extra = (*entry.varsize)(pc + __GLX_RENDER_HDR_SIZE, False); if (extra < 0) { extra = 0; } - if (cmdlen != __GLX_PAD(entry->bytes + extra)) { + if (cmdlen != __GLX_PAD(entry.bytes + extra)) { return BadLength; } } else { /* constant size command */ - if (cmdlen != __GLX_PAD(entry->bytes)) { + if (cmdlen != __GLX_PAD(entry.bytes)) { return BadLength; } } @@ -1827,7 +1814,7 @@ int __glXDisp_RenderLarge(__GLXclientState *cl, GLbyte *pc) xGLXRenderLargeReq *req; ClientPtr client= cl->client; GLuint dataBytes; - void (*proc)(GLbyte *); + __GLXdispatchRenderProcPtr proc; __GLXrenderLargeHeader *hdr; __GLXcontext *glxc; int error; @@ -1860,8 +1847,10 @@ int __glXDisp_RenderLarge(__GLXclientState *cl, GLbyte *pc) pc += sz_xGLXRenderLargeReq; if (cl->largeCmdRequestsSoFar == 0) { - __GLXrenderSizeData *entry; + __GLXrenderSizeData entry; int extra, cmdlen; + int err; + /* ** This is the first request of a multi request command. ** Make enough space in the buffer, then copy the entire request. @@ -1878,42 +1867,36 @@ int __glXDisp_RenderLarge(__GLXclientState *cl, GLbyte *pc) /* ** Check for core opcodes and grab entry data. */ - if ( (opcode >= __GLX_MIN_RENDER_OPCODE) && - (opcode <= __GLX_MAX_RENDER_OPCODE) ) { - entry = &__glXRenderSizeTable[opcode]; -#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT - } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) && - (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) { - opcode -= __GLX_MIN_RENDER_OPCODE_EXT; - entry = &__glXRenderSizeTable_EXT[opcode]; -#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */ - } else { + err = __glXGetProtocolSizeData(& Render_dispatch_info, opcode, & entry); + if (err < 0) { client->errorValue = opcode; return __glXError(GLXBadLargeRequest); } - if (!entry->bytes) { - /* unused opcode */ - client->errorValue = opcode; - return __glXError(GLXBadLargeRequest); - } - if (entry->varsize) { + proc = (__GLXdispatchRenderProcPtr) + __glXGetProtocolDecodeFunction(& Render_dispatch_info, opcode, 0); + if (proc == NULL) { + client->errorValue = opcode; + return __glXError(GLXBadLargeRequest); + } + + if (entry.varsize) { /* ** If it's a variable-size command (a command whose length must ** be computed from its parameters), all the parameters needed ** will be in the 1st request, so it's okay to do this. */ - extra = (*entry->varsize)(pc + __GLX_RENDER_LARGE_HDR_SIZE, False); + extra = (*entry.varsize)(pc + __GLX_RENDER_LARGE_HDR_SIZE, False); if (extra < 0) { extra = 0; } /* large command's header is 4 bytes longer, so add 4 */ - if (cmdlen != __GLX_PAD(entry->bytes + 4 + extra)) { + if (cmdlen != __GLX_PAD(entry.bytes + 4 + extra)) { return BadLength; } } else { /* constant size command */ - if (cmdlen != __GLX_PAD(entry->bytes + 4)) { + if (cmdlen != __GLX_PAD(entry.bytes + 4)) { return BadLength; } } |