swap_interval.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * (C) Copyright IBM Corporation 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. * on the rights to use, copy, modify, merge, publish, distribute, sub
  9. * license, and/or sell copies of the Software, and to permit persons to whom
  10. * the 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. * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
  20. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  21. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  22. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. #ifdef HAVE_DIX_CONFIG_H
  25. #include <dix-config.h>
  26. #endif
  27. #include "glxserver.h"
  28. #include "glxutil.h"
  29. #include "glxext.h"
  30. #include "singlesize.h"
  31. #include "unpack.h"
  32. #include "indirect_size_get.h"
  33. #include "indirect_dispatch.h"
  34. #include "glxbyteorder.h"
  35. static int DoSwapInterval(__GLXclientState * cl, GLbyte * pc, int do_swap);
  36. int
  37. DoSwapInterval(__GLXclientState * cl, GLbyte * pc, int do_swap)
  38. {
  39. xGLXVendorPrivateReq *const req = (xGLXVendorPrivateReq *) pc;
  40. ClientPtr client = cl->client;
  41. const GLXContextTag tag = req->contextTag;
  42. __GLXcontext *cx;
  43. GLint interval;
  44. REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 4);
  45. cx = __glXLookupContextByTag(cl, tag);
  46. if ((cx == NULL) || (cx->pGlxScreen == NULL)) {
  47. client->errorValue = tag;
  48. return __glXError(GLXBadContext);
  49. }
  50. if (cx->pGlxScreen->swapInterval == NULL) {
  51. LogMessage(X_ERROR, "AIGLX: cx->pGlxScreen->swapInterval == NULL\n");
  52. client->errorValue = tag;
  53. return __glXError(GLXUnsupportedPrivateRequest);
  54. }
  55. if (cx->drawPriv == NULL) {
  56. client->errorValue = tag;
  57. return BadValue;
  58. }
  59. pc += __GLX_VENDPRIV_HDR_SIZE;
  60. interval = (do_swap)
  61. ? bswap_32(*(int *) (pc + 0))
  62. : *(int *) (pc + 0);
  63. if (interval <= 0)
  64. return BadValue;
  65. (void) (*cx->pGlxScreen->swapInterval) (cx->drawPriv, interval);
  66. return Success;
  67. }
  68. int
  69. __glXDisp_SwapIntervalSGI(__GLXclientState * cl, GLbyte * pc)
  70. {
  71. return DoSwapInterval(cl, pc, 0);
  72. }
  73. int
  74. __glXDispSwap_SwapIntervalSGI(__GLXclientState * cl, GLbyte * pc)
  75. {
  76. return DoSwapInterval(cl, pc, 1);
  77. }