First import
[xorg_rtime.git] / xorg-server-1.4 / GL / glx / indirect_texture_compression.c
blob3c09663fcea17f53ffc74c2a0a003f24bb32d635
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:
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.
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.
26 #define NEED_REPLIES
27 #ifdef HAVE_DIX_CONFIG_H
28 #include <dix-config.h>
29 #endif
31 #include "glxserver.h"
32 #include "glxbyteorder.h"
33 #include "glxext.h"
34 #include "singlesize.h"
35 #include "unpack.h"
36 #include "indirect_size_get.h"
37 #include "indirect_dispatch.h"
38 #include "glapitable.h"
39 #include "glapi.h"
40 #include "glthread.h"
41 #include "dispatch.h"
43 int __glXDisp_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *pc)
45 xGLXSingleReq * const req = (xGLXSingleReq *) pc;
46 int error;
47 __GLXcontext * const cx = __glXForceCurrent( cl, req->contextTag, & error );
48 ClientPtr client = cl->client;
51 pc += __GLX_SINGLE_HDR_SIZE;
52 if ( cx != NULL ) {
53 const GLenum target = *(GLenum *)(pc + 0);
54 const GLint level = *(GLint *)(pc + 4);
55 GLint compsize = 0;
56 char *answer, answerBuffer[200];
58 CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize));
60 if ( compsize != 0 ) {
61 __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
62 __glXClearErrorOccured();
63 CALL_GetCompressedTexImageARB(GET_DISPATCH(), (target, level, answer));
66 if (__glXErrorOccured()) {
67 __GLX_BEGIN_REPLY(0);
68 __GLX_SEND_HEADER();
69 } else {
70 __GLX_BEGIN_REPLY(compsize);
71 ((xGLXGetTexImageReply *)&__glXReply)->width = compsize;
72 __GLX_SEND_HEADER();
73 __GLX_SEND_VOID_ARRAY(compsize);
76 error = Success;
79 return error;
83 int __glXDispSwap_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *pc)
85 xGLXSingleReq * const req = (xGLXSingleReq *) pc;
86 int error;
87 __GLXcontext * const cx = __glXForceCurrent( cl, bswap_32( req->contextTag ), & error );
88 ClientPtr client = cl->client;
91 pc += __GLX_SINGLE_HDR_SIZE;
92 if ( cx != NULL ) {
93 const GLenum target = (GLenum) bswap_32( *(int *)(pc + 0) );
94 const GLint level = (GLint ) bswap_32( *(int *)(pc + 4) );
95 GLint compsize = 0;
96 char *answer, answerBuffer[200];
98 CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize));
100 if ( compsize != 0 ) {
101 __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
102 __glXClearErrorOccured();
103 CALL_GetCompressedTexImageARB(GET_DISPATCH(), (target, level, answer));
106 if (__glXErrorOccured()) {
107 __GLX_BEGIN_REPLY(0);
108 __GLX_SEND_HEADER();
109 } else {
110 __GLX_BEGIN_REPLY(compsize);
111 ((xGLXGetTexImageReply *)&__glXReply)->width = compsize;
112 __GLX_SEND_HEADER();
113 __GLX_SEND_VOID_ARRAY(compsize);
116 error = Success;
119 return error;