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 extern EGLBoolean
24 _eglInitCurrent(void);
25
26
27 extern void
28 _eglFiniCurrent(void);
29
30
31 /**
32 * Return true if a client API enum can be converted to an index.
33 */
34 static INLINE EGLBoolean
35 _eglIsApiValid(EGLenum api)
36 {
37 return ((api >= EGL_OPENGL_ES_API && api <= EGL_OPENGL_API) ||
38 api == EGL_NONE);
39 }
40
41
42 /**
43 * Convert a client API enum to an index, for use by thread info.
44 * The client API enum is assumed to be valid.
45 */
46 static INLINE EGLint
47 _eglConvertApiToIndex(EGLenum api)
48 {
49 return (api != EGL_NONE) ? api - EGL_OPENGL_ES_API + 1 : 0;
50 }
51
52
53 /**
54 * Convert an index, used by thread info, to a client API enum.
55 * The index is assumed to be valid.
56 */
57 static INLINE EGLenum
58 _eglConvertApiFromIndex(EGLint idx)
59 {
60 return (idx) ? EGL_OPENGL_ES_API + idx - 1 : EGL_NONE;
61 }
62
63
64 extern _EGLThreadInfo *
65 _eglGetCurrentThread(void);
66
67
68 extern void
69 _eglDestroyCurrentThread(void);
70
71
72 extern EGLBoolean
73 _eglIsCurrentThreadDummy(void);
74
75
76 extern _EGLContext *
77 _eglGetCurrentContext(void);
78
79
80 extern _EGLDisplay *
81 _eglGetCurrentDisplay(void);
82
83
84 extern _EGLSurface *
85 _eglGetCurrentSurface(EGLint readdraw);
86
87
88 extern EGLBoolean
89 _eglError(EGLint errCode, const char *msg);
90
91
92 #endif /* EGLCURRENT_INCLUDED */