/**************************************************************************1*2* Copyright 2010 LunarG, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL20* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER21* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING22* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER23* DEALINGS IN THE SOFTWARE.24*25**************************************************************************/262728#ifndef EGLSYNC_INCLUDED29#define EGLSYNC_INCLUDED303132#include "c99_compat.h"3334#include "egltypedefs.h"35#include "egldisplay.h"363738/**39* "Base" class for device driver syncs.40*/41struct _egl_sync42{43/* A sync is a display resource */44_EGLResource Resource;4546EGLenum Type;47EGLenum SyncStatus;48EGLenum SyncCondition;49EGLAttrib CLEvent;50EGLint SyncFd;51};525354extern EGLBoolean55_eglInitSync(_EGLSync *sync, _EGLDisplay *disp, EGLenum type,56const EGLAttrib *attrib_list);575859extern EGLBoolean60_eglGetSyncAttrib(_EGLDisplay *disp, _EGLSync *sync,61EGLint attribute, EGLAttrib *value);626364/**65* Increment reference count for the sync.66*/67static inline _EGLSync *68_eglGetSync(_EGLSync *sync)69{70if (sync)71_eglGetResource(&sync->Resource);72return sync;73}747576/**77* Decrement reference count for the sync.78*/79static inline EGLBoolean80_eglPutSync(_EGLSync *sync)81{82return (sync) ? _eglPutResource(&sync->Resource) : EGL_FALSE;83}848586/**87* Link a sync to its display and return the handle of the link.88* The handle can be passed to client directly.89*/90static inline EGLSync91_eglLinkSync(_EGLSync *sync)92{93_eglLinkResource(&sync->Resource, _EGL_RESOURCE_SYNC);94return (EGLSync) sync;95}969798/**99* Unlink a linked sync from its display.100*/101static inline void102_eglUnlinkSync(_EGLSync *sync)103{104_eglUnlinkResource(&sync->Resource, _EGL_RESOURCE_SYNC);105}106107108/**109* Lookup a handle to find the linked sync.110* Return NULL if the handle has no corresponding linked sync.111*/112static inline _EGLSync *113_eglLookupSync(EGLSync handle, _EGLDisplay *disp)114{115_EGLSync *sync = (_EGLSync *) handle;116if (!disp || !_eglCheckResource((void *) sync, _EGL_RESOURCE_SYNC, disp))117sync = NULL;118return sync;119}120121122/**123* Return the handle of a linked sync, or EGL_NO_SYNC_KHR.124*/125static inline EGLSync126_eglGetSyncHandle(_EGLSync *sync)127{128_EGLResource *res = (_EGLResource *) sync;129return (res && _eglIsResourceLinked(res)) ?130(EGLSync) sync : EGL_NO_SYNC_KHR;131}132133134#endif /* EGLSYNC_INCLUDED */135136137