swap_interval.c revision 4642e01f
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#define NEED_REPLIES
264642e01fSmrg#ifdef HAVE_DIX_CONFIG_H
274642e01fSmrg#include <dix-config.h>
284642e01fSmrg#endif
294642e01fSmrg
304642e01fSmrg#include "glxserver.h"
314642e01fSmrg#include "glxutil.h"
324642e01fSmrg#include "glxext.h"
334642e01fSmrg#include "singlesize.h"
344642e01fSmrg#include "unpack.h"
354642e01fSmrg#include "indirect_size_get.h"
364642e01fSmrg#include "indirect_dispatch.h"
374642e01fSmrg#include "glapitable.h"
384642e01fSmrg#include "glapi.h"
394642e01fSmrg#include "glthread.h"
404642e01fSmrg#include "dispatch.h"
414642e01fSmrg#include "glapioffsets.h"
424642e01fSmrg#include "glxbyteorder.h"
434642e01fSmrg
444642e01fSmrgstatic int DoSwapInterval(__GLXclientState *cl, GLbyte *pc, int do_swap);
454642e01fSmrg
464642e01fSmrgint DoSwapInterval(__GLXclientState *cl, GLbyte *pc, int do_swap)
474642e01fSmrg{
484642e01fSmrg    xGLXVendorPrivateReq * const req = (xGLXVendorPrivateReq *) pc;
494642e01fSmrg    ClientPtr client = cl->client;
504642e01fSmrg    const GLXContextTag tag = req->contextTag;
514642e01fSmrg    __GLXcontext *cx;
524642e01fSmrg    GLint interval;
534642e01fSmrg
544642e01fSmrg
554642e01fSmrg    cx = __glXLookupContextByTag(cl, tag);
564642e01fSmrg
574642e01fSmrg    LogMessage(X_ERROR, "%s: cx = %p, GLX screen = %p\n", __func__,
584642e01fSmrg	       cx, (cx == NULL) ? NULL : cx->pGlxScreen);
594642e01fSmrg    if ((cx == NULL) || (cx->pGlxScreen == NULL)) {
604642e01fSmrg	client->errorValue = tag;
614642e01fSmrg	return __glXError(GLXBadContext);
624642e01fSmrg    }
634642e01fSmrg
644642e01fSmrg    if (cx->pGlxScreen->swapInterval == NULL) {
654642e01fSmrg	LogMessage(X_ERROR, "AIGLX: cx->pGlxScreen->swapInterval == NULL\n");
664642e01fSmrg	client->errorValue = tag;
674642e01fSmrg	return __glXError(GLXUnsupportedPrivateRequest);
684642e01fSmrg    }
694642e01fSmrg
704642e01fSmrg    if (cx->drawPriv == NULL) {
714642e01fSmrg	client->errorValue = tag;
724642e01fSmrg	return __glXError(GLXBadDrawable);
734642e01fSmrg    }
744642e01fSmrg
754642e01fSmrg    pc += __GLX_VENDPRIV_HDR_SIZE;
764642e01fSmrg    interval = (do_swap)
774642e01fSmrg      ? bswap_32(*(int *)(pc + 0))
784642e01fSmrg      :          *(int *)(pc + 0);
794642e01fSmrg
804642e01fSmrg    (void) (*cx->pGlxScreen->swapInterval)(cx->drawPriv, interval);
814642e01fSmrg    return Success;
824642e01fSmrg}
834642e01fSmrg
844642e01fSmrgint __glXDisp_SwapIntervalSGI(__GLXclientState *cl, GLbyte *pc)
854642e01fSmrg{
864642e01fSmrg    return DoSwapInterval(cl, pc, 0);
874642e01fSmrg}
884642e01fSmrg
894642e01fSmrgint __glXDispSwap_SwapIntervalSGI(__GLXclientState *cl, GLbyte *pc)
904642e01fSmrg{
914642e01fSmrg    return DoSwapInterval(cl, pc, 1);
924642e01fSmrg}
93