2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
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, sublicense,
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 including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. 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
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
31 #ifdef HAVE_DIX_CONFIG_H
32 #include <dix-config.h>
35 #include "glxserver.h"
37 #include "singlesize.h"
39 #include "indirect_size_get.h"
40 #include "indirect_dispatch.h"
43 __glXDisp_ReadPixels(__GLXclientState
* cl
, GLbyte
* pc
)
45 GLsizei width
, height
;
47 GLboolean swapBytes
, lsbFirst
;
50 ClientPtr client
= cl
->client
;
52 char *answer
, answerBuffer
[200];
54 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
59 pc
+= __GLX_SINGLE_HDR_SIZE
;
60 width
= *(GLsizei
*) (pc
+ 8);
61 height
= *(GLsizei
*) (pc
+ 12);
62 format
= *(GLenum
*) (pc
+ 16);
63 type
= *(GLenum
*) (pc
+ 20);
64 swapBytes
= *(GLboolean
*) (pc
+ 24);
65 lsbFirst
= *(GLboolean
*) (pc
+ 25);
66 compsize
= __glReadPixels_size(format
, type
, width
, height
);
70 glPixelStorei(GL_PACK_SWAP_BYTES
, swapBytes
);
71 glPixelStorei(GL_PACK_LSB_FIRST
, lsbFirst
);
72 __GLX_GET_ANSWER_BUFFER(answer
, cl
, compsize
, 1);
73 __glXClearErrorOccured();
74 glReadPixels(*(GLint
*) (pc
+ 0), *(GLint
*) (pc
+ 4),
75 *(GLsizei
*) (pc
+ 8), *(GLsizei
*) (pc
+ 12),
76 *(GLenum
*) (pc
+ 16), *(GLenum
*) (pc
+ 20), answer
);
78 if (__glXErrorOccured()) {
83 __GLX_BEGIN_REPLY(compsize
);
85 __GLX_SEND_VOID_ARRAY(compsize
);
87 cx
->hasUnflushedCommands
= GL_FALSE
;
92 __glXDisp_GetTexImage(__GLXclientState
* cl
, GLbyte
* pc
)
94 GLint level
, compsize
;
95 GLenum format
, type
, target
;
98 ClientPtr client
= cl
->client
;
100 char *answer
, answerBuffer
[200];
101 GLint width
= 0, height
= 0, depth
= 1;
103 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
108 pc
+= __GLX_SINGLE_HDR_SIZE
;
109 level
= *(GLint
*) (pc
+ 4);
110 format
= *(GLenum
*) (pc
+ 8);
111 type
= *(GLenum
*) (pc
+ 12);
112 target
= *(GLenum
*) (pc
+ 0);
113 swapBytes
= *(GLboolean
*) (pc
+ 16);
115 glGetTexLevelParameteriv(target
, level
, GL_TEXTURE_WIDTH
, &width
);
116 glGetTexLevelParameteriv(target
, level
, GL_TEXTURE_HEIGHT
, &height
);
117 if (target
== GL_TEXTURE_3D
) {
118 glGetTexLevelParameteriv(target
, level
, GL_TEXTURE_DEPTH
, &depth
);
121 * The three queries above might fail if we're in a state where queries
122 * are illegal, but then width, height, and depth would still be zero anyway.
125 __glGetTexImage_size(target
, level
, format
, type
, width
, height
, depth
);
129 glPixelStorei(GL_PACK_SWAP_BYTES
, swapBytes
);
130 __GLX_GET_ANSWER_BUFFER(answer
, cl
, compsize
, 1);
131 __glXClearErrorOccured();
132 glGetTexImage(*(GLenum
*) (pc
+ 0), *(GLint
*) (pc
+ 4),
133 *(GLenum
*) (pc
+ 8), *(GLenum
*) (pc
+ 12), answer
);
135 if (__glXErrorOccured()) {
136 __GLX_BEGIN_REPLY(0);
140 __GLX_BEGIN_REPLY(compsize
);
141 ((xGLXGetTexImageReply
*) &__glXReply
)->width
= width
;
142 ((xGLXGetTexImageReply
*) &__glXReply
)->height
= height
;
143 ((xGLXGetTexImageReply
*) &__glXReply
)->depth
= depth
;
145 __GLX_SEND_VOID_ARRAY(compsize
);
151 __glXDisp_GetPolygonStipple(__GLXclientState
* cl
, GLbyte
* pc
)
155 ClientPtr client
= cl
->client
;
157 GLubyte answerBuffer
[200];
160 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
165 pc
+= __GLX_SINGLE_HDR_SIZE
;
166 lsbFirst
= *(GLboolean
*) (pc
+ 0);
168 glPixelStorei(GL_PACK_LSB_FIRST
, lsbFirst
);
169 __GLX_GET_ANSWER_BUFFER(answer
, cl
, 128, 1);
171 __glXClearErrorOccured();
172 glGetPolygonStipple((GLubyte
*) answer
);
174 if (__glXErrorOccured()) {
175 __GLX_BEGIN_REPLY(0);
179 __GLX_BEGIN_REPLY(128);
181 __GLX_SEND_BYTE_ARRAY(128);
187 GetSeparableFilter(__GLXclientState
* cl
, GLbyte
* pc
, GLXContextTag tag
)
189 GLint compsize
, compsize2
;
190 GLenum format
, type
, target
;
193 ClientPtr client
= cl
->client
;
195 char *answer
, answerBuffer
[200];
196 GLint width
= 0, height
= 0;
198 cx
= __glXForceCurrent(cl
, tag
, &error
);
203 format
= *(GLenum
*) (pc
+ 4);
204 type
= *(GLenum
*) (pc
+ 8);
205 target
= *(GLenum
*) (pc
+ 0);
206 swapBytes
= *(GLboolean
*) (pc
+ 12);
208 /* target must be SEPARABLE_2D, however I guess we can let the GL
209 barf on this one.... */
211 glGetConvolutionParameteriv(target
, GL_CONVOLUTION_WIDTH
, &width
);
212 glGetConvolutionParameteriv(target
, GL_CONVOLUTION_HEIGHT
, &height
);
214 * The two queries above might fail if we're in a state where queries
215 * are illegal, but then width and height would still be zero anyway.
217 compsize
= __glGetTexImage_size(target
, 1, format
, type
, width
, 1, 1);
218 compsize2
= __glGetTexImage_size(target
, 1, format
, type
, height
, 1, 1);
224 compsize
= __GLX_PAD(compsize
);
225 compsize2
= __GLX_PAD(compsize2
);
227 glPixelStorei(GL_PACK_SWAP_BYTES
, swapBytes
);
228 __GLX_GET_ANSWER_BUFFER(answer
, cl
, compsize
+ compsize2
, 1);
229 __glXClearErrorOccured();
230 glGetSeparableFilter(*(GLenum
*) (pc
+ 0), *(GLenum
*) (pc
+ 4),
231 *(GLenum
*) (pc
+ 8), answer
, answer
+ compsize
, NULL
);
233 if (__glXErrorOccured()) {
234 __GLX_BEGIN_REPLY(0);
238 __GLX_BEGIN_REPLY(compsize
+ compsize2
);
239 ((xGLXGetSeparableFilterReply
*) &__glXReply
)->width
= width
;
240 ((xGLXGetSeparableFilterReply
*) &__glXReply
)->height
= height
;
242 __GLX_SEND_VOID_ARRAY(compsize
+ compsize2
);
249 __glXDisp_GetSeparableFilter(__GLXclientState
* cl
, GLbyte
* pc
)
251 const GLXContextTag tag
= __GLX_GET_SINGLE_CONTEXT_TAG(pc
);
253 return GetSeparableFilter(cl
, pc
+ __GLX_SINGLE_HDR_SIZE
, tag
);
257 __glXDisp_GetSeparableFilterEXT(__GLXclientState
* cl
, GLbyte
* pc
)
259 const GLXContextTag tag
= __GLX_GET_VENDPRIV_CONTEXT_TAG(pc
);
261 return GetSeparableFilter(cl
, pc
+ __GLX_VENDPRIV_HDR_SIZE
, tag
);
265 GetConvolutionFilter(__GLXclientState
* cl
, GLbyte
* pc
, GLXContextTag tag
)
268 GLenum format
, type
, target
;
271 ClientPtr client
= cl
->client
;
273 char *answer
, answerBuffer
[200];
274 GLint width
= 0, height
= 0;
276 cx
= __glXForceCurrent(cl
, tag
, &error
);
281 format
= *(GLenum
*) (pc
+ 4);
282 type
= *(GLenum
*) (pc
+ 8);
283 target
= *(GLenum
*) (pc
+ 0);
284 swapBytes
= *(GLboolean
*) (pc
+ 12);
286 glGetConvolutionParameteriv(target
, GL_CONVOLUTION_WIDTH
, &width
);
287 if (target
== GL_CONVOLUTION_1D
) {
291 glGetConvolutionParameteriv(target
, GL_CONVOLUTION_HEIGHT
, &height
);
294 * The two queries above might fail if we're in a state where queries
295 * are illegal, but then width and height would still be zero anyway.
297 compsize
= __glGetTexImage_size(target
, 1, format
, type
, width
, height
, 1);
301 glPixelStorei(GL_PACK_SWAP_BYTES
, swapBytes
);
302 __GLX_GET_ANSWER_BUFFER(answer
, cl
, compsize
, 1);
303 __glXClearErrorOccured();
304 glGetConvolutionFilter(*(GLenum
*) (pc
+ 0), *(GLenum
*) (pc
+ 4),
305 *(GLenum
*) (pc
+ 8), answer
);
307 if (__glXErrorOccured()) {
308 __GLX_BEGIN_REPLY(0);
312 __GLX_BEGIN_REPLY(compsize
);
313 ((xGLXGetConvolutionFilterReply
*) &__glXReply
)->width
= width
;
314 ((xGLXGetConvolutionFilterReply
*) &__glXReply
)->height
= height
;
316 __GLX_SEND_VOID_ARRAY(compsize
);
323 __glXDisp_GetConvolutionFilter(__GLXclientState
* cl
, GLbyte
* pc
)
325 const GLXContextTag tag
= __GLX_GET_SINGLE_CONTEXT_TAG(pc
);
327 return GetConvolutionFilter(cl
, pc
+ __GLX_SINGLE_HDR_SIZE
, tag
);
331 __glXDisp_GetConvolutionFilterEXT(__GLXclientState
* cl
, GLbyte
* pc
)
333 const GLXContextTag tag
= __GLX_GET_VENDPRIV_CONTEXT_TAG(pc
);
335 return GetConvolutionFilter(cl
, pc
+ __GLX_VENDPRIV_HDR_SIZE
, tag
);
339 GetHistogram(__GLXclientState
* cl
, GLbyte
* pc
, GLXContextTag tag
)
342 GLenum format
, type
, target
;
343 GLboolean swapBytes
, reset
;
345 ClientPtr client
= cl
->client
;
347 char *answer
, answerBuffer
[200];
350 cx
= __glXForceCurrent(cl
, tag
, &error
);
355 format
= *(GLenum
*) (pc
+ 4);
356 type
= *(GLenum
*) (pc
+ 8);
357 target
= *(GLenum
*) (pc
+ 0);
358 swapBytes
= *(GLboolean
*) (pc
+ 12);
359 reset
= *(GLboolean
*) (pc
+ 13);
361 glGetHistogramParameteriv(target
, GL_HISTOGRAM_WIDTH
, &width
);
363 * The one query above might fail if we're in a state where queries
364 * are illegal, but then width would still be zero anyway.
366 compsize
= __glGetTexImage_size(target
, 1, format
, type
, width
, 1, 1);
370 glPixelStorei(GL_PACK_SWAP_BYTES
, swapBytes
);
371 __GLX_GET_ANSWER_BUFFER(answer
, cl
, compsize
, 1);
372 __glXClearErrorOccured();
373 glGetHistogram(target
, reset
, format
, type
, answer
);
375 if (__glXErrorOccured()) {
376 __GLX_BEGIN_REPLY(0);
380 __GLX_BEGIN_REPLY(compsize
);
381 ((xGLXGetHistogramReply
*) &__glXReply
)->width
= width
;
383 __GLX_SEND_VOID_ARRAY(compsize
);
390 __glXDisp_GetHistogram(__GLXclientState
* cl
, GLbyte
* pc
)
392 const GLXContextTag tag
= __GLX_GET_SINGLE_CONTEXT_TAG(pc
);
394 return GetHistogram(cl
, pc
+ __GLX_SINGLE_HDR_SIZE
, tag
);
398 __glXDisp_GetHistogramEXT(__GLXclientState
* cl
, GLbyte
* pc
)
400 const GLXContextTag tag
= __GLX_GET_VENDPRIV_CONTEXT_TAG(pc
);
402 return GetHistogram(cl
, pc
+ __GLX_VENDPRIV_HDR_SIZE
, tag
);
406 GetMinmax(__GLXclientState
* cl
, GLbyte
* pc
, GLXContextTag tag
)
409 GLenum format
, type
, target
;
410 GLboolean swapBytes
, reset
;
412 ClientPtr client
= cl
->client
;
414 char *answer
, answerBuffer
[200];
416 cx
= __glXForceCurrent(cl
, tag
, &error
);
421 format
= *(GLenum
*) (pc
+ 4);
422 type
= *(GLenum
*) (pc
+ 8);
423 target
= *(GLenum
*) (pc
+ 0);
424 swapBytes
= *(GLboolean
*) (pc
+ 12);
425 reset
= *(GLboolean
*) (pc
+ 13);
427 compsize
= __glGetTexImage_size(target
, 1, format
, type
, 2, 1, 1);
431 glPixelStorei(GL_PACK_SWAP_BYTES
, swapBytes
);
432 __GLX_GET_ANSWER_BUFFER(answer
, cl
, compsize
, 1);
433 __glXClearErrorOccured();
434 glGetMinmax(target
, reset
, format
, type
, answer
);
436 if (__glXErrorOccured()) {
437 __GLX_BEGIN_REPLY(0);
441 __GLX_BEGIN_REPLY(compsize
);
443 __GLX_SEND_VOID_ARRAY(compsize
);
450 __glXDisp_GetMinmax(__GLXclientState
* cl
, GLbyte
* pc
)
452 const GLXContextTag tag
= __GLX_GET_SINGLE_CONTEXT_TAG(pc
);
454 return GetMinmax(cl
, pc
+ __GLX_SINGLE_HDR_SIZE
, tag
);
458 __glXDisp_GetMinmaxEXT(__GLXclientState
* cl
, GLbyte
* pc
)
460 const GLXContextTag tag
= __GLX_GET_VENDPRIV_CONTEXT_TAG(pc
);
462 return GetMinmax(cl
, pc
+ __GLX_VENDPRIV_HDR_SIZE
, tag
);
466 GetColorTable(__GLXclientState
* cl
, GLbyte
* pc
, GLXContextTag tag
)
469 GLenum format
, type
, target
;
472 ClientPtr client
= cl
->client
;
474 char *answer
, answerBuffer
[200];
477 cx
= __glXForceCurrent(cl
, tag
, &error
);
482 target
= *(GLenum
*) (pc
+ 0);
483 format
= *(GLenum
*) (pc
+ 4);
484 type
= *(GLenum
*) (pc
+ 8);
485 swapBytes
= *(GLboolean
*) (pc
+ 12);
487 glGetColorTableParameteriv(target
, GL_COLOR_TABLE_WIDTH
, &width
);
489 * The one query above might fail if we're in a state where queries
490 * are illegal, but then width would still be zero anyway.
492 compsize
= __glGetTexImage_size(target
, 1, format
, type
, width
, 1, 1);
496 glPixelStorei(GL_PACK_SWAP_BYTES
, swapBytes
);
497 __GLX_GET_ANSWER_BUFFER(answer
, cl
, compsize
, 1);
498 __glXClearErrorOccured();
499 glGetColorTable(*(GLenum
*) (pc
+ 0), *(GLenum
*) (pc
+ 4),
500 *(GLenum
*) (pc
+ 8), answer
);
502 if (__glXErrorOccured()) {
503 __GLX_BEGIN_REPLY(0);
507 __GLX_BEGIN_REPLY(compsize
);
508 ((xGLXGetColorTableReply
*) &__glXReply
)->width
= width
;
510 __GLX_SEND_VOID_ARRAY(compsize
);
517 __glXDisp_GetColorTable(__GLXclientState
* cl
, GLbyte
* pc
)
519 const GLXContextTag tag
= __GLX_GET_SINGLE_CONTEXT_TAG(pc
);
521 return GetColorTable(cl
, pc
+ __GLX_SINGLE_HDR_SIZE
, tag
);
525 __glXDisp_GetColorTableSGI(__GLXclientState
* cl
, GLbyte
* pc
)
527 const GLXContextTag tag
= __GLX_GET_VENDPRIV_CONTEXT_TAG(pc
);
529 return GetColorTable(cl
, pc
+ __GLX_VENDPRIV_HDR_SIZE
, tag
);