Merge branch 'master' into pipe-video
[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 _EGLSync *
32 _eglCreateSyncKHR(_EGLDriver *drv, _EGLDisplay *dpy,
33 EGLenum type, const EGLint *attrib_list);
34
35
36 extern EGLBoolean
37 _eglDestroySyncKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync);
38
39
40 extern EGLint
41 _eglClientWaitSyncKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
42 EGLint flags, EGLTimeKHR timeout);
43
44
45 extern EGLBoolean
46 _eglSignalSyncKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
47 EGLenum mode);
48
49
50 extern EGLBoolean
51 _eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
52 EGLint attribute, EGLint *value);
53
54
55 /**
56 * Link a sync to a display and return the handle of the link.
57 * The handle can be passed to client directly.
58 */
59 static INLINE EGLSyncKHR
60 _eglLinkSync(_EGLSync *sync, _EGLDisplay *dpy)
61 {
62 _eglLinkResource(&sync->Resource, _EGL_RESOURCE_SYNC, dpy);
63 return (EGLSyncKHR) sync;
64 }
65
66
67 /**
68 * Unlink a linked sync from its display.
69 */
70 static INLINE void
71 _eglUnlinkSync(_EGLSync *sync)
72 {
73 _eglUnlinkResource(&sync->Resource, _EGL_RESOURCE_SYNC);
74 }
75
76
77 /**
78 * Lookup a handle to find the linked sync.
79 * Return NULL if the handle has no corresponding linked sync.
80 */
81 static INLINE _EGLSync *
82 _eglLookupSync(EGLSyncKHR handle, _EGLDisplay *dpy)
83 {
84 _EGLSync *sync = (_EGLSync *) handle;
85 if (!dpy || !_eglCheckResource((void *) sync, _EGL_RESOURCE_SYNC, dpy))
86 sync = NULL;
87 return sync;
88 }
89
90
91 /**
92 * Return the handle of a linked sync, or EGL_NO_SYNC_KHR.
93 */
94 static INLINE EGLSyncKHR
95 _eglGetSyncHandle(_EGLSync *sync)
96 {
97 _EGLResource *res = (_EGLResource *) sync;
98 return (res && _eglIsResourceLinked(res)) ?
99 (EGLSyncKHR) sync : EGL_NO_SYNC_KHR;
100 }
101
102
103 /**
104 * Return true if the sync is linked to a display.
105 *
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.
108 */
109 static INLINE EGLBoolean
110 _eglIsSyncLinked(_EGLSync *sync)
111 {
112 _EGLResource *res = (_EGLResource *) sync;
113 return (res && _eglIsResourceLinked(res));
114 }
115
116
117 #endif /* EGL_KHR_reusable_sync */
118
119
120 #endif /* EGLSYNC_INCLUDED */