singlepix.c revision 64085b2c2ca20609255962a54c38753e976996a1
158b72103d3837fa9245120e17bd4d7083a93f288RALOVICH, Kristóf/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */ 2cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 3dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 4dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 5dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 6dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Permission is hereby granted, free of charge, to any person obtaining a 7dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * copy of this software and associated documentation files (the "Software"), 8dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * to deal in the Software without restriction, including without limitation 9dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * and/or sell copies of the Software, and to permit persons to whom the 11dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Software is furnished to do so, subject to the following conditions: 12dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 13dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * The above copyright notice including the dates of first publication and 14dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * either this permission notice or a reference to 15dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * http://oss.sgi.com/projects/FreeB/ 16dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall be included in all copies or substantial portions of the Software. 17dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 18dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 23dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SOFTWARE. 25dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 26dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Except as contained in this notice, the name of Silicon Graphics, Inc. 27dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall not be used in advertising or otherwise to promote the sale, use or 28dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * other dealings in this Software without prior written authorization from 29dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Silicon Graphics, Inc. 30dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson */ 31cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 32cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "packsingle.h" 33f434e07a6ac849cd127d70eee8b3349da7cfb360Ian Romanick#include "indirect.h" 34f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick#include "dispatch.h" 35461651357713b1408400669d6a809f2e367182feIan Romanick#include "glapi.h" 36f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick#include "glthread.h" 37f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick#include "glapioffsets.h" 38f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick#include <GL/glxproto.h> 39cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 4064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristófvoid 4164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf__indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type, 4264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLvoid * row, GLvoid * column, GLvoid * span) 43cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 4464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_DECLARE_VARIABLES(); 4564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const __GLXattribute *state; 4664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf xGLXGetSeparableFilterReply reply; 4764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLubyte *rowBuf, *colBuf; 4864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 4964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (!dpy) 5064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf return; 5164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_LOAD_VARIABLES(); 5264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf state = gc->client_state_private; 5364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 5464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* Send request */ 5564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13)); 5664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_PUT_LONG(0, target); 5764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_PUT_LONG(4, format); 5864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_PUT_LONG(8, type); 5964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_PUT_CHAR(12, state->storePack.swapEndian); 6064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_READ_XREPLY(); 6164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf compsize = reply.length << 2; 6264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 6364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (compsize != 0) { 6464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLint width, height; 6564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLint widthsize, heightsize; 6664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 6764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf width = reply.width; 6864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf height = reply.height; 6964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 7064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf widthsize = __glImageSize(width, 1, 1, format, type, 0); 7164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf heightsize = __glImageSize(height, 1, 1, format, type, 0); 7264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 7364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* Allocate a holding buffer to transform the data from */ 7464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf rowBuf = (GLubyte *) Xmalloc(widthsize); 7564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (!rowBuf) { 7664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* Throw data away */ 7764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XEatData(dpy, compsize); 7864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glXSetError(gc, GL_OUT_OF_MEMORY); 7964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf UnlockDisplay(dpy); 8064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf SyncHandle(); 8164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf return; 8264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 8364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf else { 8464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_GET_CHAR_ARRAY(((char *) rowBuf), widthsize); 8564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row); 8664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf Xfree((char *) rowBuf); 8764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 8864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf colBuf = (GLubyte *) Xmalloc(heightsize); 8964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (!colBuf) { 9064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* Throw data away */ 9164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XEatData(dpy, compsize - __GLX_PAD(widthsize)); 9264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glXSetError(gc, GL_OUT_OF_MEMORY); 9364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf UnlockDisplay(dpy); 9464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf SyncHandle(); 9564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf return; 9664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 9764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf else { 9864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_GET_CHAR_ARRAY(((char *) colBuf), heightsize); 9964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column); 10064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf Xfree((char *) colBuf); 10164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 10264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 10364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf else { 10464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* 10564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf ** don't modify user's buffer. 10664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf */ 10764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 10864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLX_SINGLE_END(); 10964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 110cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 111f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick 112f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick 113f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick#define CONCAT(a,b) a ## b 114f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick#define NAME(o) CONCAT(gl_dispatch_stub_, o) 115f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick 11664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristófvoid NAME(_gloffset_GetSeparableFilter) (GLenum target, GLenum format, 11764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLenum type, GLvoid * row, 11864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLvoid * column, GLvoid * span) 119f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick{ 12064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __GLXcontext *const gc = __glXGetCurrentContext(); 121f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick 122919ec22ecf72aa163e1b97d8c7381002131ed32cJeremy Huddleston#ifdef GLX_DIRECT_RENDERING 12364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (gc->driContext) { 12464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf CALL_GetSeparableFilter(GET_DISPATCH(), 12564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf (target, format, type, row, column, span)); 12664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf return; 12764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 12864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf else 129919ec22ecf72aa163e1b97d8c7381002131ed32cJeremy Huddleston#endif 13064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf { 13164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf Display *const dpy = gc->currentDpy; 13264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const GLuint cmdlen = __GLX_PAD(13); 13364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 13464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (dpy != NULL) { 13564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const __GLXattribute *const state = gc->client_state_private; 13664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf xGLXGetSeparableFilterReply reply; 13764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLubyte const *pc = 13864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, 13964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf X_GLvop_GetSeparableFilterEXT, cmdlen); 14064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf unsigned compsize; 14164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 14264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 14364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf (void) memcpy((void *) (pc + 0), (void *) (&target), 4); 14464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf (void) memcpy((void *) (pc + 4), (void *) (&format), 4); 14564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf (void) memcpy((void *) (pc + 8), (void *) (&type), 4); 14664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf *(int8_t *) (pc + 12) = state->storePack.swapEndian; 14764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 14864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf (void) _XReply(dpy, (xReply *) & reply, 0, False); 14964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 15064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf compsize = reply.length << 2; 15164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 15264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (compsize != 0) { 15364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const GLint width = reply.width; 15464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const GLint height = reply.height; 15564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const GLint widthsize = 15664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glImageSize(width, 1, 1, format, type, 0); 15764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf const GLint heightsize = 15864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glImageSize(height, 1, 1, format, type, 0); 15964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf GLubyte *const buf = 16064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf (GLubyte *) Xmalloc((widthsize > heightsize) ? widthsize : 16164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf heightsize); 16264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 16364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (buf == NULL) { 16464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf /* Throw data away */ 16564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XEatData(dpy, compsize); 16664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glXSetError(gc, GL_OUT_OF_MEMORY); 16764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 16864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf UnlockDisplay(dpy); 16964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf SyncHandle(); 17064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf return; 17164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 17264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf else { 17364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf int extra; 17464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 17564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf extra = 4 - (widthsize & 3); 17664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XRead(dpy, (char *) buf, widthsize); 17764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (extra < 4) { 17864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XEatData(dpy, extra); 17964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 18064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 18164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, row); 18264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 18364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf extra = 4 - (heightsize & 3); 18464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XRead(dpy, (char *) buf, heightsize); 18564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf if (extra < 4) { 18664085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf _XEatData(dpy, extra); 18764085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 18864085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 18964085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf __glEmptyImage(gc, 1, height, 1, 1, format, type, buf, column); 19064085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf 19164085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf Xfree((char *) buf); 19264085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 19364085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 19464085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 19564085b2c2ca20609255962a54c38753e976996a1RALOVICH, Kristóf } 196f3f51bc844c8749250724d164722402cb9a07dc7Ian Romanick} 197