egl: Move context functions in egldisplay.[ch] to eglcontext.[ch].
[mesa.git] / src / egl / main / egldisplay.h
1 #ifndef EGLDISPLAY_INCLUDED
2 #define EGLDISPLAY_INCLUDED
3
4 #include "egltypedefs.h"
5 #include "egldefines.h"
6 #include "eglsurface.h"
7
8
9 /**
10 * Optional EGL extensions info.
11 */
12 struct _egl_extensions
13 {
14 EGLBoolean MESA_screen_surface;
15 EGLBoolean MESA_copy_context;
16
17 char String[_EGL_MAX_EXTENSIONS_LEN];
18 };
19
20
21 struct _egl_display
22 {
23 /* used to link displays */
24 _EGLDisplay *Next;
25
26 EGLNativeDisplayType NativeDisplay;
27
28 _EGLDriver *Driver;
29 void *DriverData; /* private to driver */
30
31 int APImajor, APIminor; /**< as returned by eglInitialize() */
32 char Version[1000]; /**< initialized from APImajor/minor, DriverName */
33
34 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
35 EGLint ClientAPIsMask;
36 char ClientAPIs[1000]; /**< updated by eglQueryString */
37
38 _EGLExtensions Extensions;
39
40 int LargestPbuffer;
41
42 EGLint NumScreens;
43 _EGLScreen **Screens; /* array [NumScreens] */
44
45 EGLint MaxConfigs;
46 EGLint NumConfigs;
47 _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */
48
49 /* lists of linked contexts and surface */
50 _EGLContext *ContextList;
51 _EGLSurface *SurfaceList;
52 };
53
54
55 extern void
56 _eglFiniDisplay(void);
57
58
59 extern _EGLDisplay *
60 _eglNewDisplay(NativeDisplayType displayName);
61
62
63 extern EGLDisplay
64 _eglLinkDisplay(_EGLDisplay *dpy);
65
66
67 extern void
68 _eglUnlinkDisplay(_EGLDisplay *dpy);
69
70
71 extern _EGLDisplay *
72 _eglFindDisplay(NativeDisplayType nativeDisplay);
73
74
75 PUBLIC void
76 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
77
78
79 PUBLIC void
80 _eglCleanupDisplay(_EGLDisplay *disp);
81
82
83 extern EGLSurface
84 _eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy);
85
86
87 extern void
88 _eglUnlinkSurface(_EGLSurface *surf);
89
90
91 #ifndef _EGL_SKIP_HANDLE_CHECK
92
93
94 extern EGLBoolean
95 _eglCheckDisplayHandle(EGLDisplay dpy);
96
97
98 extern EGLBoolean
99 _eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy);
100
101
102 #else /* !_EGL_SKIP_HANDLE_CHECK */
103
104 /* Only do a quick check. This is NOT standard compliant. */
105
106 static INLINE EGLBoolean
107 _eglCheckDisplayHandle(EGLDisplay dpy)
108 {
109 return ((_EGLDisplay *) dpy != NULL);
110 }
111
112
113 static INLINE EGLBoolean
114 _eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy)
115 {
116 _EGLSurface *s = (_EGLSurface *) surf;
117 return (dpy && s && s->Display == dpy);
118 }
119
120
121 #endif /* _EGL_SKIP_HANDLE_CHECK */
122
123
124 /**
125 * Lookup a handle to find the linked display.
126 * Return NULL if the handle has no corresponding linked display.
127 */
128 static INLINE _EGLDisplay *
129 _eglLookupDisplay(EGLDisplay display)
130 {
131 _EGLDisplay *dpy = (_EGLDisplay *) display;
132 if (!_eglCheckDisplayHandle(display))
133 dpy = NULL;
134 return dpy;
135 }
136
137
138 /**
139 * Return the handle of a linked display, or EGL_NO_DISPLAY.
140 */
141 static INLINE EGLDisplay
142 _eglGetDisplayHandle(_EGLDisplay *dpy)
143 {
144 return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
145 }
146
147
148 /**
149 * Return true if the display is linked.
150 */
151 static INLINE EGLBoolean
152 _eglIsDisplayLinked(_EGLDisplay *dpy)
153 {
154 return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY);
155 }
156
157
158 /**
159 * Lookup a handle to find the linked surface.
160 * Return NULL if the handle has no corresponding linked surface.
161 */
162 static INLINE _EGLSurface *
163 _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
164 {
165 _EGLSurface *surf = (_EGLSurface *) surface;
166 if (!_eglCheckSurfaceHandle(surf, dpy))
167 surf = NULL;
168 return surf;
169 }
170
171
172 /**
173 * Return the handle of a linked surface, or EGL_NO_SURFACE.
174 */
175 static INLINE EGLSurface
176 _eglGetSurfaceHandle(_EGLSurface *surf)
177 {
178 return (EGLSurface) ((surf && surf->Display) ? surf : EGL_NO_SURFACE);
179 }
180
181
182 /**
183 * Return true if the surface is linked to a display.
184 */
185 static INLINE EGLBoolean
186 _eglIsSurfaceLinked(_EGLSurface *surf)
187 {
188 return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE);
189 }
190
191
192 /**
193 * Cast an unsigned int to a pointer.
194 */
195 static INLINE void *
196 _eglUIntToPointer(unsigned int v)
197 {
198 return (void *) ((uintptr_t) v);
199 }
200
201
202 /**
203 * Cast a pointer to an unsigned int. The pointer must be one that is
204 * returned by _eglUIntToPointer.
205 */
206 static INLINE unsigned int
207 _eglPointerToUInt(const void *p)
208 {
209 return (unsigned int) ((uintptr_t) p);
210 }
211
212
213 #endif /* EGLDISPLAY_INCLUDED */