1/* 2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. 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, 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: 11 * 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. 16 * 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 23 * SOFTWARE. 24 * 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. 29 */ 30 31#ifdef HAVE_DIX_CONFIG_H 32#include <dix-config.h> 33#endif 34 35#include "glxserver.h" 36#include "glxext.h" 37#include "singlesize.h" 38#include "unpack.h" 39#include "indirect_dispatch.h" 40#include "indirect_size_get.h" 41#include "glapitable.h" 42#include "glapi.h" 43#include "glthread.h" 44#include "dispatch.h" 45 46int __glXDispSwap_ReadPixels(__GLXclientState *cl, GLbyte *pc) 47{ 48 GLsizei width, height; 49 GLenum format, type; 50 GLboolean swapBytes, lsbFirst; 51 GLint compsize; 52 __GLX_DECLARE_SWAP_VARIABLES; 53 __GLXcontext *cx; 54 ClientPtr client = cl->client; 55 int error; 56 char *answer, answerBuffer[200]; 57 58 REQUEST_FIXED_SIZE(xGLXSingleReq, 28); 59 60 __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag); 61 cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); 62 if (!cx) { 63 return error; 64 } 65 66 pc += __GLX_SINGLE_HDR_SIZE; 67 __GLX_SWAP_INT(pc+0); 68 __GLX_SWAP_INT(pc+4); 69 __GLX_SWAP_INT(pc+8); 70 __GLX_SWAP_INT(pc+12); 71 __GLX_SWAP_INT(pc+16); 72 __GLX_SWAP_INT(pc+20); 73 74 width = *(GLsizei *)(pc + 8); 75 height = *(GLsizei *)(pc + 12); 76 format = *(GLenum *)(pc + 16); 77 type = *(GLenum *)(pc + 20); 78 swapBytes = *(GLboolean *)(pc + 24); 79 lsbFirst = *(GLboolean *)(pc + 25); 80 compsize = __glReadPixels_size(format,type,width,height); 81 if (compsize < 0) 82 return BadLength; 83 84 CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) ); 85 CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_LSB_FIRST, lsbFirst) ); 86 __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); 87 __glXClearErrorOccured(); 88 CALL_ReadPixels( GET_DISPATCH(), 89 (*(GLint *)(pc + 0), 90 *(GLint *)(pc + 4), 91 *(GLsizei *)(pc + 8), 92 *(GLsizei *)(pc + 12), 93 *(GLenum *)(pc + 16), 94 *(GLenum *)(pc + 20), 95 answer) 96 ); 97 98 if (__glXErrorOccured()) { 99 __GLX_BEGIN_REPLY(0); 100 __GLX_SWAP_REPLY_HEADER(); 101 __GLX_SEND_HEADER(); 102 } else { 103 __GLX_BEGIN_REPLY(compsize); 104 __GLX_SWAP_REPLY_HEADER(); 105 __GLX_SEND_HEADER(); 106 __GLX_SEND_VOID_ARRAY(compsize); 107 } 108 __GLX_NOTE_FLUSHED_CMDS(cx); 109 return Success; 110} 111 112int __glXDispSwap_GetTexImage(__GLXclientState *cl, GLbyte *pc) 113{ 114 GLint level, compsize; 115 GLenum format, type, target; 116 GLboolean swapBytes; 117 __GLX_DECLARE_SWAP_VARIABLES; 118 __GLXcontext *cx; 119 ClientPtr client = cl->client; 120 int error; 121 char *answer, answerBuffer[200]; 122 GLint width=0, height=0, depth=1; 123 124 REQUEST_FIXED_SIZE(xGLXSingleReq, 20); 125 126 __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag); 127 cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); 128 if (!cx) { 129 return error; 130 } 131 132 pc += __GLX_SINGLE_HDR_SIZE; 133 __GLX_SWAP_INT(pc+0); 134 __GLX_SWAP_INT(pc+4); 135 __GLX_SWAP_INT(pc+8); 136 __GLX_SWAP_INT(pc+12); 137 138 level = *(GLint *)(pc + 4); 139 format = *(GLenum *)(pc + 8); 140 type = *(GLenum *)(pc + 12); 141 target = *(GLenum *)(pc + 0); 142 swapBytes = *(GLboolean *)(pc + 16); 143 144 CALL_GetTexLevelParameteriv( GET_DISPATCH(), (target, level, GL_TEXTURE_WIDTH, &width) ); 145 CALL_GetTexLevelParameteriv( GET_DISPATCH(), (target, level, GL_TEXTURE_HEIGHT, &height) ); 146 if ( target == GL_TEXTURE_3D) { 147 CALL_GetTexLevelParameteriv( GET_DISPATCH(), (target, level, GL_TEXTURE_DEPTH, &depth) ); 148 } 149 /* 150 * The three queries above might fail if we're in a state where queries 151 * are illegal, but then width, height, and depth would still be zero anyway. 152 */ 153 compsize = __glGetTexImage_size(target,level,format,type,width,height,depth); 154 if (compsize < 0) 155 return BadLength; 156 157 CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) ); 158 __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); 159 __glXClearErrorOccured(); 160 CALL_GetTexImage( GET_DISPATCH(), ( 161 *(GLenum *)(pc + 0), 162 *(GLint *)(pc + 4), 163 *(GLenum *)(pc + 8), 164 *(GLenum *)(pc + 12), 165 answer 166 ) ); 167 168 if (__glXErrorOccured()) { 169 __GLX_BEGIN_REPLY(0); 170 __GLX_SWAP_REPLY_HEADER(); 171 __GLX_SEND_HEADER(); 172 } else { 173 __GLX_BEGIN_REPLY(compsize); 174 __GLX_SWAP_REPLY_HEADER(); 175 __GLX_SWAP_INT(&width); 176 __GLX_SWAP_INT(&height); 177 __GLX_SWAP_INT(&depth); 178 ((xGLXGetTexImageReply *)&__glXReply)->width = width; 179 ((xGLXGetTexImageReply *)&__glXReply)->height = height; 180 ((xGLXGetTexImageReply *)&__glXReply)->depth = depth; 181 __GLX_SEND_HEADER(); 182 __GLX_SEND_VOID_ARRAY(compsize); 183 } 184 return Success; 185} 186 187int __glXDispSwap_GetPolygonStipple(__GLXclientState *cl, GLbyte *pc) 188{ 189 GLboolean lsbFirst; 190 __GLXcontext *cx; 191 ClientPtr client = cl->client; 192 int error; 193 GLubyte answerBuffer[200]; 194 char *answer; 195 __GLX_DECLARE_SWAP_VARIABLES; 196 197 REQUEST_FIXED_SIZE(xGLXSingleReq, 4); 198 199 __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag); 200 cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); 201 if (!cx) { 202 return error; 203 } 204 pc += __GLX_SINGLE_HDR_SIZE; 205 lsbFirst = *(GLboolean *)(pc + 0); 206 207 CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_LSB_FIRST, lsbFirst) ); 208 __GLX_GET_ANSWER_BUFFER(answer,cl,128,1); 209 210 __glXClearErrorOccured(); 211 CALL_GetPolygonStipple( GET_DISPATCH(), ((GLubyte *) answer) ); 212 if (__glXErrorOccured()) { 213 __GLX_BEGIN_REPLY(0); 214 __GLX_SWAP_REPLY_HEADER(); 215 __GLX_SEND_HEADER(); 216 } else { 217 __GLX_BEGIN_REPLY(128); 218 __GLX_SWAP_REPLY_HEADER(); 219 __GLX_SEND_HEADER(); 220 __GLX_SEND_BYTE_ARRAY(128); 221 } 222 return Success; 223} 224 225static int GetSeparableFilter(__GLXclientState *cl, GLbyte *pc, GLXContextTag tag) 226{ 227 GLint compsize, compsize2; 228 GLenum format, type, target; 229 GLboolean swapBytes; 230 __GLXcontext *cx; 231 ClientPtr client = cl->client; 232 int error; 233 __GLX_DECLARE_SWAP_VARIABLES; 234 char *answer, answerBuffer[200]; 235 GLint width=0, height=0; 236 237 cx = __glXForceCurrent(cl, tag, &error); 238 if (!cx) { 239 return error; 240 } 241 242 __GLX_SWAP_INT(pc+0); 243 __GLX_SWAP_INT(pc+4); 244 __GLX_SWAP_INT(pc+8); 245 246 format = *(GLenum *)(pc + 4); 247 type = *(GLenum *)(pc + 8); 248 target = *(GLenum *)(pc + 0); 249 swapBytes = *(GLboolean *)(pc + 12); 250 251 /* target must be SEPARABLE_2D, however I guess we can let the GL 252 barf on this one.... */ 253 254 CALL_GetConvolutionParameteriv( GET_DISPATCH(), (target, GL_CONVOLUTION_WIDTH, &width) ); 255 CALL_GetConvolutionParameteriv( GET_DISPATCH(), (target, GL_CONVOLUTION_HEIGHT, &height) ); 256 /* 257 * The two queries above might fail if we're in a state where queries 258 * are illegal, but then width and height would still be zero anyway. 259 */ 260 compsize = __glGetTexImage_size(target,1,format,type,width,1,1); 261 compsize2 = __glGetTexImage_size(target,1,format,type,height,1,1); 262 263 if ((compsize = safe_pad(compsize)) < 0) 264 return BadLength; 265 if ((compsize2 = safe_pad(compsize2)) < 0) 266 return BadLength; 267 268 CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) ); 269 __GLX_GET_ANSWER_BUFFER(answer, cl, safe_add(compsize, compsize2), 1); 270 __glXClearErrorOccured(); 271 CALL_GetSeparableFilter( GET_DISPATCH(), ( 272 *(GLenum *)(pc + 0), 273 *(GLenum *)(pc + 4), 274 *(GLenum *)(pc + 8), 275 answer, 276 answer + compsize, 277 NULL 278 ) ); 279 280 if (__glXErrorOccured()) { 281 __GLX_BEGIN_REPLY(0); 282 __GLX_SWAP_REPLY_HEADER(); 283 } else { 284 __GLX_BEGIN_REPLY(compsize + compsize2); 285 __GLX_SWAP_REPLY_HEADER(); 286 __GLX_SWAP_INT(&width); 287 __GLX_SWAP_INT(&height); 288 ((xGLXGetSeparableFilterReply *)&__glXReply)->width = width; 289 ((xGLXGetSeparableFilterReply *)&__glXReply)->height = height; 290 __GLX_SEND_VOID_ARRAY(compsize + compsize2); 291 } 292 293 return Success; 294} 295 296int __glXDispSwap_GetSeparableFilter(__GLXclientState *cl, GLbyte *pc) 297{ 298 const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc); 299 ClientPtr client = cl->client; 300 301 REQUEST_FIXED_SIZE(xGLXSingleReq, 16); 302 return GetSeparableFilter(cl, pc + __GLX_SINGLE_HDR_SIZE, tag); 303} 304 305int __glXDispSwap_GetSeparableFilterEXT(__GLXclientState *cl, GLbyte *pc) 306{ 307 const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc); 308 ClientPtr client = cl->client; 309 310 REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16); 311 return GetSeparableFilter(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag); 312} 313 314static int GetConvolutionFilter(__GLXclientState *cl, GLbyte *pc, GLXContextTag tag) 315{ 316 GLint compsize; 317 GLenum format, type, target; 318 GLboolean swapBytes; 319 __GLXcontext *cx; 320 ClientPtr client = cl->client; 321 int error; 322 __GLX_DECLARE_SWAP_VARIABLES; 323 char *answer, answerBuffer[200]; 324 GLint width=0, height=0; 325 326 cx = __glXForceCurrent(cl, tag, &error); 327 if (!cx) { 328 return error; 329 } 330 331 __GLX_SWAP_INT(pc+0); 332 __GLX_SWAP_INT(pc+4); 333 __GLX_SWAP_INT(pc+8); 334 335 format = *(GLenum *)(pc + 4); 336 type = *(GLenum *)(pc + 8); 337 target = *(GLenum *)(pc + 0); 338 swapBytes = *(GLboolean *)(pc + 12); 339 340 CALL_GetConvolutionParameteriv( GET_DISPATCH(), (target, GL_CONVOLUTION_WIDTH, &width) ); 341 if (target == GL_CONVOLUTION_2D) { 342 height = 1; 343 } else { 344 CALL_GetConvolutionParameteriv( GET_DISPATCH(), (target, GL_CONVOLUTION_HEIGHT, &height) ); 345 } 346 /* 347 * The two queries above might fail if we're in a state where queries 348 * are illegal, but then width and height would still be zero anyway. 349 */ 350 compsize = __glGetTexImage_size(target,1,format,type,width,height,1); 351 if (compsize < 0) 352 return BadLength; 353 354 CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) ); 355 __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); 356 __glXClearErrorOccured(); 357 CALL_GetConvolutionFilter( GET_DISPATCH(), ( 358 *(GLenum *)(pc + 0), 359 *(GLenum *)(pc + 4), 360 *(GLenum *)(pc + 8), 361 answer 362 ) ); 363 364 if (__glXErrorOccured()) { 365 __GLX_BEGIN_REPLY(0); 366 __GLX_SWAP_REPLY_HEADER(); 367 } else { 368 __GLX_BEGIN_REPLY(compsize); 369 __GLX_SWAP_REPLY_HEADER(); 370 __GLX_SWAP_INT(&width); 371 __GLX_SWAP_INT(&height); 372 ((xGLXGetConvolutionFilterReply *)&__glXReply)->width = width; 373 ((xGLXGetConvolutionFilterReply *)&__glXReply)->height = height; 374 __GLX_SEND_VOID_ARRAY(compsize); 375 } 376 377 return Success; 378} 379 380int __glXDispSwap_GetConvolutionFilter(__GLXclientState *cl, GLbyte *pc) 381{ 382 const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc); 383 ClientPtr client = cl->client; 384 385 REQUEST_FIXED_SIZE(xGLXSingleReq, 16); 386 return GetConvolutionFilter(cl, pc + __GLX_SINGLE_HDR_SIZE, tag); 387} 388 389int __glXDispSwap_GetConvolutionFilterEXT(__GLXclientState *cl, GLbyte *pc) 390{ 391 const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc); 392 ClientPtr client = cl->client; 393 394 REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16); 395 return GetConvolutionFilter(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag); 396} 397 398static int GetHistogram(__GLXclientState *cl, GLbyte *pc, GLXContextTag tag) 399{ 400 GLint compsize; 401 GLenum format, type, target; 402 GLboolean swapBytes, reset; 403 __GLXcontext *cx; 404 ClientPtr client = cl->client; 405 int error; 406 __GLX_DECLARE_SWAP_VARIABLES; 407 char *answer, answerBuffer[200]; 408 GLint width=0; 409 410 cx = __glXForceCurrent(cl, tag, &error); 411 if (!cx) { 412 return error; 413 } 414 415 __GLX_SWAP_INT(pc+0); 416 __GLX_SWAP_INT(pc+4); 417 __GLX_SWAP_INT(pc+8); 418 419 format = *(GLenum *)(pc + 4); 420 type = *(GLenum *)(pc + 8); 421 target = *(GLenum *)(pc + 0); 422 swapBytes = *(GLboolean *)(pc + 12); 423 reset = *(GLboolean *)(pc + 13); 424 425 CALL_GetHistogramParameteriv( GET_DISPATCH(), (target, GL_HISTOGRAM_WIDTH, &width) ); 426 /* 427 * The one query above might fail if we're in a state where queries 428 * are illegal, but then width would still be zero anyway. 429 */ 430 compsize = __glGetTexImage_size(target,1,format,type,width,1,1); 431 if (compsize < 0) 432 return BadLength; 433 434 CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) ); 435 __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); 436 __glXClearErrorOccured(); 437 CALL_GetHistogram( GET_DISPATCH(), (target, reset, format, type, answer) ); 438 439 if (__glXErrorOccured()) { 440 __GLX_BEGIN_REPLY(0); 441 __GLX_SWAP_REPLY_HEADER(); 442 } else { 443 __GLX_BEGIN_REPLY(compsize); 444 __GLX_SWAP_REPLY_HEADER(); 445 __GLX_SWAP_INT(&width); 446 ((xGLXGetHistogramReply *)&__glXReply)->width = width; 447 __GLX_SEND_VOID_ARRAY(compsize); 448 } 449 450 return Success; 451} 452 453int __glXDispSwap_GetHistogram(__GLXclientState *cl, GLbyte *pc) 454{ 455 const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc); 456 ClientPtr client = cl->client; 457 458 REQUEST_FIXED_SIZE(xGLXSingleReq, 16); 459 return GetHistogram(cl, pc + __GLX_SINGLE_HDR_SIZE, tag); 460} 461 462int __glXDispSwap_GetHistogramEXT(__GLXclientState *cl, GLbyte *pc) 463{ 464 const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc); 465 ClientPtr client = cl->client; 466 467 REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16); 468 return GetHistogram(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag); 469} 470 471static int GetMinmax(__GLXclientState *cl, GLbyte *pc, GLXContextTag tag) 472{ 473 GLint compsize; 474 GLenum format, type, target; 475 GLboolean swapBytes, reset; 476 __GLXcontext *cx; 477 ClientPtr client = cl->client; 478 int error; 479 __GLX_DECLARE_SWAP_VARIABLES; 480 char *answer, answerBuffer[200]; 481 482 cx = __glXForceCurrent(cl, tag, &error); 483 if (!cx) { 484 return error; 485 } 486 487 __GLX_SWAP_INT(pc+0); 488 __GLX_SWAP_INT(pc+4); 489 __GLX_SWAP_INT(pc+8); 490 491 format = *(GLenum *)(pc + 4); 492 type = *(GLenum *)(pc + 8); 493 target = *(GLenum *)(pc + 0); 494 swapBytes = *(GLboolean *)(pc + 12); 495 reset = *(GLboolean *)(pc + 13); 496 497 compsize = __glGetTexImage_size(target,1,format,type,2,1,1); 498 if (compsize < 0) 499 return BadLength; 500 501 CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) ); 502 __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); 503 __glXClearErrorOccured(); 504 CALL_GetMinmax( GET_DISPATCH(), (target, reset, format, type, answer) ); 505 506 if (__glXErrorOccured()) { 507 __GLX_BEGIN_REPLY(0); 508 __GLX_SWAP_REPLY_HEADER(); 509 } else { 510 __GLX_BEGIN_REPLY(compsize); 511 __GLX_SWAP_REPLY_HEADER(); 512 __GLX_SEND_VOID_ARRAY(compsize); 513 } 514 515 return Success; 516} 517 518int __glXDispSwap_GetMinmax(__GLXclientState *cl, GLbyte *pc) 519{ 520 const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc); 521 ClientPtr client = cl->client; 522 523 REQUEST_FIXED_SIZE(xGLXSingleReq, 16); 524 return GetMinmax(cl, pc + __GLX_SINGLE_HDR_SIZE, tag); 525} 526 527int __glXDispSwap_GetMinmaxEXT(__GLXclientState *cl, GLbyte *pc) 528{ 529 const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc); 530 ClientPtr client = cl->client; 531 532 REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16); 533 return GetMinmax(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag); 534} 535 536static int GetColorTable(__GLXclientState *cl, GLbyte *pc, GLXContextTag tag) 537{ 538 GLint compsize; 539 GLenum format, type, target; 540 GLboolean swapBytes; 541 __GLXcontext *cx; 542 ClientPtr client = cl->client; 543 int error; 544 __GLX_DECLARE_SWAP_VARIABLES; 545 char *answer, answerBuffer[200]; 546 GLint width=0; 547 548 cx = __glXForceCurrent(cl, tag, &error); 549 if (!cx) { 550 return error; 551 } 552 553 __GLX_SWAP_INT(pc+0); 554 __GLX_SWAP_INT(pc+4); 555 __GLX_SWAP_INT(pc+8); 556 557 format = *(GLenum *)(pc + 4); 558 type = *(GLenum *)(pc + 8); 559 target = *(GLenum *)(pc + 0); 560 swapBytes = *(GLboolean *)(pc + 12); 561 562 CALL_GetColorTableParameteriv( GET_DISPATCH(), (target, GL_COLOR_TABLE_WIDTH, &width) ); 563 /* 564 * The one query above might fail if we're in a state where queries 565 * are illegal, but then width would still be zero anyway. 566 */ 567 compsize = __glGetTexImage_size(target,1,format,type,width,1,1); 568 if (compsize < 0) 569 return BadLength; 570 571 CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) ); 572 __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); 573 __glXClearErrorOccured(); 574 CALL_GetColorTable( GET_DISPATCH(), ( 575 *(GLenum *)(pc + 0), 576 *(GLenum *)(pc + 4), 577 *(GLenum *)(pc + 8), 578 answer 579 ) ); 580 581 if (__glXErrorOccured()) { 582 __GLX_BEGIN_REPLY(0); 583 __GLX_SWAP_REPLY_HEADER(); 584 } else { 585 __GLX_BEGIN_REPLY(compsize); 586 __GLX_SWAP_REPLY_HEADER(); 587 __GLX_SWAP_INT(&width); 588 ((xGLXGetColorTableReply *)&__glXReply)->width = width; 589 __GLX_SEND_VOID_ARRAY(compsize); 590 } 591 592 return Success; 593} 594 595int __glXDispSwap_GetColorTable(__GLXclientState *cl, GLbyte *pc) 596{ 597 const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc); 598 ClientPtr client = cl->client; 599 600 REQUEST_FIXED_SIZE(xGLXSingleReq, 16); 601 return GetColorTable(cl, pc + __GLX_SINGLE_HDR_SIZE, tag); 602} 603 604int __glXDispSwap_GetColorTableSGI(__GLXclientState *cl, GLbyte *pc) 605{ 606 const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc); 607 ClientPtr client = cl->client; 608 609 REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16); 610 return GetColorTable(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag); 611} 612