1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
5 * Copyright 2010-2011 LunarG, Inc.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
28 **************************************************************************/
32 * Public EGL API entrypoints
34 * Generally, we use the EGLDisplay parameter as a key to lookup the
35 * appropriate device driver handle, then jump though the driver's
36 * dispatch table to handle the function.
38 * That allows us the option of supporting multiple, simultaneous,
39 * heterogeneous hardware devices in the future.
41 * The EGLDisplay, EGLConfig, EGLContext and EGLSurface types are
42 * opaque handles. Internal objects are linked to a display to
45 * For each public API entry point, the opaque handles are looked up
46 * before being dispatched to the drivers. When it fails to look up
56 * is generated and the driver function is not called. An
57 * uninitialized EGLDisplay has no driver associated with it. When
58 * such display is detected,
64 * Some of the entry points use current display, context, or surface
65 * implicitly. For such entry points, the implicit objects are also
66 * checked before calling the driver function. Other than the
67 * errors listed above,
69 * EGL_BAD_CURRENT_SURFACE
71 * may also be generated.
73 * Notes on naming conventions:
75 * eglFooBar - public EGL function
76 * EGL_FOO_BAR - public EGL token
77 * EGLDatatype - public EGL datatype
79 * _eglFooBar - private EGL function
80 * _EGLDatatype - private EGL datatype, typedef'd struct
81 * _egl_struct - private EGL struct, non-typedef'd
90 #include "eglcontext.h"
91 #include "egldisplay.h"
92 #include "egltypedefs.h"
93 #include "eglcurrent.h"
94 #include "egldriver.h"
95 #include "eglsurface.h"
96 #include "eglconfig.h"
97 #include "eglscreen.h"
104 * Macros to help return an API entrypoint.
106 * These macros will unlock the display and record the error code.
108 #define RETURN_EGL_ERROR(disp, err, ret) \
111 _eglUnlockDisplay(disp); \
112 /* EGL error codes are non-zero */ \
114 _eglError(err, __FUNCTION__); \
118 #define RETURN_EGL_SUCCESS(disp, ret) \
119 RETURN_EGL_ERROR(disp, EGL_SUCCESS, ret)
121 /* record EGL_SUCCESS only when ret evaluates to true */
122 #define RETURN_EGL_EVAL(disp, ret) \
123 RETURN_EGL_ERROR(disp, (ret) ? EGL_SUCCESS : 0, ret)
127 * A bunch of macros and checks to simplify error checking.
130 #define _EGL_CHECK_DISPLAY(disp, ret, drv) \
132 drv = _eglCheckDisplay(disp, __FUNCTION__); \
134 RETURN_EGL_ERROR(disp, 0, ret); \
137 #define _EGL_CHECK_OBJECT(disp, type, obj, ret, drv) \
139 drv = _eglCheck ## type(disp, obj, __FUNCTION__); \
141 RETURN_EGL_ERROR(disp, 0, ret); \
144 #define _EGL_CHECK_SURFACE(disp, surf, ret, drv) \
145 _EGL_CHECK_OBJECT(disp, Surface, surf, ret, drv)
147 #define _EGL_CHECK_CONTEXT(disp, context, ret, drv) \
148 _EGL_CHECK_OBJECT(disp, Context, context, ret, drv)
150 #define _EGL_CHECK_CONFIG(disp, conf, ret, drv) \
151 _EGL_CHECK_OBJECT(disp, Config, conf, ret, drv)
153 #define _EGL_CHECK_SCREEN(disp, scrn, ret, drv) \
154 _EGL_CHECK_OBJECT(disp, Screen, scrn, ret, drv)
156 #define _EGL_CHECK_MODE(disp, m, ret, drv) \
157 _EGL_CHECK_OBJECT(disp, Mode, m, ret, drv)
159 #define _EGL_CHECK_SYNC(disp, s, ret, drv) \
160 _EGL_CHECK_OBJECT(disp, Sync, s, ret, drv)
163 static INLINE _EGLDriver
*
164 _eglCheckDisplay(_EGLDisplay
*disp
, const char *msg
)
167 _eglError(EGL_BAD_DISPLAY
, msg
);
170 if (!disp
->Initialized
) {
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 static INLINE _EGLDriver
*
221 _eglCheckSync(_EGLDisplay
*disp
, _EGLSync
*s
, const char *msg
)
223 _EGLDriver
*drv
= _eglCheckDisplay(disp
, msg
);
227 _eglError(EGL_BAD_PARAMETER
, msg
);
234 #ifdef EGL_MESA_screen_surface
237 static INLINE _EGLDriver
*
238 _eglCheckScreen(_EGLDisplay
*disp
, _EGLScreen
*scrn
, const char *msg
)
240 _EGLDriver
*drv
= _eglCheckDisplay(disp
, msg
);
244 _eglError(EGL_BAD_SCREEN_MESA
, msg
);
251 static INLINE _EGLDriver
*
252 _eglCheckMode(_EGLDisplay
*disp
, _EGLMode
*m
, const char *msg
)
254 _EGLDriver
*drv
= _eglCheckDisplay(disp
, msg
);
258 _eglError(EGL_BAD_MODE_MESA
, msg
);
265 #endif /* EGL_MESA_screen_surface */
269 * Lookup and lock a display.
271 static INLINE _EGLDisplay
*
272 _eglLockDisplay(EGLDisplay display
)
274 _EGLDisplay
*dpy
= _eglLookupDisplay(display
);
276 _eglLockMutex(&dpy
->Mutex
);
285 _eglUnlockDisplay(_EGLDisplay
*dpy
)
287 _eglUnlockMutex(&dpy
->Mutex
);
292 * This is typically the first EGL function that an application calls.
293 * It associates a private _EGLDisplay object to the native display.
295 EGLDisplay EGLAPIENTRY
296 eglGetDisplay(EGLNativeDisplayType nativeDisplay
)
298 _EGLPlatformType plat
= _eglGetNativePlatform(nativeDisplay
);
299 _EGLDisplay
*dpy
= _eglFindDisplay(plat
, (void *) nativeDisplay
);
300 return _eglGetDisplayHandle(dpy
);
305 * This is typically the second EGL function that an application calls.
306 * Here we load/initialize the actual hardware driver.
308 EGLBoolean EGLAPIENTRY
309 eglInitialize(EGLDisplay dpy
, EGLint
*major
, EGLint
*minor
)
311 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
314 RETURN_EGL_ERROR(NULL
, EGL_BAD_DISPLAY
, EGL_FALSE
);
316 if (!disp
->Initialized
) {
317 if (!_eglMatchDriver(disp
, EGL_FALSE
))
318 RETURN_EGL_ERROR(disp
, EGL_NOT_INITIALIZED
, EGL_FALSE
);
320 /* limit to APIs supported by core */
321 disp
->ClientAPIs
&= _EGL_API_ALL_BITS
;
324 /* Update applications version of major and minor if not NULL */
325 if ((major
!= NULL
) && (minor
!= NULL
)) {
326 *major
= disp
->VersionMajor
;
327 *minor
= disp
->VersionMinor
;
330 RETURN_EGL_SUCCESS(disp
, EGL_TRUE
);
334 EGLBoolean EGLAPIENTRY
335 eglTerminate(EGLDisplay dpy
)
337 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
340 RETURN_EGL_ERROR(NULL
, EGL_BAD_DISPLAY
, EGL_FALSE
);
342 if (disp
->Initialized
) {
343 _EGLDriver
*drv
= disp
->Driver
;
345 drv
->API
.Terminate(drv
, disp
);
346 /* do not reset disp->Driver */
347 disp
->Initialized
= EGL_FALSE
;
350 RETURN_EGL_SUCCESS(disp
, EGL_TRUE
);
354 const char * EGLAPIENTRY
355 eglQueryString(EGLDisplay dpy
, EGLint name
)
357 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
361 _EGL_CHECK_DISPLAY(disp
, NULL
, drv
);
362 ret
= drv
->API
.QueryString(drv
, disp
, name
);
364 RETURN_EGL_EVAL(disp
, ret
);
368 EGLBoolean EGLAPIENTRY
369 eglGetConfigs(EGLDisplay dpy
, EGLConfig
*configs
,
370 EGLint config_size
, EGLint
*num_config
)
372 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
376 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
377 ret
= drv
->API
.GetConfigs(drv
, disp
, configs
, config_size
, num_config
);
379 RETURN_EGL_EVAL(disp
, ret
);
383 EGLBoolean EGLAPIENTRY
384 eglChooseConfig(EGLDisplay dpy
, const EGLint
*attrib_list
, EGLConfig
*configs
,
385 EGLint config_size
, EGLint
*num_config
)
387 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
391 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
392 ret
= drv
->API
.ChooseConfig(drv
, disp
, attrib_list
, configs
,
393 config_size
, num_config
);
395 RETURN_EGL_EVAL(disp
, ret
);
399 EGLBoolean EGLAPIENTRY
400 eglGetConfigAttrib(EGLDisplay dpy
, EGLConfig config
,
401 EGLint attribute
, EGLint
*value
)
403 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
404 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
408 _EGL_CHECK_CONFIG(disp
, conf
, EGL_FALSE
, drv
);
409 ret
= drv
->API
.GetConfigAttrib(drv
, disp
, conf
, attribute
, value
);
411 RETURN_EGL_EVAL(disp
, ret
);
415 EGLContext EGLAPIENTRY
416 eglCreateContext(EGLDisplay dpy
, EGLConfig config
, EGLContext share_list
,
417 const EGLint
*attrib_list
)
419 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
420 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
421 _EGLContext
*share
= _eglLookupContext(share_list
, disp
);
423 _EGLContext
*context
;
426 _EGL_CHECK_DISPLAY(disp
, EGL_NO_CONTEXT
, drv
);
429 /* config may be NULL if surfaceless */
430 if (!disp
->Extensions
.KHR_surfaceless_gles1
&&
431 !disp
->Extensions
.KHR_surfaceless_gles2
&&
432 !disp
->Extensions
.KHR_surfaceless_opengl
)
433 RETURN_EGL_ERROR(disp
, EGL_BAD_CONFIG
, EGL_NO_CONTEXT
);
436 if (!share
&& share_list
!= EGL_NO_CONTEXT
)
437 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_NO_CONTEXT
);
439 context
= drv
->API
.CreateContext(drv
, disp
, conf
, share
, attrib_list
);
440 ret
= (context
) ? _eglLinkContext(context
) : EGL_NO_CONTEXT
;
442 RETURN_EGL_EVAL(disp
, ret
);
446 EGLBoolean EGLAPIENTRY
447 eglDestroyContext(EGLDisplay dpy
, EGLContext ctx
)
449 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
450 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
454 _EGL_CHECK_CONTEXT(disp
, context
, EGL_FALSE
, drv
);
455 _eglUnlinkContext(context
);
456 ret
= drv
->API
.DestroyContext(drv
, disp
, context
);
458 RETURN_EGL_EVAL(disp
, ret
);
462 EGLBoolean EGLAPIENTRY
463 eglMakeCurrent(EGLDisplay dpy
, EGLSurface draw
, EGLSurface read
,
466 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
467 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
468 _EGLSurface
*draw_surf
= _eglLookupSurface(draw
, disp
);
469 _EGLSurface
*read_surf
= _eglLookupSurface(read
, disp
);
474 RETURN_EGL_ERROR(disp
, EGL_BAD_DISPLAY
, EGL_FALSE
);
477 /* display is allowed to be uninitialized under certain condition */
478 if (!disp
->Initialized
) {
479 if (draw
!= EGL_NO_SURFACE
|| read
!= EGL_NO_SURFACE
||
480 ctx
!= EGL_NO_CONTEXT
)
481 RETURN_EGL_ERROR(disp
, EGL_BAD_DISPLAY
, EGL_FALSE
);
484 RETURN_EGL_SUCCESS(disp
, EGL_TRUE
);
486 if (!context
&& ctx
!= EGL_NO_CONTEXT
)
487 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_FALSE
);
488 if (!draw_surf
|| !read_surf
) {
489 /* surfaces may be NULL if surfaceless */
490 if (!disp
->Extensions
.KHR_surfaceless_gles1
&&
491 !disp
->Extensions
.KHR_surfaceless_gles2
&&
492 !disp
->Extensions
.KHR_surfaceless_opengl
)
493 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
495 if ((!draw_surf
&& draw
!= EGL_NO_SURFACE
) ||
496 (!read_surf
&& read
!= EGL_NO_SURFACE
))
497 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
498 if (draw_surf
|| read_surf
)
499 RETURN_EGL_ERROR(disp
, EGL_BAD_MATCH
, EGL_FALSE
);
502 ret
= drv
->API
.MakeCurrent(drv
, disp
, draw_surf
, read_surf
, context
);
504 RETURN_EGL_EVAL(disp
, ret
);
508 EGLBoolean EGLAPIENTRY
509 eglQueryContext(EGLDisplay dpy
, EGLContext ctx
,
510 EGLint attribute
, EGLint
*value
)
512 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
513 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
517 _EGL_CHECK_CONTEXT(disp
, context
, EGL_FALSE
, drv
);
518 ret
= drv
->API
.QueryContext(drv
, disp
, context
, attribute
, value
);
520 RETURN_EGL_EVAL(disp
, ret
);
524 EGLSurface EGLAPIENTRY
525 eglCreateWindowSurface(EGLDisplay dpy
, EGLConfig config
,
526 EGLNativeWindowType window
, const EGLint
*attrib_list
)
528 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
529 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
534 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
535 if (disp
->Platform
!= _eglGetNativePlatform(disp
->PlatformDisplay
))
536 RETURN_EGL_ERROR(disp
, EGL_BAD_NATIVE_WINDOW
, EGL_NO_SURFACE
);
538 surf
= drv
->API
.CreateWindowSurface(drv
, disp
, conf
, window
, attrib_list
);
539 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
541 RETURN_EGL_EVAL(disp
, ret
);
545 EGLSurface EGLAPIENTRY
546 eglCreatePixmapSurface(EGLDisplay dpy
, EGLConfig config
,
547 EGLNativePixmapType pixmap
, const EGLint
*attrib_list
)
549 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
550 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
555 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
556 if (disp
->Platform
!= _eglGetNativePlatform(disp
->PlatformDisplay
))
557 RETURN_EGL_ERROR(disp
, EGL_BAD_NATIVE_PIXMAP
, EGL_NO_SURFACE
);
559 surf
= drv
->API
.CreatePixmapSurface(drv
, disp
, conf
, pixmap
, attrib_list
);
560 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
562 RETURN_EGL_EVAL(disp
, ret
);
566 EGLSurface EGLAPIENTRY
567 eglCreatePbufferSurface(EGLDisplay dpy
, EGLConfig config
,
568 const EGLint
*attrib_list
)
570 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
571 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
576 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
578 surf
= drv
->API
.CreatePbufferSurface(drv
, disp
, conf
, attrib_list
);
579 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
581 RETURN_EGL_EVAL(disp
, ret
);
585 EGLBoolean EGLAPIENTRY
586 eglDestroySurface(EGLDisplay dpy
, EGLSurface surface
)
588 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
589 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
593 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
594 _eglUnlinkSurface(surf
);
595 ret
= drv
->API
.DestroySurface(drv
, disp
, surf
);
597 RETURN_EGL_EVAL(disp
, ret
);
600 EGLBoolean EGLAPIENTRY
601 eglQuerySurface(EGLDisplay dpy
, EGLSurface surface
,
602 EGLint attribute
, EGLint
*value
)
604 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
605 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
609 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
610 ret
= drv
->API
.QuerySurface(drv
, disp
, surf
, attribute
, value
);
612 RETURN_EGL_EVAL(disp
, ret
);
615 EGLBoolean EGLAPIENTRY
616 eglSurfaceAttrib(EGLDisplay dpy
, EGLSurface surface
,
617 EGLint attribute
, EGLint value
)
619 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
620 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
624 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
625 ret
= drv
->API
.SurfaceAttrib(drv
, disp
, surf
, attribute
, value
);
627 RETURN_EGL_EVAL(disp
, ret
);
631 EGLBoolean EGLAPIENTRY
632 eglBindTexImage(EGLDisplay dpy
, EGLSurface surface
, EGLint buffer
)
634 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
635 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
639 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
640 ret
= drv
->API
.BindTexImage(drv
, disp
, surf
, buffer
);
642 RETURN_EGL_EVAL(disp
, ret
);
646 EGLBoolean EGLAPIENTRY
647 eglReleaseTexImage(EGLDisplay dpy
, EGLSurface surface
, EGLint buffer
)
649 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
650 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
654 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
655 ret
= drv
->API
.ReleaseTexImage(drv
, disp
, surf
, buffer
);
657 RETURN_EGL_EVAL(disp
, ret
);
661 EGLBoolean EGLAPIENTRY
662 eglSwapInterval(EGLDisplay dpy
, EGLint interval
)
664 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
665 _EGLContext
*ctx
= _eglGetCurrentContext();
670 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
672 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
673 ctx
->Resource
.Display
!= disp
)
674 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_FALSE
);
676 surf
= ctx
->DrawSurface
;
677 if (_eglGetSurfaceHandle(surf
) == EGL_NO_SURFACE
)
678 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
680 ret
= drv
->API
.SwapInterval(drv
, disp
, surf
, interval
);
682 RETURN_EGL_EVAL(disp
, ret
);
686 EGLBoolean EGLAPIENTRY
687 eglSwapBuffers(EGLDisplay dpy
, EGLSurface surface
)
689 _EGLContext
*ctx
= _eglGetCurrentContext();
690 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
691 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
695 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
697 /* surface must be bound to current context in EGL 1.4 */
698 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
699 surf
!= ctx
->DrawSurface
)
700 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
702 ret
= drv
->API
.SwapBuffers(drv
, disp
, surf
);
704 RETURN_EGL_EVAL(disp
, ret
);
708 EGLBoolean EGLAPIENTRY
709 eglCopyBuffers(EGLDisplay dpy
, EGLSurface surface
, EGLNativePixmapType target
)
711 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
712 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
716 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
717 if (disp
->Platform
!= _eglGetNativePlatform(disp
->PlatformDisplay
))
718 RETURN_EGL_ERROR(disp
, EGL_BAD_NATIVE_PIXMAP
, EGL_FALSE
);
719 ret
= drv
->API
.CopyBuffers(drv
, disp
, surf
, target
);
721 RETURN_EGL_EVAL(disp
, ret
);
725 EGLBoolean EGLAPIENTRY
728 _EGLContext
*ctx
= _eglGetCurrentContext();
734 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
736 disp
= ctx
->Resource
.Display
;
737 _eglLockMutex(&disp
->Mutex
);
739 /* let bad current context imply bad current surface */
740 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
741 _eglGetSurfaceHandle(ctx
->DrawSurface
) == EGL_NO_SURFACE
)
742 RETURN_EGL_ERROR(disp
, EGL_BAD_CURRENT_SURFACE
, EGL_FALSE
);
744 /* a valid current context implies an initialized current display */
745 assert(disp
->Initialized
);
747 ret
= drv
->API
.WaitClient(drv
, disp
, ctx
);
749 RETURN_EGL_EVAL(disp
, ret
);
753 EGLBoolean EGLAPIENTRY
756 _EGLThreadInfo
*t
= _eglGetCurrentThread();
757 EGLint api_index
= t
->CurrentAPIIndex
;
758 EGLint es_index
= _eglConvertApiToIndex(EGL_OPENGL_ES_API
);
761 if (api_index
!= es_index
&& _eglIsCurrentThreadDummy())
762 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_FALSE
);
764 t
->CurrentAPIIndex
= es_index
;
765 ret
= eglWaitClient();
766 t
->CurrentAPIIndex
= api_index
;
771 EGLBoolean EGLAPIENTRY
772 eglWaitNative(EGLint engine
)
774 _EGLContext
*ctx
= _eglGetCurrentContext();
780 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
782 disp
= ctx
->Resource
.Display
;
783 _eglLockMutex(&disp
->Mutex
);
785 /* let bad current context imply bad current surface */
786 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
787 _eglGetSurfaceHandle(ctx
->DrawSurface
) == EGL_NO_SURFACE
)
788 RETURN_EGL_ERROR(disp
, EGL_BAD_CURRENT_SURFACE
, EGL_FALSE
);
790 /* a valid current context implies an initialized current display */
791 assert(disp
->Initialized
);
793 ret
= drv
->API
.WaitNative(drv
, disp
, engine
);
795 RETURN_EGL_EVAL(disp
, ret
);
799 EGLDisplay EGLAPIENTRY
800 eglGetCurrentDisplay(void)
802 _EGLContext
*ctx
= _eglGetCurrentContext();
805 ret
= (ctx
) ? _eglGetDisplayHandle(ctx
->Resource
.Display
) : EGL_NO_DISPLAY
;
807 RETURN_EGL_SUCCESS(NULL
, ret
);
811 EGLContext EGLAPIENTRY
812 eglGetCurrentContext(void)
814 _EGLContext
*ctx
= _eglGetCurrentContext();
817 ret
= _eglGetContextHandle(ctx
);
819 RETURN_EGL_SUCCESS(NULL
, ret
);
823 EGLSurface EGLAPIENTRY
824 eglGetCurrentSurface(EGLint readdraw
)
826 _EGLContext
*ctx
= _eglGetCurrentContext();
827 EGLint err
= EGL_SUCCESS
;
832 RETURN_EGL_SUCCESS(NULL
, EGL_NO_SURFACE
);
836 surf
= ctx
->DrawSurface
;
839 surf
= ctx
->ReadSurface
;
843 err
= EGL_BAD_PARAMETER
;
847 ret
= _eglGetSurfaceHandle(surf
);
849 RETURN_EGL_ERROR(NULL
, err
, ret
);
856 _EGLThreadInfo
*t
= _eglGetCurrentThread();
857 EGLint e
= t
->LastError
;
858 if (!_eglIsCurrentThreadDummy())
859 t
->LastError
= EGL_SUCCESS
;
864 __eglMustCastToProperFunctionPointerType EGLAPIENTRY
865 eglGetProcAddress(const char *procname
)
867 static const struct {
870 } egl_functions
[] = {
871 /* core functions should not be queryable, but, well... */
872 #ifdef _EGL_GET_CORE_ADDRESSES
873 /* alphabetical order */
874 { "eglBindAPI", (_EGLProc
) eglBindAPI
},
875 { "eglBindTexImage", (_EGLProc
) eglBindTexImage
},
876 { "eglChooseConfig", (_EGLProc
) eglChooseConfig
},
877 { "eglCopyBuffers", (_EGLProc
) eglCopyBuffers
},
878 { "eglCreateContext", (_EGLProc
) eglCreateContext
},
879 { "eglCreatePbufferFromClientBuffer", (_EGLProc
) eglCreatePbufferFromClientBuffer
},
880 { "eglCreatePbufferSurface", (_EGLProc
) eglCreatePbufferSurface
},
881 { "eglCreatePixmapSurface", (_EGLProc
) eglCreatePixmapSurface
},
882 { "eglCreateWindowSurface", (_EGLProc
) eglCreateWindowSurface
},
883 { "eglDestroyContext", (_EGLProc
) eglDestroyContext
},
884 { "eglDestroySurface", (_EGLProc
) eglDestroySurface
},
885 { "eglGetConfigAttrib", (_EGLProc
) eglGetConfigAttrib
},
886 { "eglGetConfigs", (_EGLProc
) eglGetConfigs
},
887 { "eglGetCurrentContext", (_EGLProc
) eglGetCurrentContext
},
888 { "eglGetCurrentDisplay", (_EGLProc
) eglGetCurrentDisplay
},
889 { "eglGetCurrentSurface", (_EGLProc
) eglGetCurrentSurface
},
890 { "eglGetDisplay", (_EGLProc
) eglGetDisplay
},
891 { "eglGetError", (_EGLProc
) eglGetError
},
892 { "eglGetProcAddress", (_EGLProc
) eglGetProcAddress
},
893 { "eglInitialize", (_EGLProc
) eglInitialize
},
894 { "eglMakeCurrent", (_EGLProc
) eglMakeCurrent
},
895 { "eglQueryAPI", (_EGLProc
) eglQueryAPI
},
896 { "eglQueryContext", (_EGLProc
) eglQueryContext
},
897 { "eglQueryString", (_EGLProc
) eglQueryString
},
898 { "eglQuerySurface", (_EGLProc
) eglQuerySurface
},
899 { "eglReleaseTexImage", (_EGLProc
) eglReleaseTexImage
},
900 { "eglReleaseThread", (_EGLProc
) eglReleaseThread
},
901 { "eglSurfaceAttrib", (_EGLProc
) eglSurfaceAttrib
},
902 { "eglSwapBuffers", (_EGLProc
) eglSwapBuffers
},
903 { "eglSwapInterval", (_EGLProc
) eglSwapInterval
},
904 { "eglTerminate", (_EGLProc
) eglTerminate
},
905 { "eglWaitClient", (_EGLProc
) eglWaitClient
},
906 { "eglWaitGL", (_EGLProc
) eglWaitGL
},
907 { "eglWaitNative", (_EGLProc
) eglWaitNative
},
908 #endif /* _EGL_GET_CORE_ADDRESSES */
909 #ifdef EGL_MESA_screen_surface
910 { "eglChooseModeMESA", (_EGLProc
) eglChooseModeMESA
},
911 { "eglGetModesMESA", (_EGLProc
) eglGetModesMESA
},
912 { "eglGetModeAttribMESA", (_EGLProc
) eglGetModeAttribMESA
},
913 { "eglCopyContextMESA", (_EGLProc
) eglCopyContextMESA
},
914 { "eglGetScreensMESA", (_EGLProc
) eglGetScreensMESA
},
915 { "eglCreateScreenSurfaceMESA", (_EGLProc
) eglCreateScreenSurfaceMESA
},
916 { "eglShowScreenSurfaceMESA", (_EGLProc
) eglShowScreenSurfaceMESA
},
917 { "eglScreenPositionMESA", (_EGLProc
) eglScreenPositionMESA
},
918 { "eglQueryScreenMESA", (_EGLProc
) eglQueryScreenMESA
},
919 { "eglQueryScreenSurfaceMESA", (_EGLProc
) eglQueryScreenSurfaceMESA
},
920 { "eglQueryScreenModeMESA", (_EGLProc
) eglQueryScreenModeMESA
},
921 { "eglQueryModeStringMESA", (_EGLProc
) eglQueryModeStringMESA
},
922 #endif /* EGL_MESA_screen_surface */
923 #ifdef EGL_MESA_drm_display
924 { "eglGetDRMDisplayMESA", (_EGLProc
) eglGetDRMDisplayMESA
},
926 { "eglCreateImageKHR", (_EGLProc
) eglCreateImageKHR
},
927 { "eglDestroyImageKHR", (_EGLProc
) eglDestroyImageKHR
},
928 #ifdef EGL_NOK_swap_region
929 { "eglSwapBuffersRegionNOK", (_EGLProc
) eglSwapBuffersRegionNOK
},
931 #ifdef EGL_MESA_drm_image
932 { "eglCreateDRMImageMESA", (_EGLProc
) eglCreateDRMImageMESA
},
933 { "eglExportDRMImageMESA", (_EGLProc
) eglExportDRMImageMESA
},
935 #ifdef EGL_WL_bind_wayland_display
936 { "eglBindWaylandDisplayWL", (_EGLProc
) eglBindWaylandDisplayWL
},
937 { "eglUnbindWaylandDisplayWL", (_EGLProc
) eglUnbindWaylandDisplayWL
},
945 RETURN_EGL_SUCCESS(NULL
, NULL
);
948 if (strncmp(procname
, "egl", 3) == 0) {
949 for (i
= 0; egl_functions
[i
].name
; i
++) {
950 if (strcmp(egl_functions
[i
].name
, procname
) == 0) {
951 ret
= egl_functions
[i
].function
;
957 ret
= _eglGetDriverProc(procname
);
959 RETURN_EGL_SUCCESS(NULL
, ret
);
963 #ifdef EGL_MESA_screen_surface
967 * EGL_MESA_screen extension
970 EGLBoolean EGLAPIENTRY
971 eglChooseModeMESA(EGLDisplay dpy
, EGLScreenMESA screen
,
972 const EGLint
*attrib_list
, EGLModeMESA
*modes
,
973 EGLint modes_size
, EGLint
*num_modes
)
975 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
976 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
980 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
981 ret
= drv
->API
.ChooseModeMESA(drv
, disp
, scrn
, attrib_list
,
982 modes
, modes_size
, num_modes
);
984 RETURN_EGL_EVAL(disp
, ret
);
988 EGLBoolean EGLAPIENTRY
989 eglGetModesMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLModeMESA
*modes
,
990 EGLint mode_size
, EGLint
*num_mode
)
992 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
993 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
997 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
998 ret
= drv
->API
.GetModesMESA(drv
, disp
, scrn
, modes
, mode_size
, num_mode
);
1000 RETURN_EGL_EVAL(disp
, ret
);
1004 EGLBoolean EGLAPIENTRY
1005 eglGetModeAttribMESA(EGLDisplay dpy
, EGLModeMESA mode
,
1006 EGLint attribute
, EGLint
*value
)
1008 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1009 _EGLMode
*m
= _eglLookupMode(mode
, disp
);
1013 _EGL_CHECK_MODE(disp
, m
, EGL_FALSE
, drv
);
1014 ret
= drv
->API
.GetModeAttribMESA(drv
, disp
, m
, attribute
, value
);
1016 RETURN_EGL_EVAL(disp
, ret
);
1020 EGLBoolean EGLAPIENTRY
1021 eglCopyContextMESA(EGLDisplay dpy
, EGLContext source
, EGLContext dest
,
1024 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1025 _EGLContext
*source_context
= _eglLookupContext(source
, disp
);
1026 _EGLContext
*dest_context
= _eglLookupContext(dest
, disp
);
1030 _EGL_CHECK_CONTEXT(disp
, source_context
, EGL_FALSE
, drv
);
1032 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_FALSE
);
1034 ret
= drv
->API
.CopyContextMESA(drv
, disp
,
1035 source_context
, dest_context
, mask
);
1037 RETURN_EGL_EVAL(disp
, ret
);
1041 EGLBoolean EGLAPIENTRY
1042 eglGetScreensMESA(EGLDisplay dpy
, EGLScreenMESA
*screens
,
1043 EGLint max_screens
, EGLint
*num_screens
)
1045 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1049 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1050 ret
= drv
->API
.GetScreensMESA(drv
, disp
, screens
, max_screens
, num_screens
);
1052 RETURN_EGL_EVAL(disp
, ret
);
1056 EGLSurface EGLAPIENTRY
1057 eglCreateScreenSurfaceMESA(EGLDisplay dpy
, EGLConfig config
,
1058 const EGLint
*attrib_list
)
1060 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1061 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
1066 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
1068 surf
= drv
->API
.CreateScreenSurfaceMESA(drv
, disp
, conf
, attrib_list
);
1069 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
1071 RETURN_EGL_EVAL(disp
, ret
);
1075 EGLBoolean EGLAPIENTRY
1076 eglShowScreenSurfaceMESA(EGLDisplay dpy
, EGLint screen
,
1077 EGLSurface surface
, EGLModeMESA mode
)
1079 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1080 _EGLScreen
*scrn
= _eglLookupScreen((EGLScreenMESA
) screen
, disp
);
1081 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1082 _EGLMode
*m
= _eglLookupMode(mode
, disp
);
1086 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1087 if (!surf
&& surface
!= EGL_NO_SURFACE
)
1088 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1089 if (!m
&& mode
!= EGL_NO_MODE_MESA
)
1090 RETURN_EGL_ERROR(disp
, EGL_BAD_MODE_MESA
, EGL_FALSE
);
1092 ret
= drv
->API
.ShowScreenSurfaceMESA(drv
, disp
, scrn
, surf
, m
);
1094 RETURN_EGL_EVAL(disp
, ret
);
1098 EGLBoolean EGLAPIENTRY
1099 eglScreenPositionMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLint x
, EGLint y
)
1101 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1102 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
1106 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1107 ret
= drv
->API
.ScreenPositionMESA(drv
, disp
, scrn
, x
, y
);
1109 RETURN_EGL_EVAL(disp
, ret
);
1113 EGLBoolean EGLAPIENTRY
1114 eglQueryScreenMESA(EGLDisplay dpy
, EGLScreenMESA screen
,
1115 EGLint attribute
, EGLint
*value
)
1117 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1118 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
1122 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1123 ret
= drv
->API
.QueryScreenMESA(drv
, disp
, scrn
, attribute
, value
);
1125 RETURN_EGL_EVAL(disp
, ret
);
1129 EGLBoolean EGLAPIENTRY
1130 eglQueryScreenSurfaceMESA(EGLDisplay dpy
, EGLScreenMESA screen
,
1131 EGLSurface
*surface
)
1133 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1134 _EGLScreen
*scrn
= _eglLookupScreen((EGLScreenMESA
) screen
, disp
);
1139 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1140 ret
= drv
->API
.QueryScreenSurfaceMESA(drv
, disp
, scrn
, &surf
);
1142 *surface
= _eglGetSurfaceHandle(surf
);
1144 RETURN_EGL_EVAL(disp
, ret
);
1148 EGLBoolean EGLAPIENTRY
1149 eglQueryScreenModeMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLModeMESA
*mode
)
1151 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1152 _EGLScreen
*scrn
= _eglLookupScreen((EGLScreenMESA
) screen
, disp
);
1157 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1158 ret
= drv
->API
.QueryScreenModeMESA(drv
, disp
, scrn
, &m
);
1162 RETURN_EGL_EVAL(disp
, ret
);
1166 const char * EGLAPIENTRY
1167 eglQueryModeStringMESA(EGLDisplay dpy
, EGLModeMESA mode
)
1169 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1170 _EGLMode
*m
= _eglLookupMode(mode
, disp
);
1174 _EGL_CHECK_MODE(disp
, m
, NULL
, drv
);
1175 ret
= drv
->API
.QueryModeStringMESA(drv
, disp
, m
);
1177 RETURN_EGL_EVAL(disp
, ret
);
1181 #endif /* EGL_MESA_screen_surface */
1184 #ifdef EGL_MESA_drm_display
1186 EGLDisplay EGLAPIENTRY
1187 eglGetDRMDisplayMESA(int fd
)
1189 _EGLDisplay
*dpy
= _eglFindDisplay(_EGL_PLATFORM_DRM
, (void *) (intptr_t) fd
);
1190 return _eglGetDisplayHandle(dpy
);
1193 #endif /* EGL_MESA_drm_display */
1200 * Specify the client API to use for subsequent calls including:
1201 * eglCreateContext()
1202 * eglGetCurrentContext()
1203 * eglGetCurrentDisplay()
1204 * eglGetCurrentSurface()
1205 * eglMakeCurrent(when the ctx parameter is EGL NO CONTEXT)
1208 * See section 3.7 "Rendering Context" in the EGL specification for details.
1210 EGLBoolean EGLAPIENTRY
1211 eglBindAPI(EGLenum api
)
1213 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1215 if (_eglIsCurrentThreadDummy())
1216 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_FALSE
);
1218 if (!_eglIsApiValid(api
))
1219 RETURN_EGL_ERROR(NULL
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1221 t
->CurrentAPIIndex
= _eglConvertApiToIndex(api
);
1223 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1228 * Return the last value set with eglBindAPI().
1233 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1236 /* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
1237 ret
= _eglConvertApiFromIndex(t
->CurrentAPIIndex
);
1239 RETURN_EGL_SUCCESS(NULL
, ret
);
1243 EGLSurface EGLAPIENTRY
1244 eglCreatePbufferFromClientBuffer(EGLDisplay dpy
, EGLenum buftype
,
1245 EGLClientBuffer buffer
, EGLConfig config
,
1246 const EGLint
*attrib_list
)
1248 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1249 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
1254 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
1256 surf
= drv
->API
.CreatePbufferFromClientBuffer(drv
, disp
, buftype
, buffer
,
1258 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
1260 RETURN_EGL_EVAL(disp
, ret
);
1264 EGLBoolean EGLAPIENTRY
1265 eglReleaseThread(void)
1267 /* unbind current contexts */
1268 if (!_eglIsCurrentThreadDummy()) {
1269 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1270 EGLint api_index
= t
->CurrentAPIIndex
;
1273 for (i
= 0; i
< _EGL_API_NUM_APIS
; i
++) {
1274 _EGLContext
*ctx
= t
->CurrentContexts
[i
];
1276 _EGLDisplay
*disp
= ctx
->Resource
.Display
;
1279 t
->CurrentAPIIndex
= i
;
1281 _eglLockMutex(&disp
->Mutex
);
1283 (void) drv
->API
.MakeCurrent(drv
, disp
, NULL
, NULL
, NULL
);
1284 _eglUnlockMutex(&disp
->Mutex
);
1288 t
->CurrentAPIIndex
= api_index
;
1291 _eglDestroyCurrentThread();
1293 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1297 EGLImageKHR EGLAPIENTRY
1298 eglCreateImageKHR(EGLDisplay dpy
, EGLContext ctx
, EGLenum target
,
1299 EGLClientBuffer buffer
, const EGLint
*attr_list
)
1301 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1302 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
1307 _EGL_CHECK_DISPLAY(disp
, EGL_NO_IMAGE_KHR
, drv
);
1308 if (!disp
->Extensions
.KHR_image_base
)
1309 RETURN_EGL_EVAL(disp
, EGL_NO_IMAGE_KHR
);
1310 if (!context
&& ctx
!= EGL_NO_CONTEXT
)
1311 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_NO_IMAGE_KHR
);
1313 img
= drv
->API
.CreateImageKHR(drv
,
1314 disp
, context
, target
, buffer
, attr_list
);
1315 ret
= (img
) ? _eglLinkImage(img
) : EGL_NO_IMAGE_KHR
;
1317 RETURN_EGL_EVAL(disp
, ret
);
1321 EGLBoolean EGLAPIENTRY
1322 eglDestroyImageKHR(EGLDisplay dpy
, EGLImageKHR image
)
1324 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1325 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1329 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1330 if (!disp
->Extensions
.KHR_image_base
)
1331 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1333 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1335 _eglUnlinkImage(img
);
1336 ret
= drv
->API
.DestroyImageKHR(drv
, disp
, img
);
1338 RETURN_EGL_EVAL(disp
, ret
);
1342 EGLSyncKHR EGLAPIENTRY
1343 eglCreateSyncKHR(EGLDisplay dpy
, EGLenum type
, const EGLint
*attrib_list
)
1345 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1350 _EGL_CHECK_DISPLAY(disp
, EGL_NO_SYNC_KHR
, drv
);
1351 if (!disp
->Extensions
.KHR_reusable_sync
)
1352 RETURN_EGL_EVAL(disp
, EGL_NO_SYNC_KHR
);
1354 sync
= drv
->API
.CreateSyncKHR(drv
, disp
, type
, attrib_list
);
1355 ret
= (sync
) ? _eglLinkSync(sync
) : EGL_NO_SYNC_KHR
;
1357 RETURN_EGL_EVAL(disp
, ret
);
1361 EGLBoolean EGLAPIENTRY
1362 eglDestroySyncKHR(EGLDisplay dpy
, EGLSyncKHR sync
)
1364 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1365 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1369 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1370 assert(disp
->Extensions
.KHR_reusable_sync
);
1373 ret
= drv
->API
.DestroySyncKHR(drv
, disp
, s
);
1375 RETURN_EGL_EVAL(disp
, ret
);
1380 eglClientWaitSyncKHR(EGLDisplay dpy
, EGLSyncKHR sync
, EGLint flags
, EGLTimeKHR timeout
)
1382 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1383 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1387 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1388 assert(disp
->Extensions
.KHR_reusable_sync
);
1389 ret
= drv
->API
.ClientWaitSyncKHR(drv
, disp
, s
, flags
, timeout
);
1391 RETURN_EGL_EVAL(disp
, ret
);
1395 EGLBoolean EGLAPIENTRY
1396 eglSignalSyncKHR(EGLDisplay dpy
, EGLSyncKHR sync
, EGLenum mode
)
1398 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1399 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1403 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1404 assert(disp
->Extensions
.KHR_reusable_sync
);
1405 ret
= drv
->API
.SignalSyncKHR(drv
, disp
, s
, mode
);
1407 RETURN_EGL_EVAL(disp
, ret
);
1411 EGLBoolean EGLAPIENTRY
1412 eglGetSyncAttribKHR(EGLDisplay dpy
, EGLSyncKHR sync
, EGLint attribute
, EGLint
*value
)
1414 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1415 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1419 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1420 assert(disp
->Extensions
.KHR_reusable_sync
);
1421 ret
= drv
->API
.GetSyncAttribKHR(drv
, disp
, s
, attribute
, value
);
1423 RETURN_EGL_EVAL(disp
, ret
);
1427 #ifdef EGL_NOK_swap_region
1429 EGLBoolean EGLAPIENTRY
1430 eglSwapBuffersRegionNOK(EGLDisplay dpy
, EGLSurface surface
,
1431 EGLint numRects
, const EGLint
*rects
)
1433 _EGLContext
*ctx
= _eglGetCurrentContext();
1434 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1435 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1439 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1441 if (!disp
->Extensions
.NOK_swap_region
)
1442 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1444 /* surface must be bound to current context in EGL 1.4 */
1445 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1446 surf
!= ctx
->DrawSurface
)
1447 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1449 ret
= drv
->API
.SwapBuffersRegionNOK(drv
, disp
, surf
, numRects
, rects
);
1451 RETURN_EGL_EVAL(disp
, ret
);
1454 #endif /* EGL_NOK_swap_region */
1457 #ifdef EGL_MESA_drm_image
1459 EGLImageKHR EGLAPIENTRY
1460 eglCreateDRMImageMESA(EGLDisplay dpy
, const EGLint
*attr_list
)
1462 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1467 _EGL_CHECK_DISPLAY(disp
, EGL_NO_IMAGE_KHR
, drv
);
1468 if (!disp
->Extensions
.MESA_drm_image
)
1469 RETURN_EGL_EVAL(disp
, EGL_NO_IMAGE_KHR
);
1471 img
= drv
->API
.CreateDRMImageMESA(drv
, disp
, attr_list
);
1472 ret
= (img
) ? _eglLinkImage(img
) : EGL_NO_IMAGE_KHR
;
1474 RETURN_EGL_EVAL(disp
, ret
);
1477 EGLBoolean EGLAPIENTRY
1478 eglExportDRMImageMESA(EGLDisplay dpy
, EGLImageKHR image
,
1479 EGLint
*name
, EGLint
*handle
, EGLint
*stride
)
1481 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1482 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1486 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1487 assert(disp
->Extensions
.MESA_drm_image
);
1490 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1492 ret
= drv
->API
.ExportDRMImageMESA(drv
, disp
, img
, name
, handle
, stride
);
1494 RETURN_EGL_EVAL(disp
, ret
);
1499 #ifdef EGL_WL_bind_wayland_display
1502 EGLBoolean EGLAPIENTRY
1503 eglBindWaylandDisplayWL(EGLDisplay dpy
, struct wl_display
*display
)
1505 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1509 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1510 assert(disp
->Extensions
.WL_bind_wayland_display
);
1513 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1515 ret
= drv
->API
.BindWaylandDisplayWL(drv
, disp
, display
);
1517 RETURN_EGL_EVAL(disp
, ret
);
1520 EGLBoolean EGLAPIENTRY
1521 eglUnbindWaylandDisplayWL(EGLDisplay dpy
, struct wl_display
*display
)
1523 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1527 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1528 assert(disp
->Extensions
.WL_bind_wayland_display
);
1531 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1533 ret
= drv
->API
.UnbindWaylandDisplayWL(drv
, disp
, display
);
1535 RETURN_EGL_EVAL(disp
, ret
);