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. Internal objects are linked to a display to
15 * For each public API entry point, the opaque handles are looked up
16 * before being dispatched to the drivers. When it fails to look up
26 * is generated and the driver function is not called. An
27 * uninitialized EGLDisplay has no driver associated with it. When
28 * such display is detected,
34 * Some of the entry points use current display, context, or surface
35 * implicitly. For such entry points, the implicit objects are also
36 * checked before calling the driver function. Other than the
37 * errors listed above,
39 * EGL_BAD_CURRENT_SURFACE
41 * may also be generated.
43 * Notes on naming conventions:
45 * eglFooBar - public EGL function
46 * EGL_FOO_BAR - public EGL token
47 * EGLDatatype - public EGL datatype
49 * _eglFooBar - private EGL function
50 * _EGLDatatype - private EGL datatype, typedef'd struct
51 * _egl_struct - private EGL struct, non-typedef'd
59 #include "eglcontext.h"
60 #include "egldisplay.h"
61 #include "egltypedefs.h"
62 #include "eglglobals.h"
63 #include "egldriver.h"
64 #include "eglsurface.h"
65 #include "eglconfig.h"
66 #include "eglscreen.h"
71 * This is typically the first EGL function that an application calls.
72 * We initialize our global vars and create a private _EGLDisplay object.
74 EGLDisplay EGLAPIENTRY
75 eglGetDisplay(NativeDisplayType nativeDisplay)
78 dpy = _eglFindDisplay(nativeDisplay);
80 dpy = _eglNewDisplay(nativeDisplay);
84 return _eglGetDisplayHandle(dpy);
89 * This is typically the second EGL function that an application calls.
90 * Here we load/initialize the actual hardware driver.
92 EGLBoolean EGLAPIENTRY
93 eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
95 _EGLDisplay *disp = _eglLookupDisplay(dpy);
97 EGLint major_int, minor_int;
100 return _eglError(EGL_BAD_DISPLAY, __FUNCTION__);
104 _eglPreloadDrivers();
106 drv = _eglOpenDriver(disp);
108 return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__);
110 /* Initialize the particular display now */
111 if (!drv->API.Initialize(drv, disp, &major_int, &minor_int)) {
112 _eglCloseDriver(drv, disp);
113 return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__);
116 disp->APImajor = major_int;
117 disp->APIminor = minor_int;
118 snprintf(disp->Version, sizeof(disp->Version),
119 "%d.%d (%s)", major_int, minor_int, drv->Name);
121 /* limit to APIs supported by core */
122 disp->ClientAPIsMask &= _EGL_API_ALL_BITS;
126 major_int = disp->APImajor;
127 minor_int = disp->APIminor;
130 /* Update applications version of major and minor if not NULL */
131 if ((major != NULL) && (minor != NULL)) {
140 EGLBoolean EGLAPIENTRY
141 eglTerminate(EGLDisplay dpy)
143 _EGLDisplay *disp = _eglLookupDisplay(dpy);
147 return _eglError(EGL_BAD_DISPLAY, __FUNCTION__);
151 drv->API.Terminate(drv, disp);
152 _eglCloseDriver(drv, disp);
161 * A bunch of check functions and declare macros to simply error checking.
163 static INLINE _EGLDriver *
164 _eglCheckDisplay(_EGLDisplay *disp, const char *msg)
167 _eglError(EGL_BAD_DISPLAY, msg);
171 _eglError(EGL_NOT_INITIALIZED, msg);
178 static INLINE _EGLDriver *
179 _eglCheckSurface(_EGLDisplay *disp, _EGLSurface *surf, const char *msg)
181 _EGLDriver *drv = _eglCheckDisplay(disp, msg);
185 _eglError(EGL_BAD_SURFACE, msg);
192 static INLINE _EGLDriver *
193 _eglCheckContext(_EGLDisplay *disp, _EGLContext *context, const char *msg)
195 _EGLDriver *drv = _eglCheckDisplay(disp, msg);
199 _eglError(EGL_BAD_CONTEXT, msg);
206 static INLINE _EGLDriver *
207 _eglCheckConfig(_EGLDisplay *disp, _EGLConfig *conf, const char *msg)
209 _EGLDriver *drv = _eglCheckDisplay(disp, msg);
213 _eglError(EGL_BAD_CONFIG, msg);
220 #define _EGL_DECLARE_DD(dpy) \
221 _EGLDisplay *disp = _eglLookupDisplay(dpy); \
224 drv = _eglCheckDisplay(disp, __FUNCTION__); \
230 #define _EGL_DECLARE_DD_AND_SURFACE(dpy, surface) \
231 _EGLDisplay *disp = _eglLookupDisplay(dpy); \
232 _EGLSurface *surf = _eglLookupSurface((surface), disp); \
235 drv = _eglCheckSurface(disp, surf, __FUNCTION__); \
241 #define _EGL_DECLARE_DD_AND_CONTEXT(dpy, ctx) \
242 _EGLDisplay *disp = _eglLookupDisplay(dpy); \
243 _EGLContext *context = _eglLookupContext((ctx), disp); \
246 drv = _eglCheckContext(disp, context, __FUNCTION__); \
252 #ifdef EGL_MESA_screen_surface
255 static INLINE _EGLDriver *
256 _eglCheckScreen(_EGLDisplay *disp, _EGLScreen *scrn, const char *msg)
258 _EGLDriver *drv = _eglCheckDisplay(disp, msg);
262 _eglError(EGL_BAD_SCREEN_MESA, msg);
269 static INLINE _EGLDriver *
270 _eglCheckMode(_EGLDisplay *disp, _EGLMode *m, const char *msg)
272 _EGLDriver *drv = _eglCheckDisplay(disp, msg);
276 _eglError(EGL_BAD_MODE_MESA, msg);
283 #define _EGL_DECLARE_DD_AND_SCREEN(dpy, screen) \
284 _EGLDisplay *disp = _eglLookupDisplay(dpy); \
285 _EGLScreen *scrn = _eglLookupScreen((screen), disp); \
288 drv = _eglCheckScreen(disp, scrn, __FUNCTION__); \
294 #define _EGL_DECLARE_DD_AND_MODE(dpy, mode) \
295 _EGLDisplay *disp = _eglLookupDisplay(dpy); \
296 _EGLMode *m = _eglLookupMode((mode), disp); \
299 drv = _eglCheckMode(disp, m, __FUNCTION__); \
305 #endif /* EGL_MESA_screen_surface */
308 const char * EGLAPIENTRY
309 eglQueryString(EGLDisplay dpy, EGLint name)
311 _EGL_DECLARE_DD(dpy);
312 return drv->API.QueryString(drv, disp, name);
316 EGLBoolean EGLAPIENTRY
317 eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
318 EGLint config_size, EGLint *num_config)
320 _EGL_DECLARE_DD(dpy);
321 return drv->API.GetConfigs(drv, disp, configs, config_size, num_config);
325 EGLBoolean EGLAPIENTRY
326 eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs,
327 EGLint config_size, EGLint *num_config)
329 _EGL_DECLARE_DD(dpy);
330 return drv->API.ChooseConfig(drv, disp, attrib_list, configs,
331 config_size, num_config);
335 EGLBoolean EGLAPIENTRY
336 eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
337 EGLint attribute, EGLint *value)
339 _EGLDisplay *disp = _eglLookupDisplay(dpy);
340 _EGLConfig *conf = _eglLookupConfig(config, disp);
343 drv = _eglCheckConfig(disp, conf, __FUNCTION__);
347 return drv->API.GetConfigAttrib(drv, disp, conf, attribute, value);
351 EGLContext EGLAPIENTRY
352 eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list,
353 const EGLint *attrib_list)
355 _EGLDisplay *disp = _eglLookupDisplay(dpy);
356 _EGLConfig *conf = _eglLookupConfig(config, disp);
357 _EGLContext *share = _eglLookupContext(share_list, disp);
359 _EGLContext *context;
361 drv = _eglCheckConfig(disp, conf, __FUNCTION__);
363 return EGL_NO_CONTEXT;
364 if (!share && share_list != EGL_NO_CONTEXT) {
365 _eglError(EGL_BAD_CONTEXT, __FUNCTION__);
366 return EGL_NO_CONTEXT;
369 context = drv->API.CreateContext(drv, disp, conf, share, attrib_list);
371 return _eglLinkContext(context, disp);
373 return EGL_NO_CONTEXT;
377 EGLBoolean EGLAPIENTRY
378 eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
380 _EGL_DECLARE_DD_AND_CONTEXT(dpy, ctx);
381 _eglUnlinkContext(context);
382 return drv->API.DestroyContext(drv, disp, context);
386 EGLBoolean EGLAPIENTRY
387 eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read,
390 _EGLDisplay *disp = _eglLookupDisplay(dpy);
391 _EGLContext *context = _eglLookupContext(ctx, disp);
392 _EGLSurface *draw_surf = _eglLookupSurface(draw, disp);
393 _EGLSurface *read_surf = _eglLookupSurface(read, disp);
396 drv = _eglCheckDisplay(disp, __FUNCTION__);
399 if (!context && ctx != EGL_NO_CONTEXT)
400 return _eglError(EGL_BAD_CONTEXT, __FUNCTION__);
401 if ((!draw_surf && draw != EGL_NO_SURFACE) ||
402 (!read_surf && read != EGL_NO_SURFACE))
403 return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
405 return drv->API.MakeCurrent(drv, disp, draw_surf, read_surf, context);
409 EGLBoolean EGLAPIENTRY
410 eglQueryContext(EGLDisplay dpy, EGLContext ctx,
411 EGLint attribute, EGLint *value)
413 _EGL_DECLARE_DD_AND_CONTEXT(dpy, ctx);
414 return drv->API.QueryContext(drv, disp, context, attribute, value);
418 EGLSurface EGLAPIENTRY
419 eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
420 NativeWindowType window, const EGLint *attrib_list)
422 _EGLDisplay *disp = _eglLookupDisplay(dpy);
423 _EGLConfig *conf = _eglLookupConfig(config, disp);
427 drv = _eglCheckConfig(disp, conf, __FUNCTION__);
429 return EGL_NO_SURFACE;
431 surf = drv->API.CreateWindowSurface(drv, disp, conf, window, attrib_list);
433 return _eglLinkSurface(surf, disp);
435 return EGL_NO_SURFACE;
439 EGLSurface EGLAPIENTRY
440 eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
441 NativePixmapType pixmap, const EGLint *attrib_list)
443 _EGLDisplay *disp = _eglLookupDisplay(dpy);
444 _EGLConfig *conf = _eglLookupConfig(config, disp);
448 drv = _eglCheckConfig(disp, conf, __FUNCTION__);
450 return EGL_NO_SURFACE;
452 surf = drv->API.CreatePixmapSurface(drv, disp, conf, pixmap, attrib_list);
454 return _eglLinkSurface(surf, disp);
456 return EGL_NO_SURFACE;
460 EGLSurface EGLAPIENTRY
461 eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
462 const EGLint *attrib_list)
464 _EGLDisplay *disp = _eglLookupDisplay(dpy);
465 _EGLConfig *conf = _eglLookupConfig(config, disp);
469 drv = _eglCheckConfig(disp, conf, __FUNCTION__);
471 return EGL_NO_SURFACE;
473 surf = drv->API.CreatePbufferSurface(drv, disp, conf, attrib_list);
475 return _eglLinkSurface(surf, disp);
477 return EGL_NO_SURFACE;
481 EGLBoolean EGLAPIENTRY
482 eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
484 _EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
485 _eglUnlinkSurface(surf);
486 return drv->API.DestroySurface(drv, disp, surf);
489 EGLBoolean EGLAPIENTRY
490 eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
491 EGLint attribute, EGLint *value)
493 _EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
494 return drv->API.QuerySurface(drv, disp, surf, attribute, value);
497 EGLBoolean EGLAPIENTRY
498 eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
499 EGLint attribute, EGLint value)
501 _EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
502 return drv->API.SurfaceAttrib(drv, disp, surf, attribute, value);
506 EGLBoolean EGLAPIENTRY
507 eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
509 _EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
510 return drv->API.BindTexImage(drv, disp, surf, buffer);
514 EGLBoolean EGLAPIENTRY
515 eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
517 _EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
518 return drv->API.ReleaseTexImage(drv, disp, surf, buffer);
522 EGLBoolean EGLAPIENTRY
523 eglSwapInterval(EGLDisplay dpy, EGLint interval)
525 _EGLContext *ctx = _eglGetCurrentContext();
527 _EGL_DECLARE_DD(dpy);
529 if (!ctx || !_eglIsContextLinked(ctx) || ctx->Resource.Display != disp)
530 return _eglError(EGL_BAD_CONTEXT, __FUNCTION__);
532 surf = ctx->DrawSurface;
533 if (!_eglIsSurfaceLinked(surf))
534 return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
536 return drv->API.SwapInterval(drv, disp, surf, interval);
540 EGLBoolean EGLAPIENTRY
541 eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
543 _EGLContext *ctx = _eglGetCurrentContext();
544 _EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
546 /* surface must be bound to current context in EGL 1.4 */
547 if (!ctx || !_eglIsContextLinked(ctx) || surf != ctx->DrawSurface)
548 return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
550 return drv->API.SwapBuffers(drv, disp, surf);
554 EGLBoolean EGLAPIENTRY
555 eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, NativePixmapType target)
557 _EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
558 return drv->API.CopyBuffers(drv, disp, surf, target);
562 EGLBoolean EGLAPIENTRY
565 _EGLContext *ctx = _eglGetCurrentContext();
571 /* let bad current context imply bad current surface */
572 if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface))
573 return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__);
575 /* a valid current context implies an initialized current display */
576 disp = ctx->Resource.Display;
580 return drv->API.WaitClient(drv, disp, ctx);
584 EGLBoolean EGLAPIENTRY
587 #ifdef EGL_VERSION_1_2
588 _EGLThreadInfo *t = _eglGetCurrentThread();
589 EGLint api_index = t->CurrentAPIIndex;
590 EGLint es_index = _eglConvertApiToIndex(EGL_OPENGL_ES_API);
593 if (api_index != es_index && _eglIsCurrentThreadDummy())
594 return _eglError(EGL_BAD_ALLOC, "eglWaitGL");
596 t->CurrentAPIIndex = es_index;
597 ret = eglWaitClient();
598 t->CurrentAPIIndex = api_index;
601 return eglWaitClient();
606 EGLBoolean EGLAPIENTRY
607 eglWaitNative(EGLint engine)
609 _EGLContext *ctx = _eglGetCurrentContext();
615 /* let bad current context imply bad current surface */
616 if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface))
617 return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__);
619 /* a valid current context implies an initialized current display */
620 disp = ctx->Resource.Display;
624 return drv->API.WaitNative(drv, disp, engine);
628 EGLDisplay EGLAPIENTRY
629 eglGetCurrentDisplay(void)
631 _EGLDisplay *dpy = _eglGetCurrentDisplay();
632 return _eglGetDisplayHandle(dpy);
636 EGLContext EGLAPIENTRY
637 eglGetCurrentContext(void)
639 _EGLContext *ctx = _eglGetCurrentContext();
640 return _eglGetContextHandle(ctx);
644 EGLSurface EGLAPIENTRY
645 eglGetCurrentSurface(EGLint readdraw)
647 _EGLContext *ctx = _eglGetCurrentContext();
651 return EGL_NO_SURFACE;
655 surf = ctx->DrawSurface;
658 surf = ctx->ReadSurface;
661 _eglError(EGL_BAD_PARAMETER, __FUNCTION__);
666 return _eglGetSurfaceHandle(surf);
673 _EGLThreadInfo *t = _eglGetCurrentThread();
674 EGLint e = t->LastError;
675 if (!_eglIsCurrentThreadDummy())
676 t->LastError = EGL_SUCCESS;
681 __eglMustCastToProperFunctionPointerType EGLAPIENTRY
682 eglGetProcAddress(const char *procname)
684 static const struct {
687 } egl_functions[] = {
688 /* extensions only */
689 #ifdef EGL_MESA_screen_surface
690 { "eglChooseModeMESA", (_EGLProc) eglChooseModeMESA },
691 { "eglGetModesMESA", (_EGLProc) eglGetModesMESA },
692 { "eglGetModeAttribMESA", (_EGLProc) eglGetModeAttribMESA },
693 { "eglCopyContextMESA", (_EGLProc) eglCopyContextMESA },
694 { "eglGetScreensMESA", (_EGLProc) eglGetScreensMESA },
695 { "eglCreateScreenSurfaceMESA", (_EGLProc) eglCreateScreenSurfaceMESA },
696 { "eglShowScreenSurfaceMESA", (_EGLProc) eglShowScreenSurfaceMESA },
697 { "eglScreenPositionMESA", (_EGLProc) eglScreenPositionMESA },
698 { "eglQueryScreenMESA", (_EGLProc) eglQueryScreenMESA },
699 { "eglQueryScreenSurfaceMESA", (_EGLProc) eglQueryScreenSurfaceMESA },
700 { "eglQueryScreenModeMESA", (_EGLProc) eglQueryScreenModeMESA },
701 { "eglQueryModeStringMESA", (_EGLProc) eglQueryModeStringMESA },
702 #endif /* EGL_MESA_screen_surface */
709 if (strncmp(procname, "egl", 3) == 0) {
710 for (i = 0; egl_functions[i].name; i++) {
711 if (strcmp(egl_functions[i].name, procname) == 0)
712 return egl_functions[i].function;
716 _eglPreloadDrivers();
718 /* now loop over drivers to query their procs */
719 for (i = 0; i < _eglGlobal.NumDrivers; i++) {
720 _EGLDriver *drv = _eglGlobal.Drivers[i];
721 _EGLProc p = drv->API.GetProcAddress(drv, procname);
730 #ifdef EGL_MESA_screen_surface
734 * EGL_MESA_screen extension
737 EGLBoolean EGLAPIENTRY
738 eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen,
739 const EGLint *attrib_list, EGLModeMESA *modes,
740 EGLint modes_size, EGLint *num_modes)
742 _EGL_DECLARE_DD_AND_SCREEN(dpy, screen);
743 return drv->API.ChooseModeMESA(drv, disp, scrn, attrib_list,
744 modes, modes_size, num_modes);
748 EGLBoolean EGLAPIENTRY
749 eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes,
750 EGLint mode_size, EGLint *num_mode)
752 _EGL_DECLARE_DD_AND_SCREEN(dpy, screen);
753 return drv->API.GetModesMESA(drv, disp, scrn, modes, mode_size, num_mode);
757 EGLBoolean EGLAPIENTRY
758 eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode,
759 EGLint attribute, EGLint *value)
761 _EGL_DECLARE_DD_AND_MODE(dpy, mode);
762 return drv->API.GetModeAttribMESA(drv, disp, m, attribute, value);
766 EGLBoolean EGLAPIENTRY
767 eglCopyContextMESA(EGLDisplay dpy, EGLContext source, EGLContext dest,
770 _EGLDisplay *disp = _eglLookupDisplay(dpy);
771 _EGLContext *source_context = _eglLookupContext(source, disp);
772 _EGLContext *dest_context = _eglLookupContext(dest, disp);
775 drv = _eglCheckContext(disp, source_context, __FUNCTION__);
776 if (!drv || !dest_context) {
778 _eglError(EGL_BAD_CONTEXT, __FUNCTION__);
782 return drv->API.CopyContextMESA(drv, disp, source_context, dest_context,
788 eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens,
789 EGLint max_screens, EGLint *num_screens)
791 _EGL_DECLARE_DD(dpy);
792 return drv->API.GetScreensMESA(drv, disp, screens,
793 max_screens, num_screens);
798 eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config,
799 const EGLint *attrib_list)
801 _EGLDisplay *disp = _eglLookupDisplay(dpy);
802 _EGLConfig *conf = _eglLookupConfig(config, disp);
806 drv = _eglCheckConfig(disp, conf, __FUNCTION__);
808 return EGL_NO_SURFACE;
810 surf = drv->API.CreateScreenSurfaceMESA(drv, disp, conf, attrib_list);
812 return _eglLinkSurface(surf, disp);
814 return EGL_NO_SURFACE;
819 eglShowScreenSurfaceMESA(EGLDisplay dpy, EGLint screen,
820 EGLSurface surface, EGLModeMESA mode)
822 _EGLDisplay *disp = _eglLookupDisplay(dpy);
823 _EGLScreen *scrn = _eglLookupScreen((EGLScreenMESA) screen, disp);
824 _EGLSurface *surf = _eglLookupSurface(surface, disp);
825 _EGLMode *m = _eglLookupMode(mode, disp);
828 drv = _eglCheckScreen(disp, scrn, __FUNCTION__);
831 if (!surf && surface != EGL_NO_SURFACE)
832 return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
833 if (!m && mode != EGL_NO_MODE_MESA)
834 return _eglError(EGL_BAD_MODE_MESA, __FUNCTION__);
836 return drv->API.ShowScreenSurfaceMESA(drv, disp, scrn, surf, m);
841 eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y)
843 _EGL_DECLARE_DD_AND_SCREEN(dpy, screen);
844 return drv->API.ScreenPositionMESA(drv, disp, scrn, x, y);
849 eglQueryScreenMESA(EGLDisplay dpy, EGLScreenMESA screen,
850 EGLint attribute, EGLint *value)
852 _EGL_DECLARE_DD_AND_SCREEN(dpy, screen);
853 return drv->API.QueryScreenMESA(drv, disp, scrn, attribute, value);
858 eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen,
861 _EGLDisplay *disp = _eglLookupDisplay(dpy);
862 _EGLScreen *scrn = _eglLookupScreen((EGLScreenMESA) screen, disp);
866 drv = _eglCheckScreen(disp, scrn, __FUNCTION__);
870 if (drv->API.QueryScreenSurfaceMESA(drv, disp, scrn, &surf) != EGL_TRUE)
873 *surface = _eglGetSurfaceHandle(surf);
874 return (surf != NULL);
879 eglQueryScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode)
881 _EGLDisplay *disp = _eglLookupDisplay(dpy);
882 _EGLScreen *scrn = _eglLookupScreen((EGLScreenMESA) screen, disp);
886 drv = _eglCheckScreen(disp, scrn, __FUNCTION__);
890 if (drv->API.QueryScreenModeMESA(drv, disp, scrn, &m) != EGL_TRUE)
900 eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode)
902 _EGL_DECLARE_DD_AND_MODE(dpy, mode);
903 return drv->API.QueryModeStringMESA(drv, disp, m);
907 #endif /* EGL_MESA_screen_surface */
914 #ifdef EGL_VERSION_1_2
918 * Specify the client API to use for subsequent calls including:
920 * eglGetCurrentContext()
921 * eglGetCurrentDisplay()
922 * eglGetCurrentSurface()
923 * eglMakeCurrent(when the ctx parameter is EGL NO CONTEXT)
926 * See section 3.7 "Rendering Context" in the EGL specification for details.
929 eglBindAPI(EGLenum api)
931 _EGLThreadInfo *t = _eglGetCurrentThread();
933 if (_eglIsCurrentThreadDummy())
934 return _eglError(EGL_BAD_ALLOC, "eglBindAPI");
936 if (!_eglIsApiValid(api))
937 return _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
939 t->CurrentAPIIndex = _eglConvertApiToIndex(api);
945 * Return the last value set with eglBindAPI().
950 /* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
951 _EGLThreadInfo *t = _eglGetCurrentThread();
952 return _eglConvertApiFromIndex(t->CurrentAPIIndex);
957 eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype,
958 EGLClientBuffer buffer, EGLConfig config,
959 const EGLint *attrib_list)
961 _EGLDisplay *disp = _eglLookupDisplay(dpy);
962 _EGLConfig *conf = _eglLookupConfig(config, disp);
966 drv = _eglCheckConfig(disp, conf, __FUNCTION__);
968 return EGL_NO_SURFACE;
970 surf = drv->API.CreatePbufferFromClientBuffer(drv, disp, buftype, buffer,
973 return _eglLinkSurface(surf, disp);
975 return EGL_NO_SURFACE;
980 eglReleaseThread(void)
982 /* unbind current context */
983 if (!_eglIsCurrentThreadDummy()) {
984 _EGLDisplay *disp = _eglGetCurrentDisplay();
988 (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL);
992 _eglDestroyCurrentThread();
997 #endif /* EGL_VERSION_1_2 */