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 _eglCreateSyncKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
,
33 EGLenum type
, const EGLint
*attrib_list
);
37 _eglDestroySyncKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSync
*sync
);
41 _eglClientWaitSyncKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSync
*sync
,
42 EGLint flags
, EGLTimeKHR timeout
);
46 _eglSignalSyncKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSync
*sync
,
51 _eglGetSyncAttribKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSync
*sync
,
52 EGLint attribute
, EGLint
*value
);
56 * Link a sync to a display and return the handle of the link.
57 * The handle can be passed to client directly.
59 static INLINE EGLSyncKHR
60 _eglLinkSync(_EGLSync
*sync
, _EGLDisplay
*dpy
)
62 _eglLinkResource(&sync
->Resource
, _EGL_RESOURCE_SYNC
, dpy
);
63 return (EGLSyncKHR
) sync
;
68 * Unlink a linked sync from its display.
71 _eglUnlinkSync(_EGLSync
*sync
)
73 _eglUnlinkResource(&sync
->Resource
, _EGL_RESOURCE_SYNC
);
78 * Lookup a handle to find the linked sync.
79 * Return NULL if the handle has no corresponding linked sync.
81 static INLINE _EGLSync
*
82 _eglLookupSync(EGLSyncKHR handle
, _EGLDisplay
*dpy
)
84 _EGLSync
*sync
= (_EGLSync
*) handle
;
85 if (!dpy
|| !_eglCheckResource((void *) sync
, _EGL_RESOURCE_SYNC
, dpy
))
92 * Return the handle of a linked sync, or EGL_NO_SYNC_KHR.
94 static INLINE EGLSyncKHR
95 _eglGetSyncHandle(_EGLSync
*sync
)
97 _EGLResource
*res
= (_EGLResource
*) sync
;
98 return (res
&& _eglIsResourceLinked(res
)) ?
99 (EGLSyncKHR
) sync
: EGL_NO_SYNC_KHR
;
104 * Return true if the sync is linked to a display.
106 * The link is considered a reference to the sync (the display is owning the
107 * sync). Drivers should not destroy a sync when it is linked.
109 static INLINE EGLBoolean
110 _eglIsSyncLinked(_EGLSync
*sync
)
112 _EGLResource
*res
= (_EGLResource
*) sync
;
113 return (res
&& _eglIsResourceLinked(res
));
117 #endif /* EGL_KHR_reusable_sync */
120 #endif /* EGLSYNC_INCLUDED */