2 * Public EGL API entrypoints
4 * Generally, we use the EGLDisplay parameter as a key to lookup the
5 * appropriate device driver handle, then jump though the driver's
6 * dispatch table to handle the function.
8 * That allows us the option of supporting multiple, simultaneous,
9 * heterogeneous hardware devices in the future.
11 * The EGLDisplay, EGLConfig, EGLContext and EGLSurface types are
12 * opaque handles implemented with 32-bit unsigned integers.
13 * It's up to the driver function or fallback function to look up the
14 * handle and get an object.
15 * By using opaque handles, we leave open the possibility of having
16 * indirect rendering in the future, like GLX.
19 * Notes on naming conventions:
21 * eglFooBar - public EGL function
22 * EGL_FOO_BAR - public EGL token
23 * EGLDatatype - public EGL datatype
25 * _eglFooBar - private EGL function
26 * _EGLDatatype - private EGL datatype, typedef'd struct
27 * _egl_struct - private EGL struct, non-typedef'd
35 /**#include "glapi.h"**/
36 #include "eglcontext.h"
37 #include "egldisplay.h"
38 #include "egltypedefs.h"
39 #include "eglglobals.h"
40 #include "egldriver.h"
41 #include "eglsurface.h"
46 * NOTE: displayName is treated as a string in _eglChooseDriver()!!!
47 * This will probably change!
48 * See _eglChooseDriver() for details!
51 eglGetDisplay(NativeDisplayType displayName
)
55 dpy
= _eglNewDisplay(displayName
);
59 return EGL_NO_DISPLAY
;
64 eglInitialize(EGLDisplay dpy
, EGLint
*major
, EGLint
*minor
)
67 _EGLDriver
*drv
= _eglChooseDriver(dpy
);
69 return drv
->Initialize(drv
, dpy
, major
, minor
);
76 eglTerminate(EGLDisplay dpy
)
78 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
80 return _eglCloseDriver(drv
, dpy
);
87 eglQueryString(EGLDisplay dpy
, EGLint name
)
89 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
91 return drv
->QueryString(drv
, dpy
, name
);
98 eglGetConfigs(EGLDisplay dpy
, EGLConfig
*configs
, EGLint config_size
, EGLint
*num_config
)
100 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
101 /* XXX check drv for null in remaining functions */
102 return drv
->GetConfigs(drv
, dpy
, configs
, config_size
, num_config
);
107 eglChooseConfig(EGLDisplay dpy
, const EGLint
*attrib_list
, EGLConfig
*configs
, EGLint config_size
, EGLint
*num_config
)
109 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
110 return drv
->ChooseConfig(drv
, dpy
, attrib_list
, configs
, config_size
, num_config
);
115 eglGetConfigAttrib(EGLDisplay dpy
, EGLConfig config
, EGLint attribute
, EGLint
*value
)
117 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
118 return drv
->GetConfigAttrib(drv
, dpy
, config
, attribute
, value
);
123 eglCreateContext(EGLDisplay dpy
, EGLConfig config
, EGLContext share_list
, const EGLint
*attrib_list
)
125 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
126 return drv
->CreateContext(drv
, dpy
, config
, share_list
, attrib_list
);
131 eglDestroyContext(EGLDisplay dpy
, EGLContext ctx
)
133 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
134 return drv
->DestroyContext(drv
, dpy
, ctx
);
139 eglMakeCurrent(EGLDisplay dpy
, EGLSurface draw
, EGLSurface read
, EGLContext ctx
)
141 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
142 return drv
->MakeCurrent(drv
, dpy
, draw
, read
, ctx
);
147 eglQueryContext(EGLDisplay dpy
, EGLContext ctx
, EGLint attribute
, EGLint
*value
)
149 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
150 return drv
->QueryContext(drv
, dpy
, ctx
, attribute
, value
);
155 eglCreateWindowSurface(EGLDisplay dpy
, EGLConfig config
, NativeWindowType window
, const EGLint
*attrib_list
)
157 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
158 return drv
->CreateWindowSurface(drv
, dpy
, config
, window
, attrib_list
);
163 eglCreatePixmapSurface(EGLDisplay dpy
, EGLConfig config
, NativePixmapType pixmap
, const EGLint
*attrib_list
)
165 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
166 return drv
->CreatePixmapSurface(drv
, dpy
, config
, pixmap
, attrib_list
);
171 eglCreatePbufferSurface(EGLDisplay dpy
, EGLConfig config
, const EGLint
*attrib_list
)
173 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
174 return drv
->CreatePbufferSurface(drv
, dpy
, config
, attrib_list
);
179 eglDestroySurface(EGLDisplay dpy
, EGLSurface surface
)
181 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
182 return drv
->DestroySurface(drv
, dpy
, surface
);
187 eglQuerySurface(EGLDisplay dpy
, EGLSurface surface
, EGLint attribute
, EGLint
*value
)
189 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
190 return drv
->QuerySurface(drv
, dpy
, surface
, attribute
, value
);
195 eglSurfaceAttrib(EGLDisplay dpy
, EGLSurface surface
, EGLint attribute
, EGLint value
)
197 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
198 return drv
->SurfaceAttrib(drv
, dpy
, surface
, attribute
, value
);
203 eglBindTexImage(EGLDisplay dpy
, EGLSurface surface
, EGLint buffer
)
205 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
206 return drv
->BindTexImage(drv
, dpy
, surface
, buffer
);
211 eglReleaseTexImage(EGLDisplay dpy
, EGLSurface surface
, EGLint buffer
)
213 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
214 return drv
->ReleaseTexImage(drv
, dpy
, surface
, buffer
);
219 eglSwapInterval(EGLDisplay dpy
, EGLint interval
)
221 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
222 return drv
->SwapInterval(drv
, dpy
, interval
);
227 eglSwapBuffers(EGLDisplay dpy
, EGLSurface draw
)
229 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
230 return drv
->SwapBuffers(drv
, dpy
, draw
);
235 eglCopyBuffers(EGLDisplay dpy
, EGLSurface surface
, NativePixmapType target
)
237 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
238 return drv
->CopyBuffers(drv
, dpy
, surface
, target
);
245 EGLDisplay dpy
= eglGetCurrentDisplay();
246 if (dpy
!= EGL_NO_DISPLAY
) {
247 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
248 return drv
->WaitGL(drv
, dpy
);
256 eglWaitNative(EGLint engine
)
258 EGLDisplay dpy
= eglGetCurrentDisplay();
259 if (dpy
!= EGL_NO_DISPLAY
) {
260 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
261 return drv
->WaitNative(drv
, dpy
, engine
);
269 eglGetCurrentDisplay(void)
271 _EGLDisplay
*dpy
= _eglGetCurrentDisplay();
275 return EGL_NO_DISPLAY
;
280 eglGetCurrentContext(void)
282 _EGLContext
*ctx
= _eglGetCurrentContext();
286 return EGL_NO_CONTEXT
;
291 eglGetCurrentSurface(EGLint readdraw
)
293 _EGLSurface
*s
= _eglGetCurrentSurface(readdraw
);
297 return EGL_NO_SURFACE
;
304 EGLint e
= _eglGlobal
.LastError
;
305 _eglGlobal
.LastError
= EGL_SUCCESS
;
310 void (* APIENTRY
eglGetProcAddress(const char *procname
))()
312 typedef void (*genericFunc
)();
313 struct name_function
{
317 static struct name_function egl_functions
[] = {
318 /* alphabetical order */
319 { "eglBindTexImage", (_EGLProc
) eglBindTexImage
},
320 { "eglChooseConfig", (_EGLProc
) eglChooseConfig
},
321 { "eglCopyBuffers", (_EGLProc
) eglCopyBuffers
},
322 { "eglCreateContext", (_EGLProc
) eglCreateContext
},
323 { "eglCreatePbufferSurface", (_EGLProc
) eglCreatePbufferSurface
},
324 { "eglCreatePixmapSurface", (_EGLProc
) eglCreatePixmapSurface
},
325 { "eglCreateWindowSurface", (_EGLProc
) eglCreateWindowSurface
},
326 { "eglDestroyContext", (_EGLProc
) eglDestroyContext
},
327 { "eglDestroySurface", (_EGLProc
) eglDestroySurface
},
328 { "eglGetConfigAttrib", (_EGLProc
) eglGetConfigAttrib
},
329 { "eglGetConfigs", (_EGLProc
) eglGetConfigs
},
330 { "eglGetCurrentContext", (_EGLProc
) eglGetCurrentContext
},
331 { "eglGetCurrentDisplay", (_EGLProc
) eglGetCurrentDisplay
},
332 { "eglGetCurrentSurface", (_EGLProc
) eglGetCurrentSurface
},
333 { "eglGetDisplay", (_EGLProc
) eglGetDisplay
},
334 { "eglGetError", (_EGLProc
) eglGetError
},
335 { "eglGetProcAddress", (_EGLProc
) eglGetProcAddress
},
336 { "eglInitialize", (_EGLProc
) eglInitialize
},
337 { "eglMakeCurrent", (_EGLProc
) eglMakeCurrent
},
338 { "eglQueryContext", (_EGLProc
) eglQueryContext
},
339 { "eglQueryString", (_EGLProc
) eglQueryString
},
340 { "eglQuerySurface", (_EGLProc
) eglQuerySurface
},
341 { "eglReleaseTexImage", (_EGLProc
) eglReleaseTexImage
},
342 { "eglSurfaceAttrib", (_EGLProc
) eglSurfaceAttrib
},
343 { "eglSwapBuffers", (_EGLProc
) eglSwapBuffers
},
344 { "eglSwapInterval", (_EGLProc
) eglSwapInterval
},
345 { "eglTerminate", (_EGLProc
) eglTerminate
},
346 { "eglWaitGL", (_EGLProc
) eglWaitGL
},
347 { "eglWaitNative", (_EGLProc
) eglWaitNative
},
349 { "eglChooseModeMESA", (_EGLProc
) eglChooseModeMESA
},
350 { "eglGetModesMESA", (_EGLProc
) eglGetModesMESA
},
351 { "eglGetModeAttribMESA", (_EGLProc
) eglGetModeAttribMESA
},
352 { "eglGetScreensMESA", (_EGLProc
) eglGetScreensMESA
},
353 { "eglCreateScreenSurfaceMESA", (_EGLProc
) eglCreateScreenSurfaceMESA
},
354 { "eglShowSurfaceMESA", (_EGLProc
) eglShowSurfaceMESA
},
355 { "eglScreenPositionMESA", (_EGLProc
) eglScreenPositionMESA
},
356 { "eglQueryDisplayMESA", (_EGLProc
) eglQueryDisplayMESA
},
357 { "eglQueryScreenMESA", (_EGLProc
) eglQueryScreenMESA
},
358 { "eglQueryScreenSurfaceMESA", (_EGLProc
) eglQueryScreenSurfaceMESA
},
359 { "eglQueryScreenModeMESA", (_EGLProc
) eglQueryScreenModeMESA
},
360 { "eglQueryModeStringMESA", (_EGLProc
) eglQueryModeStringMESA
},
364 for (i
= 0; egl_functions
[i
].name
; i
++) {
365 if (strcmp(egl_functions
[i
].name
, procname
) == 0) {
366 return (genericFunc
) egl_functions
[i
].function
;
370 /* XXX enable this code someday */
371 return (genericFunc
) _glapi_get_proc_address(procname
);
379 * EGL_MESA_screen extension
383 eglChooseModeMESA(EGLDisplay dpy
, EGLScreenMESA screen
,
384 const EGLint
*attrib_list
, EGLModeMESA
*modes
,
385 EGLint modes_size
, EGLint
*num_modes
)
387 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
389 return drv
->ChooseModeMESA(drv
, dpy
, screen
, attrib_list
, modes
, modes_size
, num_modes
);
396 eglGetModesMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLModeMESA
*modes
, EGLint mode_size
, EGLint
*num_mode
)
398 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
400 return drv
->GetModesMESA(drv
, dpy
, screen
, modes
, mode_size
, num_mode
);
407 eglGetModeAttribMESA(EGLDisplay dpy
, EGLModeMESA mode
, EGLint attribute
, EGLint
*value
)
409 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
411 return drv
->GetModeAttribMESA(drv
, dpy
, mode
, attribute
, value
);
418 eglGetScreensMESA(EGLDisplay dpy
, EGLScreenMESA
*screens
, EGLint max_screens
, EGLint
*num_screens
)
420 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
422 return drv
->GetScreensMESA(drv
, dpy
, screens
, max_screens
, num_screens
);
429 eglCreateScreenSurfaceMESA(EGLDisplay dpy
, EGLConfig config
, const EGLint
*attrib_list
)
431 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
432 return drv
->CreateScreenSurfaceMESA(drv
, dpy
, config
, attrib_list
);
437 eglShowSurfaceMESA(EGLDisplay dpy
, EGLint screen
, EGLSurface surface
, EGLModeMESA mode
)
439 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
440 return drv
->ShowSurfaceMESA(drv
, dpy
, screen
, surface
, mode
);
445 eglScreenPositionMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLint x
, EGLint y
)
447 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
448 return drv
->ScreenPositionMESA(drv
, dpy
, screen
, x
, y
);
453 eglQueryDisplayMESA(EGLDisplay dpy
, EGLint attrib
, EGLint
*value
)
455 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
456 return drv
->QueryDisplayMESA(drv
, dpy
, attrib
, value
);
461 eglQueryScreenMESA( EGLDisplay dpy
, EGLScreenMESA screen
, EGLint attribute
, EGLint
*value
)
463 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
464 return drv
->QueryScreenMESA(drv
, dpy
, screen
, attribute
, value
);
469 eglQueryScreenSurfaceMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLSurface
*surface
)
471 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
472 return drv
->QueryScreenSurfaceMESA(drv
, dpy
, screen
, surface
);
477 eglQueryScreenModeMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLModeMESA
*mode
)
479 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
480 return drv
->QueryScreenModeMESA(drv
, dpy
, screen
, mode
);
485 eglQueryModeStringMESA(EGLDisplay dpy
, EGLModeMESA mode
)
487 _EGLDriver
*drv
= _eglLookupDriver(dpy
);
488 return drv
->QueryModeStringMESA(drv
, dpy
, mode
);