1 #ifndef EGLSYNC_INCLUDED
2 #define EGLSYNC_INCLUDED
5 #include "egltypedefs.h"
6 #include "egldisplay.h"
9 #ifdef EGL_KHR_reusable_sync
13 * "Base" class for device driver syncs.
17 /* A sync is a display resource */
18 _EGLResource Resource
;
22 EGLenum SyncCondition
;
27 _eglInitSync(_EGLSync
*sync
, _EGLDisplay
*dpy
, EGLenum type
,
28 const EGLint
*attrib_list
);
32 _eglGetSyncAttribKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSync
*sync
,
33 EGLint attribute
, EGLint
*value
);
37 * Increment reference count for the sync.
39 static INLINE _EGLSync
*
40 _eglGetSync(_EGLSync
*sync
)
43 _eglGetResource(&sync
->Resource
);
49 * Decrement reference count for the sync.
51 static INLINE EGLBoolean
52 _eglPutSync(_EGLSync
*sync
)
54 return (sync
) ? _eglPutResource(&sync
->Resource
) : EGL_FALSE
;
59 * Link a sync to its display and return the handle of the link.
60 * The handle can be passed to client directly.
62 static INLINE EGLSyncKHR
63 _eglLinkSync(_EGLSync
*sync
)
65 _eglLinkResource(&sync
->Resource
, _EGL_RESOURCE_SYNC
);
66 return (EGLSyncKHR
) sync
;
71 * Unlink a linked sync from its display.
74 _eglUnlinkSync(_EGLSync
*sync
)
76 _eglUnlinkResource(&sync
->Resource
, _EGL_RESOURCE_SYNC
);
81 * Lookup a handle to find the linked sync.
82 * Return NULL if the handle has no corresponding linked sync.
84 static INLINE _EGLSync
*
85 _eglLookupSync(EGLSyncKHR handle
, _EGLDisplay
*dpy
)
87 _EGLSync
*sync
= (_EGLSync
*) handle
;
88 if (!dpy
|| !_eglCheckResource((void *) sync
, _EGL_RESOURCE_SYNC
, dpy
))
95 * Return the handle of a linked sync, or EGL_NO_SYNC_KHR.
97 static INLINE EGLSyncKHR
98 _eglGetSyncHandle(_EGLSync
*sync
)
100 _EGLResource
*res
= (_EGLResource
*) sync
;
101 return (res
&& _eglIsResourceLinked(res
)) ?
102 (EGLSyncKHR
) sync
: EGL_NO_SYNC_KHR
;
106 #endif /* EGL_KHR_reusable_sync */
109 #endif /* EGLSYNC_INCLUDED */