egl: Minor changes to the _EGLScreen interface.
[mesa.git] / src / egl / main / eglsync.h
1 #ifndef EGLSYNC_INCLUDED
2 #define EGLSYNC_INCLUDED
3
4
5 #include "egltypedefs.h"
6 #include "egldisplay.h"
7
8
9 #ifdef EGL_KHR_reusable_sync
10
11
12 /**
13 * "Base" class for device driver syncs.
14 */
15 struct _egl_sync
16 {
17 /* A sync is a display resource */
18 _EGLResource Resource;
19
20 EGLenum Type;
21 EGLenum SyncStatus;
22 EGLenum SyncCondition;
23 };
24
25
26 PUBLIC EGLBoolean
27 _eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type,
28 const EGLint *attrib_list);
29
30
31 extern EGLBoolean
32 _eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
33 EGLint attribute, EGLint *value);
34
35
36 /**
37 * Link a sync to its display and return the handle of the link.
38 * The handle can be passed to client directly.
39 */
40 static INLINE EGLSyncKHR
41 _eglLinkSync(_EGLSync *sync)
42 {
43 _eglLinkResource(&sync->Resource, _EGL_RESOURCE_SYNC);
44 return (EGLSyncKHR) sync;
45 }
46
47
48 /**
49 * Unlink a linked sync from its display.
50 */
51 static INLINE void
52 _eglUnlinkSync(_EGLSync *sync)
53 {
54 _eglUnlinkResource(&sync->Resource, _EGL_RESOURCE_SYNC);
55 }
56
57
58 /**
59 * Lookup a handle to find the linked sync.
60 * Return NULL if the handle has no corresponding linked sync.
61 */
62 static INLINE _EGLSync *
63 _eglLookupSync(EGLSyncKHR handle, _EGLDisplay *dpy)
64 {
65 _EGLSync *sync = (_EGLSync *) handle;
66 if (!dpy || !_eglCheckResource((void *) sync, _EGL_RESOURCE_SYNC, dpy))
67 sync = NULL;
68 return sync;
69 }
70
71
72 /**
73 * Return the handle of a linked sync, or EGL_NO_SYNC_KHR.
74 */
75 static INLINE EGLSyncKHR
76 _eglGetSyncHandle(_EGLSync *sync)
77 {
78 _EGLResource *res = (_EGLResource *) sync;
79 return (res && _eglIsResourceLinked(res)) ?
80 (EGLSyncKHR) sync : EGL_NO_SYNC_KHR;
81 }
82
83
84 /**
85 * Return true if the sync is linked to a display.
86 *
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.
89 */
90 static INLINE EGLBoolean
91 _eglIsSyncLinked(_EGLSync *sync)
92 {
93 _EGLResource *res = (_EGLResource *) sync;
94 return (res && _eglIsResourceLinked(res));
95 }
96
97
98 #endif /* EGL_KHR_reusable_sync */
99
100
101 #endif /* EGLSYNC_INCLUDED */