1/* 2 * (C) Copyright IBM Corporation 2005, 2006 3 * All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sub license, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19 * IBM, 20 * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 * SOFTWARE. 24 */ 25 26#ifdef HAVE_DIX_CONFIG_H 27#include <dix-config.h> 28#endif 29 30#include "glxserver.h" 31#include "glxbyteorder.h" 32#include "glxext.h" 33#include "singlesize.h" 34#include "unpack.h" 35#include "indirect_size_get.h" 36#include "indirect_dispatch.h" 37#include "glapitable.h" 38#include "glapi.h" 39#include "glthread.h" 40#include "dispatch.h" 41 42int __glXDisp_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *pc) 43{ 44 xGLXSingleReq * const req = (xGLXSingleReq *) pc; 45 int error; 46 __GLXcontext * const cx = __glXForceCurrent( cl, req->contextTag, & error ); 47 ClientPtr client = cl->client; 48 49 50 REQUEST_FIXED_SIZE(xGLXSingleReq, 8); 51 52 pc += __GLX_SINGLE_HDR_SIZE; 53 if ( cx != NULL ) { 54 const GLenum target = *(GLenum *)(pc + 0); 55 const GLint level = *(GLint *)(pc + 4); 56 GLint compsize = 0; 57 char *answer = NULL, answerBuffer[200]; 58 59 CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize)); 60 61 if ( compsize != 0 ) { 62 __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); 63 __glXClearErrorOccured(); 64 CALL_GetCompressedTexImageARB(GET_DISPATCH(), (target, level, answer)); 65 } 66 67 if (__glXErrorOccured()) { 68 __GLX_BEGIN_REPLY(0); 69 __GLX_SEND_HEADER(); 70 } else { 71 __GLX_BEGIN_REPLY(compsize); 72 ((xGLXGetTexImageReply *)&__glXReply)->width = compsize; 73 __GLX_SEND_HEADER(); 74 __GLX_SEND_VOID_ARRAY(compsize); 75 } 76 77 error = Success; 78 } 79 80 return error; 81} 82 83 84int __glXDispSwap_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *pc) 85{ 86 xGLXSingleReq * const req = (xGLXSingleReq *) pc; 87 int error; 88 __GLXcontext * const cx = __glXForceCurrent( cl, bswap_32( req->contextTag ), & error ); 89 ClientPtr client = cl->client; 90 91 92 REQUEST_FIXED_SIZE(xGLXSingleReq, 8); 93 94 pc += __GLX_SINGLE_HDR_SIZE; 95 if ( cx != NULL ) { 96 const GLenum target = (GLenum) bswap_32( *(int *)(pc + 0) ); 97 const GLint level = (GLint ) bswap_32( *(int *)(pc + 4) ); 98 GLint compsize = 0; 99 char *answer = NULL, answerBuffer[200]; 100 101 CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize)); 102 103 if ( compsize != 0 ) { 104 __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); 105 __glXClearErrorOccured(); 106 CALL_GetCompressedTexImageARB(GET_DISPATCH(), (target, level, answer)); 107 } 108 109 if (__glXErrorOccured()) { 110 __GLX_BEGIN_REPLY(0); 111 __GLX_SEND_HEADER(); 112 } else { 113 __GLX_BEGIN_REPLY(compsize); 114 ((xGLXGetTexImageReply *)&__glXReply)->width = compsize; 115 __GLX_SEND_HEADER(); 116 __GLX_SEND_VOID_ARRAY(compsize); 117 } 118 119 error = Success; 120 } 121 122 return error; 123} 124