Merge branch 'lp-offset-twoside'
[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 * Increment reference count for the sync.
38 */
39 static INLINE _EGLSync *
40 _eglGetSync(_EGLSync *sync)
41 {
42 if (sync)
43 _eglGetResource(&sync->Resource);
44 return sync;
45 }
46
47
48 /**
49 * Decrement reference count for the sync.
50 */
51 static INLINE EGLBoolean
52 _eglPutSync(_EGLSync *sync)
53 {
54 return (sync) ? _eglPutResource(&sync->Resource) : EGL_FALSE;
55 }
56
57
58 /**
59 * Link a sync to its display and return the handle of the link.
60 * The handle can be passed to client directly.
61 */
62 static INLINE EGLSyncKHR
63 _eglLinkSync(_EGLSync *sync)
64 {
65 _eglLinkResource(&sync->Resource, _EGL_RESOURCE_SYNC);
66 return (EGLSyncKHR) sync;
67 }
68
69
70 /**
71 * Unlink a linked sync from its display.
72 */
73 static INLINE void
74 _eglUnlinkSync(_EGLSync *sync)
75 {
76 _eglUnlinkResource(&sync->Resource, _EGL_RESOURCE_SYNC);
77 }
78
79
80 /**
81 * Lookup a handle to find the linked sync.
82 * Return NULL if the handle has no corresponding linked sync.
83 */
84 static INLINE _EGLSync *
85 _eglLookupSync(EGLSyncKHR handle, _EGLDisplay *dpy)
86 {
87 _EGLSync *sync = (_EGLSync *) handle;
88 if (!dpy || !_eglCheckResource((void *) sync, _EGL_RESOURCE_SYNC, dpy))
89 sync = NULL;
90 return sync;
91 }
92
93
94 /**
95 * Return the handle of a linked sync, or EGL_NO_SYNC_KHR.
96 */
97 static INLINE EGLSyncKHR
98 _eglGetSyncHandle(_EGLSync *sync)
99 {
100 _EGLResource *res = (_EGLResource *) sync;
101 return (res && _eglIsResourceLinked(res)) ?
102 (EGLSyncKHR) sync : EGL_NO_SYNC_KHR;
103 }
104
105
106 #endif /* EGL_KHR_reusable_sync */
107
108
109 #endif /* EGLSYNC_INCLUDED */