static int GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag) { GLint compsize, compsize2; GLenum format, type, target; GLboolean swapBytes; __GLXcontext *cx; ClientPtr client = cl->client; int error; __GLX_DECLARE_SWAP_VARIABLES; char *answer, answerBuffer[200]; GLint width = 0, height = 0; cx = __glXForceCurrent(cl, tag, &error); if (!cx) { return error; } __GLX_SWAP_INT(pc + 0); __GLX_SWAP_INT(pc + 4); __GLX_SWAP_INT(pc + 8); format = *(GLenum *) (pc + 4); type = *(GLenum *) (pc + 8); target = *(GLenum *) (pc + 0); swapBytes = *(GLboolean *) (pc + 12); /* target must be SEPARABLE_2D, however I guess we can let the GL barf on this one.... */ CALL_GetConvolutionParameteriv(GET_DISPATCH(), (target, GL_CONVOLUTION_WIDTH, &width)); CALL_GetConvolutionParameteriv(GET_DISPATCH(), (target, GL_CONVOLUTION_HEIGHT, &height)); /* * The two queries above might fail if we're in a state where queries * are illegal, but then width and height would still be zero anyway. */ compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1); compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1); if (compsize < 0) compsize = 0; if (compsize2 < 0) compsize2 = 0; compsize = __GLX_PAD(compsize); compsize2 = __GLX_PAD(compsize2); CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes)); __GLX_GET_ANSWER_BUFFER(answer, cl, compsize + compsize2, 1); __glXClearErrorOccured(); CALL_GetSeparableFilter(GET_DISPATCH(), (*(GLenum *) (pc + 0), *(GLenum *) (pc + 4), *(GLenum *) (pc + 8), answer, answer + compsize, NULL)); if (__glXErrorOccured()) { __GLX_BEGIN_REPLY(0); __GLX_SWAP_REPLY_HEADER(); } else { __GLX_BEGIN_REPLY(compsize + compsize2); __GLX_SWAP_REPLY_HEADER(); __GLX_SWAP_INT(&width); __GLX_SWAP_INT(&height); ((xGLXGetSeparableFilterReply *) & __glXReply)->width = width; ((xGLXGetSeparableFilterReply *) & __glXReply)->height = height; __GLX_SEND_VOID_ARRAY(compsize + compsize2); } return Success; }
void NAME(_gloffset_GetSeparableFilter)(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span) { __GLXcontext * const gc = __glXGetCurrentContext(); if (gc->isDirect) { CALL_GetSeparableFilter(GET_DISPATCH(), (target, format, type, row, column, span)); return; } else { Display *const dpy = gc->currentDpy; const GLuint cmdlen = __GLX_PAD(13); if (dpy != NULL) { const __GLXattribute * const state = gc->client_state_private; xGLXGetSeparableFilterReply reply; GLubyte const *pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetSeparableFilterEXT, cmdlen); unsigned compsize; (void) memcpy((void *) (pc + 0), (void *) (&target), 4); (void) memcpy((void *) (pc + 4), (void *) (&format), 4); (void) memcpy((void *) (pc + 8), (void *) (&type), 4); *(int8_t *) (pc + 12) = state->storePack.swapEndian; (void) _XReply(dpy, (xReply *) & reply, 0, False); compsize = reply.length << 2; if (compsize != 0) { const GLint width = reply.width; const GLint height = reply.height; const GLint widthsize = __glImageSize(width, 1, 1, format, type, 0); const GLint heightsize = __glImageSize(height, 1, 1, format, type, 0); GLubyte * const buf = (GLubyte*) Xmalloc((widthsize > heightsize) ? widthsize : heightsize); if (buf == NULL) { /* Throw data away */ _XEatData(dpy, compsize); __glXSetError(gc, GL_OUT_OF_MEMORY); UnlockDisplay(dpy); SyncHandle(); return; } else { int extra; extra = 4 - (widthsize & 3); _XRead(dpy, (char *)buf, widthsize); if (extra < 4) { _XEatData(dpy, extra); } __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, row); extra = 4 - (heightsize & 3); _XRead(dpy, (char *)buf, heightsize); if (extra < 4) { _XEatData(dpy, extra); } __glEmptyImage(gc, 1, height, 1, 1, format, type, buf, column); Xfree((char*) buf); } } } } }