14642e01fSmrg/* 24642e01fSmrg * (C) Copyright IBM Corporation 2006 34642e01fSmrg * All Rights Reserved. 44642e01fSmrg * 54642e01fSmrg * Permission is hereby granted, free of charge, to any person obtaining a 64642e01fSmrg * copy of this software and associated documentation files (the "Software"), 74642e01fSmrg * to deal in the Software without restriction, including without limitation 84642e01fSmrg * on the rights to use, copy, modify, merge, publish, distribute, sub 94642e01fSmrg * license, and/or sell copies of the Software, and to permit persons to whom 104642e01fSmrg * the Software is furnished to do so, subject to the following conditions: 114642e01fSmrg * 124642e01fSmrg * The above copyright notice and this permission notice (including the next 134642e01fSmrg * paragraph) shall be included in all copies or substantial portions of the 144642e01fSmrg * Software. 154642e01fSmrg * 164642e01fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 174642e01fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 184642e01fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 194642e01fSmrg * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 204642e01fSmrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 214642e01fSmrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 224642e01fSmrg * USE OR OTHER DEALINGS IN THE SOFTWARE. 234642e01fSmrg */ 244642e01fSmrg 254642e01fSmrg#ifdef HAVE_DIX_CONFIG_H 264642e01fSmrg#include <dix-config.h> 274642e01fSmrg#endif 284642e01fSmrg 294642e01fSmrg#include "glxserver.h" 304642e01fSmrg#include "glxutil.h" 314642e01fSmrg#include "glxext.h" 324642e01fSmrg#include "singlesize.h" 334642e01fSmrg#include "unpack.h" 344642e01fSmrg#include "indirect_size_get.h" 354642e01fSmrg#include "indirect_dispatch.h" 364642e01fSmrg#include "glxbyteorder.h" 374642e01fSmrg 38f7df2e56Smrgstatic int DoSwapInterval(__GLXclientState * cl, GLbyte * pc, int do_swap); 394642e01fSmrg 40f7df2e56Smrgint 41f7df2e56SmrgDoSwapInterval(__GLXclientState * cl, GLbyte * pc, int do_swap) 424642e01fSmrg{ 43f7df2e56Smrg xGLXVendorPrivateReq *const req = (xGLXVendorPrivateReq *) pc; 444642e01fSmrg ClientPtr client = cl->client; 454642e01fSmrg const GLXContextTag tag = req->contextTag; 464642e01fSmrg __GLXcontext *cx; 474642e01fSmrg GLint interval; 484642e01fSmrg 49f7df2e56Smrg REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 4); 500b0d8713Smrg 514642e01fSmrg cx = __glXLookupContextByTag(cl, tag); 524642e01fSmrg 534642e01fSmrg if ((cx == NULL) || (cx->pGlxScreen == NULL)) { 54f7df2e56Smrg client->errorValue = tag; 55f7df2e56Smrg return __glXError(GLXBadContext); 564642e01fSmrg } 57f7df2e56Smrg 584642e01fSmrg if (cx->pGlxScreen->swapInterval == NULL) { 59f7df2e56Smrg LogMessage(X_ERROR, "AIGLX: cx->pGlxScreen->swapInterval == NULL\n"); 60f7df2e56Smrg client->errorValue = tag; 61f7df2e56Smrg return __glXError(GLXUnsupportedPrivateRequest); 624642e01fSmrg } 634642e01fSmrg 644642e01fSmrg if (cx->drawPriv == NULL) { 65f7df2e56Smrg client->errorValue = tag; 66f7df2e56Smrg return BadValue; 674642e01fSmrg } 68f7df2e56Smrg 694642e01fSmrg pc += __GLX_VENDPRIV_HDR_SIZE; 704642e01fSmrg interval = (do_swap) 71f7df2e56Smrg ? bswap_32(*(int *) (pc + 0)) 72f7df2e56Smrg : *(int *) (pc + 0); 734642e01fSmrg 746747b715Smrg if (interval <= 0) 75f7df2e56Smrg return BadValue; 766747b715Smrg 77f7df2e56Smrg (void) (*cx->pGlxScreen->swapInterval) (cx->drawPriv, interval); 784642e01fSmrg return Success; 794642e01fSmrg} 804642e01fSmrg 81f7df2e56Smrgint 82f7df2e56Smrg__glXDisp_SwapIntervalSGI(__GLXclientState * cl, GLbyte * pc) 834642e01fSmrg{ 844642e01fSmrg return DoSwapInterval(cl, pc, 0); 854642e01fSmrg} 864642e01fSmrg 87f7df2e56Smrgint 88f7df2e56Smrg__glXDispSwap_SwapIntervalSGI(__GLXclientState * cl, GLbyte * pc) 894642e01fSmrg{ 904642e01fSmrg return DoSwapInterval(cl, pc, 1); 914642e01fSmrg} 92