1706f2543Smrg/* 2706f2543Smrg * (C) Copyright IBM Corporation 2005, 2006 3706f2543Smrg * All Rights Reserved. 4706f2543Smrg * 5706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a 6706f2543Smrg * copy of this software and associated documentation files (the "Software"), 7706f2543Smrg * to deal in the Software without restriction, including without limitation 8706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sub license, 9706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the 10706f2543Smrg * Software is furnished to do so, subject to the following conditions: 11706f2543Smrg * 12706f2543Smrg * The above copyright notice and this permission notice (including the next 13706f2543Smrg * paragraph) shall be included in all copies or substantial portions of the 14706f2543Smrg * Software. 15706f2543Smrg * 16706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17706f2543Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19706f2543Smrg * IBM, 20706f2543Smrg * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21706f2543Smrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22706f2543Smrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23706f2543Smrg * SOFTWARE. 24706f2543Smrg */ 25706f2543Smrg 26706f2543Smrg#ifdef HAVE_DIX_CONFIG_H 27706f2543Smrg#include <dix-config.h> 28706f2543Smrg#endif 29706f2543Smrg 30706f2543Smrg#include "glxserver.h" 31706f2543Smrg#include "glxbyteorder.h" 32706f2543Smrg#include "glxext.h" 33706f2543Smrg#include "singlesize.h" 34706f2543Smrg#include "unpack.h" 35706f2543Smrg#include "indirect_size_get.h" 36706f2543Smrg#include "indirect_dispatch.h" 37706f2543Smrg#include "glapitable.h" 38706f2543Smrg#include "glapi.h" 39706f2543Smrg#include "glthread.h" 40706f2543Smrg#include "dispatch.h" 41706f2543Smrg 42706f2543Smrgint __glXDisp_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *pc) 43706f2543Smrg{ 44706f2543Smrg xGLXSingleReq * const req = (xGLXSingleReq *) pc; 45706f2543Smrg int error; 46706f2543Smrg __GLXcontext * const cx = __glXForceCurrent( cl, req->contextTag, & error ); 47706f2543Smrg ClientPtr client = cl->client; 48706f2543Smrg 49706f2543Smrg 50706f2543Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 8); 51706f2543Smrg 52706f2543Smrg pc += __GLX_SINGLE_HDR_SIZE; 53706f2543Smrg if ( cx != NULL ) { 54706f2543Smrg const GLenum target = *(GLenum *)(pc + 0); 55706f2543Smrg const GLint level = *(GLint *)(pc + 4); 56706f2543Smrg GLint compsize = 0; 57706f2543Smrg char *answer = NULL, answerBuffer[200]; 58706f2543Smrg 59706f2543Smrg CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize)); 60706f2543Smrg 61706f2543Smrg if ( compsize != 0 ) { 62706f2543Smrg __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); 63706f2543Smrg __glXClearErrorOccured(); 64706f2543Smrg CALL_GetCompressedTexImageARB(GET_DISPATCH(), (target, level, answer)); 65706f2543Smrg } 66706f2543Smrg 67706f2543Smrg if (__glXErrorOccured()) { 68706f2543Smrg __GLX_BEGIN_REPLY(0); 69706f2543Smrg __GLX_SEND_HEADER(); 70706f2543Smrg } else { 71706f2543Smrg __GLX_BEGIN_REPLY(compsize); 72706f2543Smrg ((xGLXGetTexImageReply *)&__glXReply)->width = compsize; 73706f2543Smrg __GLX_SEND_HEADER(); 74706f2543Smrg __GLX_SEND_VOID_ARRAY(compsize); 75706f2543Smrg } 76706f2543Smrg 77706f2543Smrg error = Success; 78706f2543Smrg } 79706f2543Smrg 80706f2543Smrg return error; 81706f2543Smrg} 82706f2543Smrg 83706f2543Smrg 84706f2543Smrgint __glXDispSwap_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *pc) 85706f2543Smrg{ 86706f2543Smrg xGLXSingleReq * const req = (xGLXSingleReq *) pc; 87706f2543Smrg int error; 88706f2543Smrg __GLXcontext * const cx = __glXForceCurrent( cl, bswap_32( req->contextTag ), & error ); 89706f2543Smrg ClientPtr client = cl->client; 90706f2543Smrg 91706f2543Smrg 92706f2543Smrg REQUEST_FIXED_SIZE(xGLXSingleReq, 8); 93706f2543Smrg 94706f2543Smrg pc += __GLX_SINGLE_HDR_SIZE; 95706f2543Smrg if ( cx != NULL ) { 96706f2543Smrg const GLenum target = (GLenum) bswap_32( *(int *)(pc + 0) ); 97706f2543Smrg const GLint level = (GLint ) bswap_32( *(int *)(pc + 4) ); 98706f2543Smrg GLint compsize = 0; 99706f2543Smrg char *answer = NULL, answerBuffer[200]; 100706f2543Smrg 101706f2543Smrg CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize)); 102706f2543Smrg 103706f2543Smrg if ( compsize != 0 ) { 104706f2543Smrg __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); 105706f2543Smrg __glXClearErrorOccured(); 106706f2543Smrg CALL_GetCompressedTexImageARB(GET_DISPATCH(), (target, level, answer)); 107706f2543Smrg } 108706f2543Smrg 109706f2543Smrg if (__glXErrorOccured()) { 110706f2543Smrg __GLX_BEGIN_REPLY(0); 111706f2543Smrg __GLX_SEND_HEADER(); 112706f2543Smrg } else { 113706f2543Smrg __GLX_BEGIN_REPLY(compsize); 114706f2543Smrg ((xGLXGetTexImageReply *)&__glXReply)->width = compsize; 115706f2543Smrg __GLX_SEND_HEADER(); 116706f2543Smrg __GLX_SEND_VOID_ARRAY(compsize); 117706f2543Smrg } 118706f2543Smrg 119706f2543Smrg error = Success; 120706f2543Smrg } 121706f2543Smrg 122706f2543Smrg return error; 123706f2543Smrg} 124