14642e01fSmrg/* 24642e01fSmrg * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 34642e01fSmrg * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 44642e01fSmrg * 54642e01fSmrg * Permission is hereby granted, free of charge, to any person obtaining a 64642e01fSmrg * copy of this software and associated documentation files (the "Software"), 74642e01fSmrg * to deal in the Software without restriction, including without limitation 84642e01fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 94642e01fSmrg * and/or sell copies of the Software, and to permit persons to whom the 104642e01fSmrg * Software is furnished to do so, subject to the following conditions: 114642e01fSmrg * 124642e01fSmrg * The above copyright notice including the dates of first publication and 134642e01fSmrg * either this permission notice or a reference to 144642e01fSmrg * http://oss.sgi.com/projects/FreeB/ 154642e01fSmrg * shall be included in all copies or substantial portions of the Software. 164642e01fSmrg * 174642e01fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 184642e01fSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 194642e01fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 204642e01fSmrg * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 214642e01fSmrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 224642e01fSmrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 234642e01fSmrg * SOFTWARE. 244642e01fSmrg * 254642e01fSmrg * Except as contained in this notice, the name of Silicon Graphics, Inc. 264642e01fSmrg * shall not be used in advertising or otherwise to promote the sale, use or 274642e01fSmrg * other dealings in this Software without prior written authorization from 284642e01fSmrg * Silicon Graphics, Inc. 294642e01fSmrg */ 304642e01fSmrg 314642e01fSmrg#ifdef HAVE_DIX_CONFIG_H 324642e01fSmrg#include <dix-config.h> 334642e01fSmrg#endif 344642e01fSmrg 354642e01fSmrg#include "glxserver.h" 364642e01fSmrg#include "glxext.h" 374642e01fSmrg#include "singlesize.h" 384642e01fSmrg#include "unpack.h" 394642e01fSmrg#include "indirect_dispatch.h" 404642e01fSmrg#include "indirect_size_get.h" 414642e01fSmrg 42f7df2e56Smrgint 43f7df2e56Smrg__glXDispSwap_ReadPixels(__GLXclientState * cl, GLbyte * pc) 444642e01fSmrg{ 454642e01fSmrg GLsizei width, height; 464642e01fSmrg GLenum format, type; 474642e01fSmrg GLboolean swapBytes, lsbFirst; 484642e01fSmrg GLint compsize; 49f7df2e56Smrg 504642e01fSmrg __GLX_DECLARE_SWAP_VARIABLES; 514642e01fSmrg __GLXcontext *cx; 524642e01fSmrg ClientPtr client = cl->client; 534642e01fSmrg int error; 544642e01fSmrg char *answer, answerBuffer[200]; 557e31ba66Smrg xGLXSingleReply reply = { 0, }; 564642e01fSmrg 570b0d8713Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 28); 580b0d8713Smrg 59f7df2e56Smrg __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag); 604642e01fSmrg cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); 614642e01fSmrg if (!cx) { 62f7df2e56Smrg return error; 634642e01fSmrg } 644642e01fSmrg 654642e01fSmrg pc += __GLX_SINGLE_HDR_SIZE; 66f7df2e56Smrg __GLX_SWAP_INT(pc + 0); 67f7df2e56Smrg __GLX_SWAP_INT(pc + 4); 68f7df2e56Smrg __GLX_SWAP_INT(pc + 8); 69f7df2e56Smrg __GLX_SWAP_INT(pc + 12); 70f7df2e56Smrg __GLX_SWAP_INT(pc + 16); 71f7df2e56Smrg __GLX_SWAP_INT(pc + 20); 72f7df2e56Smrg 73f7df2e56Smrg width = *(GLsizei *) (pc + 8); 74f7df2e56Smrg height = *(GLsizei *) (pc + 12); 75f7df2e56Smrg format = *(GLenum *) (pc + 16); 76f7df2e56Smrg type = *(GLenum *) (pc + 20); 77f7df2e56Smrg swapBytes = *(GLboolean *) (pc + 24); 78f7df2e56Smrg lsbFirst = *(GLboolean *) (pc + 25); 79f7df2e56Smrg compsize = __glReadPixels_size(format, type, width, height); 800b0d8713Smrg if (compsize < 0) 810b0d8713Smrg return BadLength; 824642e01fSmrg 83f7df2e56Smrg glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); 84f7df2e56Smrg glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst); 85f7df2e56Smrg __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1); 864642e01fSmrg __glXClearErrorOccured(); 87f7df2e56Smrg glReadPixels(*(GLint *) (pc + 0), *(GLint *) (pc + 4), 88f7df2e56Smrg *(GLsizei *) (pc + 8), *(GLsizei *) (pc + 12), 89f7df2e56Smrg *(GLenum *) (pc + 16), *(GLenum *) (pc + 20), answer); 904642e01fSmrg 914642e01fSmrg if (__glXErrorOccured()) { 92f7df2e56Smrg __GLX_BEGIN_REPLY(0); 93f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 94f7df2e56Smrg __GLX_SEND_HEADER(); 95f7df2e56Smrg } 96f7df2e56Smrg else { 97f7df2e56Smrg __GLX_BEGIN_REPLY(compsize); 98f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 99f7df2e56Smrg __GLX_SEND_HEADER(); 100f7df2e56Smrg __GLX_SEND_VOID_ARRAY(compsize); 1014642e01fSmrg } 1024642e01fSmrg return Success; 1034642e01fSmrg} 1044642e01fSmrg 105f7df2e56Smrgint 106f7df2e56Smrg__glXDispSwap_GetTexImage(__GLXclientState * cl, GLbyte * pc) 1074642e01fSmrg{ 1084642e01fSmrg GLint level, compsize; 1094642e01fSmrg GLenum format, type, target; 1104642e01fSmrg GLboolean swapBytes; 111f7df2e56Smrg 1124642e01fSmrg __GLX_DECLARE_SWAP_VARIABLES; 1134642e01fSmrg __GLXcontext *cx; 1144642e01fSmrg ClientPtr client = cl->client; 1154642e01fSmrg int error; 1164642e01fSmrg char *answer, answerBuffer[200]; 117f7df2e56Smrg GLint width = 0, height = 0, depth = 1; 1187e31ba66Smrg xGLXSingleReply reply = { 0, }; 1194642e01fSmrg 1200b0d8713Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 20); 1210b0d8713Smrg 122f7df2e56Smrg __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag); 1234642e01fSmrg cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); 1244642e01fSmrg if (!cx) { 125f7df2e56Smrg return error; 1264642e01fSmrg } 1274642e01fSmrg 1284642e01fSmrg pc += __GLX_SINGLE_HDR_SIZE; 129f7df2e56Smrg __GLX_SWAP_INT(pc + 0); 130f7df2e56Smrg __GLX_SWAP_INT(pc + 4); 131f7df2e56Smrg __GLX_SWAP_INT(pc + 8); 132f7df2e56Smrg __GLX_SWAP_INT(pc + 12); 133f7df2e56Smrg 134f7df2e56Smrg level = *(GLint *) (pc + 4); 135f7df2e56Smrg format = *(GLenum *) (pc + 8); 136f7df2e56Smrg type = *(GLenum *) (pc + 12); 137f7df2e56Smrg target = *(GLenum *) (pc + 0); 138f7df2e56Smrg swapBytes = *(GLboolean *) (pc + 16); 139f7df2e56Smrg 140f7df2e56Smrg glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width); 141f7df2e56Smrg glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height); 142f7df2e56Smrg if (target == GL_TEXTURE_3D) { 143f7df2e56Smrg glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth); 1444642e01fSmrg } 1454642e01fSmrg /* 1464642e01fSmrg * The three queries above might fail if we're in a state where queries 1474642e01fSmrg * are illegal, but then width, height, and depth would still be zero anyway. 1484642e01fSmrg */ 149f7df2e56Smrg compsize = 150f7df2e56Smrg __glGetTexImage_size(target, level, format, type, width, height, depth); 1510b0d8713Smrg if (compsize < 0) 1520b0d8713Smrg return BadLength; 1534642e01fSmrg 154f7df2e56Smrg glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); 155f7df2e56Smrg __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1); 1564642e01fSmrg __glXClearErrorOccured(); 157f7df2e56Smrg glGetTexImage(*(GLenum *) (pc + 0), *(GLint *) (pc + 4), 158f7df2e56Smrg *(GLenum *) (pc + 8), *(GLenum *) (pc + 12), answer); 1594642e01fSmrg 1604642e01fSmrg if (__glXErrorOccured()) { 161f7df2e56Smrg __GLX_BEGIN_REPLY(0); 162f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 163f7df2e56Smrg __GLX_SEND_HEADER(); 164f7df2e56Smrg } 165f7df2e56Smrg else { 166f7df2e56Smrg __GLX_BEGIN_REPLY(compsize); 167f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 168f7df2e56Smrg __GLX_SWAP_INT(&width); 169f7df2e56Smrg __GLX_SWAP_INT(&height); 170f7df2e56Smrg __GLX_SWAP_INT(&depth); 1717e31ba66Smrg ((xGLXGetTexImageReply *) &reply)->width = width; 1727e31ba66Smrg ((xGLXGetTexImageReply *) &reply)->height = height; 1737e31ba66Smrg ((xGLXGetTexImageReply *) &reply)->depth = depth; 174f7df2e56Smrg __GLX_SEND_HEADER(); 175f7df2e56Smrg __GLX_SEND_VOID_ARRAY(compsize); 1764642e01fSmrg } 1774642e01fSmrg return Success; 1784642e01fSmrg} 1794642e01fSmrg 180f7df2e56Smrgint 181f7df2e56Smrg__glXDispSwap_GetPolygonStipple(__GLXclientState * cl, GLbyte * pc) 1824642e01fSmrg{ 1834642e01fSmrg GLboolean lsbFirst; 1844642e01fSmrg __GLXcontext *cx; 1854642e01fSmrg ClientPtr client = cl->client; 1864642e01fSmrg int error; 1874642e01fSmrg GLubyte answerBuffer[200]; 1884642e01fSmrg char *answer; 1897e31ba66Smrg xGLXSingleReply reply = { 0, }; 190f7df2e56Smrg 1914642e01fSmrg __GLX_DECLARE_SWAP_VARIABLES; 1924642e01fSmrg 1930b0d8713Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 4); 1940b0d8713Smrg 195f7df2e56Smrg __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag); 1964642e01fSmrg cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); 1974642e01fSmrg if (!cx) { 198f7df2e56Smrg return error; 1994642e01fSmrg } 2004642e01fSmrg pc += __GLX_SINGLE_HDR_SIZE; 201f7df2e56Smrg lsbFirst = *(GLboolean *) (pc + 0); 2024642e01fSmrg 203f7df2e56Smrg glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst); 204f7df2e56Smrg __GLX_GET_ANSWER_BUFFER(answer, cl, 128, 1); 2054642e01fSmrg 2064642e01fSmrg __glXClearErrorOccured(); 207f7df2e56Smrg glGetPolygonStipple((GLubyte *) answer); 2084642e01fSmrg if (__glXErrorOccured()) { 209f7df2e56Smrg __GLX_BEGIN_REPLY(0); 210f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 211f7df2e56Smrg __GLX_SEND_HEADER(); 212f7df2e56Smrg } 213f7df2e56Smrg else { 214f7df2e56Smrg __GLX_BEGIN_REPLY(128); 215f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 216f7df2e56Smrg __GLX_SEND_HEADER(); 217f7df2e56Smrg __GLX_SEND_BYTE_ARRAY(128); 2184642e01fSmrg } 2194642e01fSmrg return Success; 2204642e01fSmrg} 2214642e01fSmrg 222f7df2e56Smrgstatic int 223f7df2e56SmrgGetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag) 2244642e01fSmrg{ 2254642e01fSmrg GLint compsize, compsize2; 2264642e01fSmrg GLenum format, type, target; 2274642e01fSmrg GLboolean swapBytes; 2284642e01fSmrg __GLXcontext *cx; 2294642e01fSmrg ClientPtr client = cl->client; 2304642e01fSmrg int error; 231f7df2e56Smrg 2324642e01fSmrg __GLX_DECLARE_SWAP_VARIABLES; 2334642e01fSmrg char *answer, answerBuffer[200]; 234f7df2e56Smrg GLint width = 0, height = 0; 2357e31ba66Smrg xGLXSingleReply reply = { 0, }; 2364642e01fSmrg 2374642e01fSmrg cx = __glXForceCurrent(cl, tag, &error); 2384642e01fSmrg if (!cx) { 239f7df2e56Smrg return error; 2404642e01fSmrg } 2414642e01fSmrg 242f7df2e56Smrg __GLX_SWAP_INT(pc + 0); 243f7df2e56Smrg __GLX_SWAP_INT(pc + 4); 244f7df2e56Smrg __GLX_SWAP_INT(pc + 8); 2454642e01fSmrg 246f7df2e56Smrg format = *(GLenum *) (pc + 4); 247f7df2e56Smrg type = *(GLenum *) (pc + 8); 248f7df2e56Smrg target = *(GLenum *) (pc + 0); 249f7df2e56Smrg swapBytes = *(GLboolean *) (pc + 12); 2504642e01fSmrg 2514642e01fSmrg /* target must be SEPARABLE_2D, however I guess we can let the GL 2524642e01fSmrg barf on this one.... */ 2534642e01fSmrg 254f7df2e56Smrg glGetConvolutionParameteriv(target, GL_CONVOLUTION_WIDTH, &width); 255f7df2e56Smrg glGetConvolutionParameteriv(target, GL_CONVOLUTION_HEIGHT, &height); 2564642e01fSmrg /* 2574642e01fSmrg * The two queries above might fail if we're in a state where queries 2584642e01fSmrg * are illegal, but then width and height would still be zero anyway. 2594642e01fSmrg */ 260f7df2e56Smrg compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1); 261f7df2e56Smrg compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1); 2624642e01fSmrg 2630b0d8713Smrg if ((compsize = safe_pad(compsize)) < 0) 2640b0d8713Smrg return BadLength; 2650b0d8713Smrg if ((compsize2 = safe_pad(compsize2)) < 0) 2660b0d8713Smrg return BadLength; 2674642e01fSmrg 268f7df2e56Smrg glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); 2690b0d8713Smrg __GLX_GET_ANSWER_BUFFER(answer, cl, safe_add(compsize, compsize2), 1); 2704642e01fSmrg __glXClearErrorOccured(); 271f7df2e56Smrg glGetSeparableFilter(*(GLenum *) (pc + 0), *(GLenum *) (pc + 4), 272f7df2e56Smrg *(GLenum *) (pc + 8), answer, answer + compsize, NULL); 2734642e01fSmrg 2744642e01fSmrg if (__glXErrorOccured()) { 275f7df2e56Smrg __GLX_BEGIN_REPLY(0); 276f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 277f7df2e56Smrg } 278f7df2e56Smrg else { 279f7df2e56Smrg __GLX_BEGIN_REPLY(compsize + compsize2); 280f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 281f7df2e56Smrg __GLX_SWAP_INT(&width); 282f7df2e56Smrg __GLX_SWAP_INT(&height); 2837e31ba66Smrg ((xGLXGetSeparableFilterReply *) &reply)->width = width; 2847e31ba66Smrg ((xGLXGetSeparableFilterReply *) &reply)->height = height; 285f7df2e56Smrg __GLX_SEND_VOID_ARRAY(compsize + compsize2); 2864642e01fSmrg } 2874642e01fSmrg 2884642e01fSmrg return Success; 2894642e01fSmrg} 2904642e01fSmrg 291f7df2e56Smrgint 292f7df2e56Smrg__glXDispSwap_GetSeparableFilter(__GLXclientState * cl, GLbyte * pc) 2934642e01fSmrg{ 2944642e01fSmrg const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc); 2950b0d8713Smrg ClientPtr client = cl->client; 2964642e01fSmrg 2970b0d8713Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 16); 2984642e01fSmrg return GetSeparableFilter(cl, pc + __GLX_SINGLE_HDR_SIZE, tag); 2994642e01fSmrg} 3004642e01fSmrg 301f7df2e56Smrgint 302f7df2e56Smrg__glXDispSwap_GetSeparableFilterEXT(__GLXclientState * cl, GLbyte * pc) 3034642e01fSmrg{ 3044642e01fSmrg const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc); 3050b0d8713Smrg ClientPtr client = cl->client; 3064642e01fSmrg 3070b0d8713Smrg REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16); 3084642e01fSmrg return GetSeparableFilter(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag); 3094642e01fSmrg} 3104642e01fSmrg 311f7df2e56Smrgstatic int 312f7df2e56SmrgGetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag) 3134642e01fSmrg{ 3144642e01fSmrg GLint compsize; 3154642e01fSmrg GLenum format, type, target; 3164642e01fSmrg GLboolean swapBytes; 3174642e01fSmrg __GLXcontext *cx; 3184642e01fSmrg ClientPtr client = cl->client; 3194642e01fSmrg int error; 320f7df2e56Smrg 3214642e01fSmrg __GLX_DECLARE_SWAP_VARIABLES; 3224642e01fSmrg char *answer, answerBuffer[200]; 323f7df2e56Smrg GLint width = 0, height = 0; 3247e31ba66Smrg xGLXSingleReply reply = { 0, }; 3254642e01fSmrg 3264642e01fSmrg cx = __glXForceCurrent(cl, tag, &error); 3274642e01fSmrg if (!cx) { 328f7df2e56Smrg return error; 3294642e01fSmrg } 3304642e01fSmrg 331f7df2e56Smrg __GLX_SWAP_INT(pc + 0); 332f7df2e56Smrg __GLX_SWAP_INT(pc + 4); 333f7df2e56Smrg __GLX_SWAP_INT(pc + 8); 3344642e01fSmrg 335f7df2e56Smrg format = *(GLenum *) (pc + 4); 336f7df2e56Smrg type = *(GLenum *) (pc + 8); 337f7df2e56Smrg target = *(GLenum *) (pc + 0); 338f7df2e56Smrg swapBytes = *(GLboolean *) (pc + 12); 3394642e01fSmrg 340f7df2e56Smrg glGetConvolutionParameteriv(target, GL_CONVOLUTION_WIDTH, &width); 3414642e01fSmrg if (target == GL_CONVOLUTION_2D) { 3424642e01fSmrg height = 1; 343f7df2e56Smrg } 344f7df2e56Smrg else { 345f7df2e56Smrg glGetConvolutionParameteriv(target, GL_CONVOLUTION_HEIGHT, &height); 3464642e01fSmrg } 3474642e01fSmrg /* 3484642e01fSmrg * The two queries above might fail if we're in a state where queries 3494642e01fSmrg * are illegal, but then width and height would still be zero anyway. 3504642e01fSmrg */ 351f7df2e56Smrg compsize = __glGetTexImage_size(target, 1, format, type, width, height, 1); 3520b0d8713Smrg if (compsize < 0) 3530b0d8713Smrg return BadLength; 3544642e01fSmrg 355f7df2e56Smrg glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); 356f7df2e56Smrg __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1); 3574642e01fSmrg __glXClearErrorOccured(); 358f7df2e56Smrg glGetConvolutionFilter(*(GLenum *) (pc + 0), *(GLenum *) (pc + 4), 359f7df2e56Smrg *(GLenum *) (pc + 8), answer); 3604642e01fSmrg 3614642e01fSmrg if (__glXErrorOccured()) { 362f7df2e56Smrg __GLX_BEGIN_REPLY(0); 363f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 364f7df2e56Smrg } 365f7df2e56Smrg else { 366f7df2e56Smrg __GLX_BEGIN_REPLY(compsize); 367f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 368f7df2e56Smrg __GLX_SWAP_INT(&width); 369f7df2e56Smrg __GLX_SWAP_INT(&height); 3707e31ba66Smrg ((xGLXGetConvolutionFilterReply *) &reply)->width = width; 3717e31ba66Smrg ((xGLXGetConvolutionFilterReply *) &reply)->height = height; 372f7df2e56Smrg __GLX_SEND_VOID_ARRAY(compsize); 3734642e01fSmrg } 3744642e01fSmrg 3754642e01fSmrg return Success; 3764642e01fSmrg} 3774642e01fSmrg 378f7df2e56Smrgint 379f7df2e56Smrg__glXDispSwap_GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc) 3804642e01fSmrg{ 3814642e01fSmrg const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc); 3820b0d8713Smrg ClientPtr client = cl->client; 3834642e01fSmrg 3840b0d8713Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 16); 3854642e01fSmrg return GetConvolutionFilter(cl, pc + __GLX_SINGLE_HDR_SIZE, tag); 3864642e01fSmrg} 3874642e01fSmrg 388f7df2e56Smrgint 389f7df2e56Smrg__glXDispSwap_GetConvolutionFilterEXT(__GLXclientState * cl, GLbyte * pc) 3904642e01fSmrg{ 3914642e01fSmrg const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc); 3920b0d8713Smrg ClientPtr client = cl->client; 3934642e01fSmrg 3940b0d8713Smrg REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16); 3954642e01fSmrg return GetConvolutionFilter(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag); 3964642e01fSmrg} 3974642e01fSmrg 398f7df2e56Smrgstatic int 399f7df2e56SmrgGetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag) 4004642e01fSmrg{ 4014642e01fSmrg GLint compsize; 4024642e01fSmrg GLenum format, type, target; 4034642e01fSmrg GLboolean swapBytes, reset; 4044642e01fSmrg __GLXcontext *cx; 4054642e01fSmrg ClientPtr client = cl->client; 4064642e01fSmrg int error; 407f7df2e56Smrg 4084642e01fSmrg __GLX_DECLARE_SWAP_VARIABLES; 4094642e01fSmrg char *answer, answerBuffer[200]; 410f7df2e56Smrg GLint width = 0; 4117e31ba66Smrg xGLXSingleReply reply = { 0, }; 4124642e01fSmrg 4134642e01fSmrg cx = __glXForceCurrent(cl, tag, &error); 4144642e01fSmrg if (!cx) { 415f7df2e56Smrg return error; 4164642e01fSmrg } 4174642e01fSmrg 418f7df2e56Smrg __GLX_SWAP_INT(pc + 0); 419f7df2e56Smrg __GLX_SWAP_INT(pc + 4); 420f7df2e56Smrg __GLX_SWAP_INT(pc + 8); 4214642e01fSmrg 422f7df2e56Smrg format = *(GLenum *) (pc + 4); 423f7df2e56Smrg type = *(GLenum *) (pc + 8); 424f7df2e56Smrg target = *(GLenum *) (pc + 0); 425f7df2e56Smrg swapBytes = *(GLboolean *) (pc + 12); 426f7df2e56Smrg reset = *(GLboolean *) (pc + 13); 4274642e01fSmrg 428f7df2e56Smrg glGetHistogramParameteriv(target, GL_HISTOGRAM_WIDTH, &width); 4294642e01fSmrg /* 4304642e01fSmrg * The one query above might fail if we're in a state where queries 4314642e01fSmrg * are illegal, but then width would still be zero anyway. 4324642e01fSmrg */ 433f7df2e56Smrg compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1); 4340b0d8713Smrg if (compsize < 0) 4350b0d8713Smrg return BadLength; 4364642e01fSmrg 437f7df2e56Smrg glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); 438f7df2e56Smrg __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1); 4394642e01fSmrg __glXClearErrorOccured(); 440f7df2e56Smrg glGetHistogram(target, reset, format, type, answer); 4414642e01fSmrg 4424642e01fSmrg if (__glXErrorOccured()) { 443f7df2e56Smrg __GLX_BEGIN_REPLY(0); 444f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 445f7df2e56Smrg } 446f7df2e56Smrg else { 447f7df2e56Smrg __GLX_BEGIN_REPLY(compsize); 448f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 449f7df2e56Smrg __GLX_SWAP_INT(&width); 4507e31ba66Smrg ((xGLXGetHistogramReply *) &reply)->width = width; 451f7df2e56Smrg __GLX_SEND_VOID_ARRAY(compsize); 4524642e01fSmrg } 4534642e01fSmrg 4544642e01fSmrg return Success; 4554642e01fSmrg} 4564642e01fSmrg 457f7df2e56Smrgint 458f7df2e56Smrg__glXDispSwap_GetHistogram(__GLXclientState * cl, GLbyte * pc) 4594642e01fSmrg{ 4604642e01fSmrg const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc); 4610b0d8713Smrg ClientPtr client = cl->client; 4624642e01fSmrg 4630b0d8713Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 16); 4644642e01fSmrg return GetHistogram(cl, pc + __GLX_SINGLE_HDR_SIZE, tag); 4654642e01fSmrg} 4664642e01fSmrg 467f7df2e56Smrgint 468f7df2e56Smrg__glXDispSwap_GetHistogramEXT(__GLXclientState * cl, GLbyte * pc) 4694642e01fSmrg{ 4704642e01fSmrg const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc); 4710b0d8713Smrg ClientPtr client = cl->client; 4724642e01fSmrg 4730b0d8713Smrg REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16); 4744642e01fSmrg return GetHistogram(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag); 4754642e01fSmrg} 4764642e01fSmrg 477f7df2e56Smrgstatic int 478f7df2e56SmrgGetMinmax(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag) 4794642e01fSmrg{ 4804642e01fSmrg GLint compsize; 4814642e01fSmrg GLenum format, type, target; 4824642e01fSmrg GLboolean swapBytes, reset; 4834642e01fSmrg __GLXcontext *cx; 4844642e01fSmrg ClientPtr client = cl->client; 4854642e01fSmrg int error; 486f7df2e56Smrg 4874642e01fSmrg __GLX_DECLARE_SWAP_VARIABLES; 4884642e01fSmrg char *answer, answerBuffer[200]; 4897e31ba66Smrg xGLXSingleReply reply = { 0, }; 4904642e01fSmrg 4914642e01fSmrg cx = __glXForceCurrent(cl, tag, &error); 4924642e01fSmrg if (!cx) { 493f7df2e56Smrg return error; 4944642e01fSmrg } 4954642e01fSmrg 496f7df2e56Smrg __GLX_SWAP_INT(pc + 0); 497f7df2e56Smrg __GLX_SWAP_INT(pc + 4); 498f7df2e56Smrg __GLX_SWAP_INT(pc + 8); 4994642e01fSmrg 500f7df2e56Smrg format = *(GLenum *) (pc + 4); 501f7df2e56Smrg type = *(GLenum *) (pc + 8); 502f7df2e56Smrg target = *(GLenum *) (pc + 0); 503f7df2e56Smrg swapBytes = *(GLboolean *) (pc + 12); 504f7df2e56Smrg reset = *(GLboolean *) (pc + 13); 5054642e01fSmrg 506f7df2e56Smrg compsize = __glGetTexImage_size(target, 1, format, type, 2, 1, 1); 5070b0d8713Smrg if (compsize < 0) 5080b0d8713Smrg return BadLength; 5094642e01fSmrg 510f7df2e56Smrg glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); 511f7df2e56Smrg __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1); 5124642e01fSmrg __glXClearErrorOccured(); 513f7df2e56Smrg glGetMinmax(target, reset, format, type, answer); 5144642e01fSmrg 5154642e01fSmrg if (__glXErrorOccured()) { 516f7df2e56Smrg __GLX_BEGIN_REPLY(0); 517f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 518f7df2e56Smrg } 519f7df2e56Smrg else { 520f7df2e56Smrg __GLX_BEGIN_REPLY(compsize); 521f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 522f7df2e56Smrg __GLX_SEND_VOID_ARRAY(compsize); 5234642e01fSmrg } 5244642e01fSmrg 5254642e01fSmrg return Success; 5264642e01fSmrg} 5274642e01fSmrg 528f7df2e56Smrgint 529f7df2e56Smrg__glXDispSwap_GetMinmax(__GLXclientState * cl, GLbyte * pc) 5304642e01fSmrg{ 5314642e01fSmrg const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc); 5320b0d8713Smrg ClientPtr client = cl->client; 5334642e01fSmrg 5340b0d8713Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 16); 5354642e01fSmrg return GetMinmax(cl, pc + __GLX_SINGLE_HDR_SIZE, tag); 5364642e01fSmrg} 5374642e01fSmrg 538f7df2e56Smrgint 539f7df2e56Smrg__glXDispSwap_GetMinmaxEXT(__GLXclientState * cl, GLbyte * pc) 5404642e01fSmrg{ 5414642e01fSmrg const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc); 5420b0d8713Smrg ClientPtr client = cl->client; 5434642e01fSmrg 5440b0d8713Smrg REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16); 5454642e01fSmrg return GetMinmax(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag); 5464642e01fSmrg} 5474642e01fSmrg 548f7df2e56Smrgstatic int 549f7df2e56SmrgGetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag) 5504642e01fSmrg{ 5514642e01fSmrg GLint compsize; 5524642e01fSmrg GLenum format, type, target; 5534642e01fSmrg GLboolean swapBytes; 5544642e01fSmrg __GLXcontext *cx; 5554642e01fSmrg ClientPtr client = cl->client; 5564642e01fSmrg int error; 557f7df2e56Smrg 5584642e01fSmrg __GLX_DECLARE_SWAP_VARIABLES; 5594642e01fSmrg char *answer, answerBuffer[200]; 560f7df2e56Smrg GLint width = 0; 5617e31ba66Smrg xGLXSingleReply reply = { 0, }; 5624642e01fSmrg 5634642e01fSmrg cx = __glXForceCurrent(cl, tag, &error); 5644642e01fSmrg if (!cx) { 565f7df2e56Smrg return error; 5664642e01fSmrg } 5674642e01fSmrg 568f7df2e56Smrg __GLX_SWAP_INT(pc + 0); 569f7df2e56Smrg __GLX_SWAP_INT(pc + 4); 570f7df2e56Smrg __GLX_SWAP_INT(pc + 8); 5714642e01fSmrg 572f7df2e56Smrg format = *(GLenum *) (pc + 4); 573f7df2e56Smrg type = *(GLenum *) (pc + 8); 574f7df2e56Smrg target = *(GLenum *) (pc + 0); 575f7df2e56Smrg swapBytes = *(GLboolean *) (pc + 12); 5764642e01fSmrg 577f7df2e56Smrg glGetColorTableParameteriv(target, GL_COLOR_TABLE_WIDTH, &width); 5784642e01fSmrg /* 5794642e01fSmrg * The one query above might fail if we're in a state where queries 5804642e01fSmrg * are illegal, but then width would still be zero anyway. 5814642e01fSmrg */ 582f7df2e56Smrg compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1); 5830b0d8713Smrg if (compsize < 0) 5840b0d8713Smrg return BadLength; 5854642e01fSmrg 586f7df2e56Smrg glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); 587f7df2e56Smrg __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1); 5884642e01fSmrg __glXClearErrorOccured(); 589f7df2e56Smrg glGetColorTable(*(GLenum *) (pc + 0), *(GLenum *) (pc + 4), 590f7df2e56Smrg *(GLenum *) (pc + 8), answer); 5914642e01fSmrg 5924642e01fSmrg if (__glXErrorOccured()) { 593f7df2e56Smrg __GLX_BEGIN_REPLY(0); 594f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 595f7df2e56Smrg } 596f7df2e56Smrg else { 597f7df2e56Smrg __GLX_BEGIN_REPLY(compsize); 598f7df2e56Smrg __GLX_SWAP_REPLY_HEADER(); 599f7df2e56Smrg __GLX_SWAP_INT(&width); 6007e31ba66Smrg ((xGLXGetColorTableReply *) &reply)->width = width; 601f7df2e56Smrg __GLX_SEND_VOID_ARRAY(compsize); 6024642e01fSmrg } 6034642e01fSmrg 6044642e01fSmrg return Success; 6054642e01fSmrg} 6064642e01fSmrg 607f7df2e56Smrgint 608f7df2e56Smrg__glXDispSwap_GetColorTable(__GLXclientState * cl, GLbyte * pc) 6094642e01fSmrg{ 6104642e01fSmrg const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc); 6110b0d8713Smrg ClientPtr client = cl->client; 6124642e01fSmrg 6130b0d8713Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 16); 6144642e01fSmrg return GetColorTable(cl, pc + __GLX_SINGLE_HDR_SIZE, tag); 6154642e01fSmrg} 6164642e01fSmrg 617f7df2e56Smrgint 618f7df2e56Smrg__glXDispSwap_GetColorTableSGI(__GLXclientState * cl, GLbyte * pc) 6194642e01fSmrg{ 6204642e01fSmrg const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc); 6210b0d8713Smrg ClientPtr client = cl->client; 6224642e01fSmrg 6230b0d8713Smrg REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16); 6244642e01fSmrg return GetColorTable(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag); 6254642e01fSmrg} 626