14642e01fSmrg/* 24642e01fSmrg * (C) Copyright IBM Corporation 2005, 2006 34642e01fSmrg * All Rights Reserved. 4f7df2e56Smrg * 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, sub license, 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: 11f7df2e56Smrg * 124642e01fSmrg * The above copyright notice and this permission notice (including the next 134642e01fSmrg * paragraph) shall be included in all copies or substantial portions of the 144642e01fSmrg * Software. 15f7df2e56Smrg * 164642e01fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 174642e01fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 184642e01fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 194642e01fSmrg * IBM, 204642e01fSmrg * AND/OR THEIR SUPPLIERS 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 264642e01fSmrg#ifdef HAVE_DIX_CONFIG_H 274642e01fSmrg#include <dix-config.h> 284642e01fSmrg#endif 294642e01fSmrg 304642e01fSmrg#include "glxserver.h" 314642e01fSmrg#include "glxbyteorder.h" 324642e01fSmrg#include "glxext.h" 334642e01fSmrg#include "singlesize.h" 344642e01fSmrg#include "unpack.h" 354642e01fSmrg#include "indirect_size_get.h" 364642e01fSmrg#include "indirect_dispatch.h" 374642e01fSmrg 38f7df2e56Smrgint 39f7df2e56Smrg__glXDisp_GetCompressedTexImage(struct __GLXclientStateRec *cl, GLbyte * pc) 404642e01fSmrg{ 41f7df2e56Smrg xGLXSingleReq *const req = (xGLXSingleReq *) pc; 424642e01fSmrg int error; 43f7df2e56Smrg __GLXcontext *const cx = __glXForceCurrent(cl, req->contextTag, &error); 444642e01fSmrg ClientPtr client = cl->client; 454642e01fSmrg 46f7df2e56Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 8); 474642e01fSmrg 484642e01fSmrg pc += __GLX_SINGLE_HDR_SIZE; 49f7df2e56Smrg if (cx != NULL) { 50f7df2e56Smrg const GLenum target = *(GLenum *) (pc + 0); 51f7df2e56Smrg const GLint level = *(GLint *) (pc + 4); 52f7df2e56Smrg GLint compsize = 0; 53f7df2e56Smrg char *answer = NULL, answerBuffer[200]; 547e31ba66Smrg xGLXSingleReply reply = { 0, }; 55f7df2e56Smrg 56f7df2e56Smrg glGetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, 57f7df2e56Smrg &compsize); 58f7df2e56Smrg 59f7df2e56Smrg if (compsize != 0) { 60f7df2e56Smrg PFNGLGETCOMPRESSEDTEXIMAGEARBPROC GetCompressedTexImageARB = 61f7df2e56Smrg __glGetProcAddress("glGetCompressedTexImageARB"); 62f7df2e56Smrg __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1); 63f7df2e56Smrg __glXClearErrorOccured(); 64f7df2e56Smrg GetCompressedTexImageARB(target, level, answer); 65f7df2e56Smrg } 66f7df2e56Smrg 67f7df2e56Smrg if (__glXErrorOccured()) { 68f7df2e56Smrg __GLX_BEGIN_REPLY(0); 69f7df2e56Smrg __GLX_SEND_HEADER(); 70f7df2e56Smrg } 71f7df2e56Smrg else { 72f7df2e56Smrg __GLX_BEGIN_REPLY(compsize); 737e31ba66Smrg ((xGLXGetTexImageReply *) &reply)->width = compsize; 74f7df2e56Smrg __GLX_SEND_HEADER(); 75f7df2e56Smrg __GLX_SEND_VOID_ARRAY(compsize); 76f7df2e56Smrg } 77f7df2e56Smrg 78f7df2e56Smrg error = Success; 794642e01fSmrg } 804642e01fSmrg 814642e01fSmrg return error; 824642e01fSmrg} 834642e01fSmrg 84f7df2e56Smrgint 85f7df2e56Smrg__glXDispSwap_GetCompressedTexImage(struct __GLXclientStateRec *cl, GLbyte * pc) 864642e01fSmrg{ 87f7df2e56Smrg xGLXSingleReq *const req = (xGLXSingleReq *) pc; 884642e01fSmrg int error; 89f7df2e56Smrg __GLXcontext *const cx = 90f7df2e56Smrg __glXForceCurrent(cl, bswap_32(req->contextTag), &error); 914642e01fSmrg ClientPtr client = cl->client; 924642e01fSmrg 93f7df2e56Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 8); 944642e01fSmrg 954642e01fSmrg pc += __GLX_SINGLE_HDR_SIZE; 96f7df2e56Smrg if (cx != NULL) { 97f7df2e56Smrg const GLenum target = (GLenum) bswap_32(*(int *) (pc + 0)); 98f7df2e56Smrg const GLint level = (GLint) bswap_32(*(int *) (pc + 4)); 99f7df2e56Smrg GLint compsize = 0; 100f7df2e56Smrg char *answer = NULL, answerBuffer[200]; 1017e31ba66Smrg xGLXSingleReply reply = { 0, }; 102f7df2e56Smrg 103f7df2e56Smrg glGetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, 104f7df2e56Smrg &compsize); 105f7df2e56Smrg 106f7df2e56Smrg if (compsize != 0) { 107f7df2e56Smrg PFNGLGETCOMPRESSEDTEXIMAGEARBPROC GetCompressedTexImageARB = 108f7df2e56Smrg __glGetProcAddress("glGetCompressedTexImageARB"); 109f7df2e56Smrg __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1); 110f7df2e56Smrg __glXClearErrorOccured(); 111f7df2e56Smrg GetCompressedTexImageARB(target, level, answer); 112f7df2e56Smrg } 113f7df2e56Smrg 114f7df2e56Smrg if (__glXErrorOccured()) { 115f7df2e56Smrg __GLX_BEGIN_REPLY(0); 116f7df2e56Smrg __GLX_SEND_HEADER(); 117f7df2e56Smrg } 118f7df2e56Smrg else { 119f7df2e56Smrg __GLX_BEGIN_REPLY(compsize); 1207e31ba66Smrg ((xGLXGetTexImageReply *) &reply)->width = compsize; 121f7df2e56Smrg __GLX_SEND_HEADER(); 122f7df2e56Smrg __GLX_SEND_VOID_ARRAY(compsize); 123f7df2e56Smrg } 124f7df2e56Smrg 125f7df2e56Smrg error = Success; 1264642e01fSmrg } 1274642e01fSmrg 1284642e01fSmrg return error; 1294642e01fSmrg} 130