1cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 2dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 5dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Permission is hereby granted, free of charge, to any person obtaining a 6dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * copy of this software and associated documentation files (the "Software"), 7dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * to deal in the Software without restriction, including without limitation 8dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * and/or sell copies of the Software, and to permit persons to whom the 10dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Software is furnished to do so, subject to the following conditions: 11dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 12dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * The above copyright notice including the dates of first publication and 13dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * either this permission notice or a reference to 14dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * http://oss.sgi.com/projects/FreeB/ 15dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall be included in all copies or substantial portions of the Software. 16dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 17dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SOFTWARE. 24dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 25dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Except as contained in this notice, the name of Silicon Graphics, Inc. 26dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall not be used in advertising or otherwise to promote the sale, use or 27dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * other dealings in this Software without prior written authorization from 28dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Silicon Graphics, Inc. 29dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson */ 30cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 31cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "packsingle.h" 32f434e07a6ac849cd127d70eee8b3349da7cfb360Ian Romanick#include "indirect.h" 33461651357713b1408400669d6a809f2e367182feIan Romanick#include "glapi.h" 34f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick#include <GL/glxproto.h> 35cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristófvoid 3764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf__indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type, 3864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLvoid * row, GLvoid * column, GLvoid * span) 39cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 4064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_DECLARE_VARIABLES(); 4164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const __GLXattribute *state; 4264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf xGLXGetSeparableFilterReply reply; 4364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLubyte *rowBuf, *colBuf; 4464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 4564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (!dpy) 4664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf return; 4764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_LOAD_VARIABLES(); 4864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf state = gc->client_state_private; 4964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 5064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* Send request */ 5164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13)); 5264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_PUT_LONG(0, target); 5364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_PUT_LONG(4, format); 5464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_PUT_LONG(8, type); 5564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_PUT_CHAR(12, state->storePack.swapEndian); 5664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_READ_XREPLY(); 5764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf compsize = reply.length << 2; 5864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 5964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (compsize != 0) { 6064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLint width, height; 6164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLint widthsize, heightsize; 6264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 6364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf width = reply.width; 6464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf height = reply.height; 6564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 6664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf widthsize = __glImageSize(width, 1, 1, format, type, 0); 6764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf heightsize = __glImageSize(height, 1, 1, format, type, 0); 6864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 6964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* Allocate a holding buffer to transform the data from */ 702b7a972e3f36bfcdc6fbe2b59d7ffdcde49c9405Matt Turner rowBuf = malloc(widthsize); 7164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (!rowBuf) { 7264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* Throw data away */ 7364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XEatData(dpy, compsize); 7464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glXSetError(gc, GL_OUT_OF_MEMORY); 7564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf UnlockDisplay(dpy); 7664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf SyncHandle(); 7764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf return; 7864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 7964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf else { 8064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_GET_CHAR_ARRAY(((char *) rowBuf), widthsize); 8164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row); 827c7b7b068b1d0dc8e14b87dab5dbd4108f874f74Matt Turner free((char *) rowBuf); 8364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 842b7a972e3f36bfcdc6fbe2b59d7ffdcde49c9405Matt Turner colBuf = malloc(heightsize); 8564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (!colBuf) { 8664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* Throw data away */ 8764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XEatData(dpy, compsize - __GLX_PAD(widthsize)); 8864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glXSetError(gc, GL_OUT_OF_MEMORY); 8964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf UnlockDisplay(dpy); 9064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf SyncHandle(); 9164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf return; 9264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 9364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf else { 9464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_GET_CHAR_ARRAY(((char *) colBuf), heightsize); 9564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column); 967c7b7b068b1d0dc8e14b87dab5dbd4108f874f74Matt Turner free((char *) colBuf); 9764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 9864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 9964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf else { 10064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* 10164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf ** don't modify user's buffer. 10264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf */ 10364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 10464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_END(); 10564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 106cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 107f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick 108f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick 109e4dbfa44ed018d124e1531077d506c8c914c1a51Chia-I Wu/* it is defined to gl_dispatch_stub_NNN in indirect.h */ 110e4dbfa44ed018d124e1531077d506c8c914c1a51Chia-I Wuvoid gl_dispatch_stub_GetSeparableFilterEXT (GLenum target, GLenum format, 111e4dbfa44ed018d124e1531077d506c8c914c1a51Chia-I Wu GLenum type, GLvoid * row, 112e4dbfa44ed018d124e1531077d506c8c914c1a51Chia-I Wu GLvoid * column, GLvoid * span) 113f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick{ 114c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg struct glx_context *const gc = __glXGetCurrentContext(); 115f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick 11680b280db883edc9550484dba03bd5c124b6a9bf9Jeremy Huddleston#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) 117c491e585e43d48a2aeec96ccc4008da6c443fb42Kristian Høgsberg if (gc->isDirect) { 11899fee476a102be898a1a093c037e06382f90a5b9Ian Romanick const _glapi_proc *const table = (_glapi_proc *) GET_DISPATCH(); 11999fee476a102be898a1a093c037e06382f90a5b9Ian Romanick PFNGLGETSEPARABLEFILTEREXTPROC p = 12099fee476a102be898a1a093c037e06382f90a5b9Ian Romanick (PFNGLGETSEPARABLEFILTEREXTPROC) table[359]; 12199fee476a102be898a1a093c037e06382f90a5b9Ian Romanick 12299fee476a102be898a1a093c037e06382f90a5b9Ian Romanick p(target, format, type, row, column, span); 12364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf return; 12464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 12564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf else 126919ec22ecf72aa163e1b97d8c7381002131ed32cJeremy Huddleston#endif 12764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf { 12864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf Display *const dpy = gc->currentDpy; 12964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const GLuint cmdlen = __GLX_PAD(13); 13064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 13164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (dpy != NULL) { 13264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const __GLXattribute *const state = gc->client_state_private; 13364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf xGLXGetSeparableFilterReply reply; 13464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLubyte const *pc = 13564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, 13664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf X_GLvop_GetSeparableFilterEXT, cmdlen); 13764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf unsigned compsize; 13864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 13964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 14064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf (void) memcpy((void *) (pc + 0), (void *) (&target), 4); 14164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf (void) memcpy((void *) (pc + 4), (void *) (&format), 4); 14264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf (void) memcpy((void *) (pc + 8), (void *) (&type), 4); 14364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf *(int8_t *) (pc + 12) = state->storePack.swapEndian; 14464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 14564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf (void) _XReply(dpy, (xReply *) & reply, 0, False); 14664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 14764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf compsize = reply.length << 2; 14864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 14964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (compsize != 0) { 15064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const GLint width = reply.width; 15164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const GLint height = reply.height; 15264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const GLint widthsize = 15364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glImageSize(width, 1, 1, format, type, 0); 15464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const GLint heightsize = 15564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glImageSize(height, 1, 1, format, type, 0); 15664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLubyte *const buf = 1572b7a972e3f36bfcdc6fbe2b59d7ffdcde49c9405Matt Turner malloc((widthsize > heightsize) ? widthsize : heightsize); 15864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 15964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (buf == NULL) { 16064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* Throw data away */ 16164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XEatData(dpy, compsize); 16264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glXSetError(gc, GL_OUT_OF_MEMORY); 16364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 16464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf UnlockDisplay(dpy); 16564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf SyncHandle(); 16664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf return; 16764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 16864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf else { 16964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf int extra; 17064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 17164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf extra = 4 - (widthsize & 3); 17264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XRead(dpy, (char *) buf, widthsize); 17364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (extra < 4) { 17464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XEatData(dpy, extra); 17564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 17664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 17764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, row); 17864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 17964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf extra = 4 - (heightsize & 3); 18064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XRead(dpy, (char *) buf, heightsize); 18164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (extra < 4) { 18264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XEatData(dpy, extra); 18364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 18464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 18564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glEmptyImage(gc, 1, height, 1, 1, format, type, buf, column); 18664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 1877c7b7b068b1d0dc8e14b87dab5dbd4108f874f74Matt Turner free((char *) buf); 18864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 18964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 19064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 19164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 192f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick} 193