swap_interval.c revision 0b0d8713
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 "glapitable.h" 374642e01fSmrg#include "glapi.h" 384642e01fSmrg#include "glthread.h" 394642e01fSmrg#include "dispatch.h" 404642e01fSmrg#include "glapioffsets.h" 414642e01fSmrg#include "glxbyteorder.h" 424642e01fSmrg 434642e01fSmrgstatic int DoSwapInterval(__GLXclientState *cl, GLbyte *pc, int do_swap); 444642e01fSmrg 454642e01fSmrgint DoSwapInterval(__GLXclientState *cl, GLbyte *pc, int do_swap) 464642e01fSmrg{ 474642e01fSmrg xGLXVendorPrivateReq * const req = (xGLXVendorPrivateReq *) pc; 484642e01fSmrg ClientPtr client = cl->client; 494642e01fSmrg const GLXContextTag tag = req->contextTag; 504642e01fSmrg __GLXcontext *cx; 514642e01fSmrg GLint interval; 524642e01fSmrg 534642e01fSmrg 540b0d8713Smrg REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 4); 550b0d8713Smrg 564642e01fSmrg cx = __glXLookupContextByTag(cl, tag); 574642e01fSmrg 584642e01fSmrg if ((cx == NULL) || (cx->pGlxScreen == NULL)) { 594642e01fSmrg client->errorValue = tag; 604642e01fSmrg return __glXError(GLXBadContext); 614642e01fSmrg } 624642e01fSmrg 634642e01fSmrg if (cx->pGlxScreen->swapInterval == NULL) { 644642e01fSmrg LogMessage(X_ERROR, "AIGLX: cx->pGlxScreen->swapInterval == NULL\n"); 654642e01fSmrg client->errorValue = tag; 664642e01fSmrg return __glXError(GLXUnsupportedPrivateRequest); 674642e01fSmrg } 684642e01fSmrg 694642e01fSmrg if (cx->drawPriv == NULL) { 704642e01fSmrg client->errorValue = tag; 716747b715Smrg return BadValue; 724642e01fSmrg } 734642e01fSmrg 744642e01fSmrg pc += __GLX_VENDPRIV_HDR_SIZE; 754642e01fSmrg interval = (do_swap) 764642e01fSmrg ? bswap_32(*(int *)(pc + 0)) 774642e01fSmrg : *(int *)(pc + 0); 784642e01fSmrg 796747b715Smrg if (interval <= 0) 806747b715Smrg return BadValue; 816747b715Smrg 824642e01fSmrg (void) (*cx->pGlxScreen->swapInterval)(cx->drawPriv, interval); 834642e01fSmrg return Success; 844642e01fSmrg} 854642e01fSmrg 864642e01fSmrgint __glXDisp_SwapIntervalSGI(__GLXclientState *cl, GLbyte *pc) 874642e01fSmrg{ 884642e01fSmrg return DoSwapInterval(cl, pc, 0); 894642e01fSmrg} 904642e01fSmrg 914642e01fSmrgint __glXDispSwap_SwapIntervalSGI(__GLXclientState *cl, GLbyte *pc) 924642e01fSmrg{ 934642e01fSmrg return DoSwapInterval(cl, pc, 1); 944642e01fSmrg} 95