Merge branch 'mesa_7_5_branch'
[mesa.git] / src / egl / main / eglcurrent.h
1 #ifndef EGLCURRENT_INCLUDED
2 #define EGLCURRENT_INCLUDED
3
4 #include "egltypedefs.h"
5
6
7 #define _EGL_API_NUM_INDICES \
8 (EGL_OPENGL_API - EGL_OPENGL_ES_API + 2) /* idx 0 is for EGL_NONE */
9
10
11 /**
12 * Per-thread info
13 */
14 struct _egl_thread_info
15 {
16 EGLint LastError;
17 _EGLContext *CurrentContexts[_EGL_API_NUM_INDICES];
18 /* use index for fast access to current context */
19 EGLint CurrentAPIIndex;
20 };
21
22
23 /**
24 * Return true if a client API enum can be converted to an index.
25 */
26 static INLINE EGLBoolean
27 _eglIsApiValid(EGLenum api)
28 {
29 return ((api >= EGL_OPENGL_ES_API && api <= EGL_OPENGL_API) ||
30 api == EGL_NONE);
31 }
32
33
34 /**
35 * Convert a client API enum to an index, for use by thread info.
36 * The client API enum is assumed to be valid.
37 */
38 static INLINE EGLint
39 _eglConvertApiToIndex(EGLenum api)
40 {
41 return (api != EGL_NONE) ? api - EGL_OPENGL_ES_API + 1 : 0;
42 }
43
44
45 /**
46 * Convert an index, used by thread info, to a client API enum.
47 * The index is assumed to be valid.
48 */
49 static INLINE EGLenum
50 _eglConvertApiFromIndex(EGLint idx)
51 {
52 return (idx) ? EGL_OPENGL_ES_API + idx - 1 : EGL_NONE;
53 }
54
55
56 extern _EGLThreadInfo *
57 _eglGetCurrentThread(void);
58
59
60 extern void
61 _eglDestroyCurrentThread(void);
62
63
64 extern EGLBoolean
65 _eglIsCurrentThreadDummy(void);
66
67
68 extern _EGLContext *
69 _eglGetCurrentContext(void);
70
71
72 extern _EGLDisplay *
73 _eglGetCurrentDisplay(void);
74
75
76 extern _EGLSurface *
77 _eglGetCurrentSurface(EGLint readdraw);
78
79
80 extern EGLBoolean
81 _eglError(EGLint errCode, const char *msg);
82
83
84 #endif /* EGLCURRENT_INCLUDED */