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 * Link a sync to a display and return the handle of the link.
38 * The handle can be passed to client directly.
40 static INLINE EGLSyncKHR
41 _eglLinkSync(_EGLSync
*sync
, _EGLDisplay
*dpy
)
43 _eglLinkResource(&sync
->Resource
, _EGL_RESOURCE_SYNC
, dpy
);
44 return (EGLSyncKHR
) sync
;
49 * Unlink a linked sync from its display.
52 _eglUnlinkSync(_EGLSync
*sync
)
54 _eglUnlinkResource(&sync
->Resource
, _EGL_RESOURCE_SYNC
);
59 * Lookup a handle to find the linked sync.
60 * Return NULL if the handle has no corresponding linked sync.
62 static INLINE _EGLSync
*
63 _eglLookupSync(EGLSyncKHR handle
, _EGLDisplay
*dpy
)
65 _EGLSync
*sync
= (_EGLSync
*) handle
;
66 if (!dpy
|| !_eglCheckResource((void *) sync
, _EGL_RESOURCE_SYNC
, dpy
))
73 * Return the handle of a linked sync, or EGL_NO_SYNC_KHR.
75 static INLINE EGLSyncKHR
76 _eglGetSyncHandle(_EGLSync
*sync
)
78 _EGLResource
*res
= (_EGLResource
*) sync
;
79 return (res
&& _eglIsResourceLinked(res
)) ?
80 (EGLSyncKHR
) sync
: EGL_NO_SYNC_KHR
;
85 * Return true if the sync is linked to a display.
87 * The link is considered a reference to the sync (the display is owning the
88 * sync). Drivers should not destroy a sync when it is linked.
90 static INLINE EGLBoolean
91 _eglIsSyncLinked(_EGLSync
*sync
)
93 _EGLResource
*res
= (_EGLResource
*) sync
;
94 return (res
&& _eglIsResourceLinked(res
));
98 #endif /* EGL_KHR_reusable_sync */
101 #endif /* EGLSYNC_INCLUDED */