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
;
26 _eglInitSync(_EGLSync
*sync
, _EGLDisplay
*dpy
, EGLenum type
,
27 const EGLint
*attrib_list
);
31 _eglCreateSyncKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
,
32 EGLenum type
, const EGLint
*attrib_list
);
36 _eglDestroySyncKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSync
*sync
);
40 _eglClientWaitSyncKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSync
*sync
,
41 EGLint flags
, EGLTimeKHR timeout
);
45 _eglSignalSyncKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSync
*sync
,
50 _eglGetSyncAttribKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSync
*sync
,
51 EGLint attribute
, EGLint
*value
);
55 * Link a sync to a display and return the handle of the link.
56 * The handle can be passed to client directly.
58 static INLINE EGLSyncKHR
59 _eglLinkSync(_EGLSync
*sync
, _EGLDisplay
*dpy
)
61 _eglLinkResource(&sync
->Resource
, _EGL_RESOURCE_SYNC
, dpy
);
62 return (EGLSyncKHR
) sync
;
67 * Unlink a linked sync from its display.
70 _eglUnlinkSync(_EGLSync
*sync
)
72 _eglUnlinkResource(&sync
->Resource
, _EGL_RESOURCE_SYNC
);
77 * Lookup a handle to find the linked sync.
78 * Return NULL if the handle has no corresponding linked sync.
80 static INLINE _EGLSync
*
81 _eglLookupSync(EGLSyncKHR handle
, _EGLDisplay
*dpy
)
83 _EGLSync
*sync
= (_EGLSync
*) handle
;
84 if (!dpy
|| !_eglCheckResource((void *) sync
, _EGL_RESOURCE_SYNC
, dpy
))
91 * Return the handle of a linked sync, or EGL_NO_SYNC_KHR.
93 static INLINE EGLSyncKHR
94 _eglGetSyncHandle(_EGLSync
*sync
)
96 _EGLResource
*res
= (_EGLResource
*) sync
;
97 return (res
&& _eglIsResourceLinked(res
)) ?
98 (EGLSyncKHR
) sync
: EGL_NO_SYNC_KHR
;
103 * Return true if the sync is linked to a display.
105 * The link is considered a reference to the sync (the display is owning the
106 * sync). Drivers should not destroy a sync when it is linked.
108 static INLINE EGLBoolean
109 _eglIsSyncLinked(_EGLSync
*sync
)
111 _EGLResource
*res
= (_EGLResource
*) sync
;
112 return (res
&& _eglIsResourceLinked(res
));
116 #endif /* EGL_KHR_reusable_sync */
119 #endif /* EGLSYNC_INCLUDED */