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 { "eglCreateSyncKHR", (_EGLProc
) eglCreateSyncKHR
},
929 { "eglDestroySyncKHR", (_EGLProc
) eglDestroySyncKHR
},
930 { "eglClientWaitSyncKHR", (_EGLProc
) eglClientWaitSyncKHR
},
931 { "eglSignalSyncKHR", (_EGLProc
) eglSignalSyncKHR
},
932 { "eglGetSyncAttribKHR", (_EGLProc
) eglGetSyncAttribKHR
},
933 #ifdef EGL_NOK_swap_region
934 { "eglSwapBuffersRegionNOK", (_EGLProc
) eglSwapBuffersRegionNOK
},
936 #ifdef EGL_MESA_drm_image
937 { "eglCreateDRMImageMESA", (_EGLProc
) eglCreateDRMImageMESA
},
938 { "eglExportDRMImageMESA", (_EGLProc
) eglExportDRMImageMESA
},
940 #ifdef EGL_WL_bind_wayland_display
941 { "eglBindWaylandDisplayWL", (_EGLProc
) eglBindWaylandDisplayWL
},
942 { "eglUnbindWaylandDisplayWL", (_EGLProc
) eglUnbindWaylandDisplayWL
},
950 RETURN_EGL_SUCCESS(NULL
, NULL
);
953 if (strncmp(procname
, "egl", 3) == 0) {
954 for (i
= 0; egl_functions
[i
].name
; i
++) {
955 if (strcmp(egl_functions
[i
].name
, procname
) == 0) {
956 ret
= egl_functions
[i
].function
;
962 ret
= _eglGetDriverProc(procname
);
964 RETURN_EGL_SUCCESS(NULL
, ret
);
968 #ifdef EGL_MESA_screen_surface
972 * EGL_MESA_screen extension
975 EGLBoolean EGLAPIENTRY
976 eglChooseModeMESA(EGLDisplay dpy
, EGLScreenMESA screen
,
977 const EGLint
*attrib_list
, EGLModeMESA
*modes
,
978 EGLint modes_size
, EGLint
*num_modes
)
980 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
981 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
985 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
986 ret
= drv
->API
.ChooseModeMESA(drv
, disp
, scrn
, attrib_list
,
987 modes
, modes_size
, num_modes
);
989 RETURN_EGL_EVAL(disp
, ret
);
993 EGLBoolean EGLAPIENTRY
994 eglGetModesMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLModeMESA
*modes
,
995 EGLint mode_size
, EGLint
*num_mode
)
997 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
998 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
1002 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1003 ret
= drv
->API
.GetModesMESA(drv
, disp
, scrn
, modes
, mode_size
, num_mode
);
1005 RETURN_EGL_EVAL(disp
, ret
);
1009 EGLBoolean EGLAPIENTRY
1010 eglGetModeAttribMESA(EGLDisplay dpy
, EGLModeMESA mode
,
1011 EGLint attribute
, EGLint
*value
)
1013 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1014 _EGLMode
*m
= _eglLookupMode(mode
, disp
);
1018 _EGL_CHECK_MODE(disp
, m
, EGL_FALSE
, drv
);
1019 ret
= drv
->API
.GetModeAttribMESA(drv
, disp
, m
, attribute
, value
);
1021 RETURN_EGL_EVAL(disp
, ret
);
1025 EGLBoolean EGLAPIENTRY
1026 eglCopyContextMESA(EGLDisplay dpy
, EGLContext source
, EGLContext dest
,
1029 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1030 _EGLContext
*source_context
= _eglLookupContext(source
, disp
);
1031 _EGLContext
*dest_context
= _eglLookupContext(dest
, disp
);
1035 _EGL_CHECK_CONTEXT(disp
, source_context
, EGL_FALSE
, drv
);
1037 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_FALSE
);
1039 ret
= drv
->API
.CopyContextMESA(drv
, disp
,
1040 source_context
, dest_context
, mask
);
1042 RETURN_EGL_EVAL(disp
, ret
);
1046 EGLBoolean EGLAPIENTRY
1047 eglGetScreensMESA(EGLDisplay dpy
, EGLScreenMESA
*screens
,
1048 EGLint max_screens
, EGLint
*num_screens
)
1050 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1054 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1055 ret
= drv
->API
.GetScreensMESA(drv
, disp
, screens
, max_screens
, num_screens
);
1057 RETURN_EGL_EVAL(disp
, ret
);
1061 EGLSurface EGLAPIENTRY
1062 eglCreateScreenSurfaceMESA(EGLDisplay dpy
, EGLConfig config
,
1063 const EGLint
*attrib_list
)
1065 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1066 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
1071 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
1073 surf
= drv
->API
.CreateScreenSurfaceMESA(drv
, disp
, conf
, attrib_list
);
1074 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
1076 RETURN_EGL_EVAL(disp
, ret
);
1080 EGLBoolean EGLAPIENTRY
1081 eglShowScreenSurfaceMESA(EGLDisplay dpy
, EGLint screen
,
1082 EGLSurface surface
, EGLModeMESA mode
)
1084 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1085 _EGLScreen
*scrn
= _eglLookupScreen((EGLScreenMESA
) screen
, disp
);
1086 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1087 _EGLMode
*m
= _eglLookupMode(mode
, disp
);
1091 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1092 if (!surf
&& surface
!= EGL_NO_SURFACE
)
1093 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1094 if (!m
&& mode
!= EGL_NO_MODE_MESA
)
1095 RETURN_EGL_ERROR(disp
, EGL_BAD_MODE_MESA
, EGL_FALSE
);
1097 ret
= drv
->API
.ShowScreenSurfaceMESA(drv
, disp
, scrn
, surf
, m
);
1099 RETURN_EGL_EVAL(disp
, ret
);
1103 EGLBoolean EGLAPIENTRY
1104 eglScreenPositionMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLint x
, EGLint y
)
1106 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1107 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
1111 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1112 ret
= drv
->API
.ScreenPositionMESA(drv
, disp
, scrn
, x
, y
);
1114 RETURN_EGL_EVAL(disp
, ret
);
1118 EGLBoolean EGLAPIENTRY
1119 eglQueryScreenMESA(EGLDisplay dpy
, EGLScreenMESA screen
,
1120 EGLint attribute
, EGLint
*value
)
1122 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1123 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
1127 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1128 ret
= drv
->API
.QueryScreenMESA(drv
, disp
, scrn
, attribute
, value
);
1130 RETURN_EGL_EVAL(disp
, ret
);
1134 EGLBoolean EGLAPIENTRY
1135 eglQueryScreenSurfaceMESA(EGLDisplay dpy
, EGLScreenMESA screen
,
1136 EGLSurface
*surface
)
1138 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1139 _EGLScreen
*scrn
= _eglLookupScreen((EGLScreenMESA
) screen
, disp
);
1144 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1145 ret
= drv
->API
.QueryScreenSurfaceMESA(drv
, disp
, scrn
, &surf
);
1147 *surface
= _eglGetSurfaceHandle(surf
);
1149 RETURN_EGL_EVAL(disp
, ret
);
1153 EGLBoolean EGLAPIENTRY
1154 eglQueryScreenModeMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLModeMESA
*mode
)
1156 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1157 _EGLScreen
*scrn
= _eglLookupScreen((EGLScreenMESA
) screen
, disp
);
1162 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1163 ret
= drv
->API
.QueryScreenModeMESA(drv
, disp
, scrn
, &m
);
1167 RETURN_EGL_EVAL(disp
, ret
);
1171 const char * EGLAPIENTRY
1172 eglQueryModeStringMESA(EGLDisplay dpy
, EGLModeMESA mode
)
1174 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1175 _EGLMode
*m
= _eglLookupMode(mode
, disp
);
1179 _EGL_CHECK_MODE(disp
, m
, NULL
, drv
);
1180 ret
= drv
->API
.QueryModeStringMESA(drv
, disp
, m
);
1182 RETURN_EGL_EVAL(disp
, ret
);
1186 #endif /* EGL_MESA_screen_surface */
1189 #ifdef EGL_MESA_drm_display
1191 EGLDisplay EGLAPIENTRY
1192 eglGetDRMDisplayMESA(int fd
)
1194 _EGLDisplay
*dpy
= _eglFindDisplay(_EGL_PLATFORM_DRM
, (void *) (intptr_t) fd
);
1195 return _eglGetDisplayHandle(dpy
);
1198 #endif /* EGL_MESA_drm_display */
1205 * Specify the client API to use for subsequent calls including:
1206 * eglCreateContext()
1207 * eglGetCurrentContext()
1208 * eglGetCurrentDisplay()
1209 * eglGetCurrentSurface()
1210 * eglMakeCurrent(when the ctx parameter is EGL NO CONTEXT)
1213 * See section 3.7 "Rendering Context" in the EGL specification for details.
1215 EGLBoolean EGLAPIENTRY
1216 eglBindAPI(EGLenum api
)
1218 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1220 if (_eglIsCurrentThreadDummy())
1221 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_FALSE
);
1223 if (!_eglIsApiValid(api
))
1224 RETURN_EGL_ERROR(NULL
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1226 t
->CurrentAPIIndex
= _eglConvertApiToIndex(api
);
1228 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1233 * Return the last value set with eglBindAPI().
1238 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1241 /* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
1242 ret
= _eglConvertApiFromIndex(t
->CurrentAPIIndex
);
1244 RETURN_EGL_SUCCESS(NULL
, ret
);
1248 EGLSurface EGLAPIENTRY
1249 eglCreatePbufferFromClientBuffer(EGLDisplay dpy
, EGLenum buftype
,
1250 EGLClientBuffer buffer
, EGLConfig config
,
1251 const EGLint
*attrib_list
)
1253 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1254 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
1259 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
1261 surf
= drv
->API
.CreatePbufferFromClientBuffer(drv
, disp
, buftype
, buffer
,
1263 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
1265 RETURN_EGL_EVAL(disp
, ret
);
1269 EGLBoolean EGLAPIENTRY
1270 eglReleaseThread(void)
1272 /* unbind current contexts */
1273 if (!_eglIsCurrentThreadDummy()) {
1274 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1275 EGLint api_index
= t
->CurrentAPIIndex
;
1278 for (i
= 0; i
< _EGL_API_NUM_APIS
; i
++) {
1279 _EGLContext
*ctx
= t
->CurrentContexts
[i
];
1281 _EGLDisplay
*disp
= ctx
->Resource
.Display
;
1284 t
->CurrentAPIIndex
= i
;
1286 _eglLockMutex(&disp
->Mutex
);
1288 (void) drv
->API
.MakeCurrent(drv
, disp
, NULL
, NULL
, NULL
);
1289 _eglUnlockMutex(&disp
->Mutex
);
1293 t
->CurrentAPIIndex
= api_index
;
1296 _eglDestroyCurrentThread();
1298 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1302 EGLImageKHR EGLAPIENTRY
1303 eglCreateImageKHR(EGLDisplay dpy
, EGLContext ctx
, EGLenum target
,
1304 EGLClientBuffer buffer
, const EGLint
*attr_list
)
1306 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1307 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
1312 _EGL_CHECK_DISPLAY(disp
, EGL_NO_IMAGE_KHR
, drv
);
1313 if (!disp
->Extensions
.KHR_image_base
)
1314 RETURN_EGL_EVAL(disp
, EGL_NO_IMAGE_KHR
);
1315 if (!context
&& ctx
!= EGL_NO_CONTEXT
)
1316 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_NO_IMAGE_KHR
);
1318 img
= drv
->API
.CreateImageKHR(drv
,
1319 disp
, context
, target
, buffer
, attr_list
);
1320 ret
= (img
) ? _eglLinkImage(img
) : EGL_NO_IMAGE_KHR
;
1322 RETURN_EGL_EVAL(disp
, ret
);
1326 EGLBoolean EGLAPIENTRY
1327 eglDestroyImageKHR(EGLDisplay dpy
, EGLImageKHR image
)
1329 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1330 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1334 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1335 if (!disp
->Extensions
.KHR_image_base
)
1336 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1338 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1340 _eglUnlinkImage(img
);
1341 ret
= drv
->API
.DestroyImageKHR(drv
, disp
, img
);
1343 RETURN_EGL_EVAL(disp
, ret
);
1347 EGLSyncKHR EGLAPIENTRY
1348 eglCreateSyncKHR(EGLDisplay dpy
, EGLenum type
, const EGLint
*attrib_list
)
1350 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1355 _EGL_CHECK_DISPLAY(disp
, EGL_NO_SYNC_KHR
, drv
);
1356 if (!disp
->Extensions
.KHR_reusable_sync
)
1357 RETURN_EGL_EVAL(disp
, EGL_NO_SYNC_KHR
);
1359 sync
= drv
->API
.CreateSyncKHR(drv
, disp
, type
, attrib_list
);
1360 ret
= (sync
) ? _eglLinkSync(sync
) : EGL_NO_SYNC_KHR
;
1362 RETURN_EGL_EVAL(disp
, ret
);
1366 EGLBoolean EGLAPIENTRY
1367 eglDestroySyncKHR(EGLDisplay dpy
, EGLSyncKHR sync
)
1369 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1370 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1374 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1375 assert(disp
->Extensions
.KHR_reusable_sync
);
1378 ret
= drv
->API
.DestroySyncKHR(drv
, disp
, s
);
1380 RETURN_EGL_EVAL(disp
, ret
);
1385 eglClientWaitSyncKHR(EGLDisplay dpy
, EGLSyncKHR sync
, EGLint flags
, EGLTimeKHR timeout
)
1387 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1388 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1392 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1393 assert(disp
->Extensions
.KHR_reusable_sync
);
1394 ret
= drv
->API
.ClientWaitSyncKHR(drv
, disp
, s
, flags
, timeout
);
1396 RETURN_EGL_EVAL(disp
, ret
);
1400 EGLBoolean EGLAPIENTRY
1401 eglSignalSyncKHR(EGLDisplay dpy
, EGLSyncKHR sync
, EGLenum mode
)
1403 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1404 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1408 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1409 assert(disp
->Extensions
.KHR_reusable_sync
);
1410 ret
= drv
->API
.SignalSyncKHR(drv
, disp
, s
, mode
);
1412 RETURN_EGL_EVAL(disp
, ret
);
1416 EGLBoolean EGLAPIENTRY
1417 eglGetSyncAttribKHR(EGLDisplay dpy
, EGLSyncKHR sync
, EGLint attribute
, EGLint
*value
)
1419 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1420 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1424 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1425 assert(disp
->Extensions
.KHR_reusable_sync
);
1426 ret
= drv
->API
.GetSyncAttribKHR(drv
, disp
, s
, attribute
, value
);
1428 RETURN_EGL_EVAL(disp
, ret
);
1432 #ifdef EGL_NOK_swap_region
1434 EGLBoolean EGLAPIENTRY
1435 eglSwapBuffersRegionNOK(EGLDisplay dpy
, EGLSurface surface
,
1436 EGLint numRects
, const EGLint
*rects
)
1438 _EGLContext
*ctx
= _eglGetCurrentContext();
1439 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1440 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1444 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1446 if (!disp
->Extensions
.NOK_swap_region
)
1447 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1449 /* surface must be bound to current context in EGL 1.4 */
1450 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1451 surf
!= ctx
->DrawSurface
)
1452 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1454 ret
= drv
->API
.SwapBuffersRegionNOK(drv
, disp
, surf
, numRects
, rects
);
1456 RETURN_EGL_EVAL(disp
, ret
);
1459 #endif /* EGL_NOK_swap_region */
1462 #ifdef EGL_MESA_drm_image
1464 EGLImageKHR EGLAPIENTRY
1465 eglCreateDRMImageMESA(EGLDisplay dpy
, const EGLint
*attr_list
)
1467 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1472 _EGL_CHECK_DISPLAY(disp
, EGL_NO_IMAGE_KHR
, drv
);
1473 if (!disp
->Extensions
.MESA_drm_image
)
1474 RETURN_EGL_EVAL(disp
, EGL_NO_IMAGE_KHR
);
1476 img
= drv
->API
.CreateDRMImageMESA(drv
, disp
, attr_list
);
1477 ret
= (img
) ? _eglLinkImage(img
) : EGL_NO_IMAGE_KHR
;
1479 RETURN_EGL_EVAL(disp
, ret
);
1482 EGLBoolean EGLAPIENTRY
1483 eglExportDRMImageMESA(EGLDisplay dpy
, EGLImageKHR image
,
1484 EGLint
*name
, EGLint
*handle
, EGLint
*stride
)
1486 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1487 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1491 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1492 assert(disp
->Extensions
.MESA_drm_image
);
1495 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1497 ret
= drv
->API
.ExportDRMImageMESA(drv
, disp
, img
, name
, handle
, stride
);
1499 RETURN_EGL_EVAL(disp
, ret
);
1504 #ifdef EGL_WL_bind_wayland_display
1507 EGLBoolean EGLAPIENTRY
1508 eglBindWaylandDisplayWL(EGLDisplay dpy
, struct wl_display
*display
)
1510 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1514 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1515 assert(disp
->Extensions
.WL_bind_wayland_display
);
1518 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1520 ret
= drv
->API
.BindWaylandDisplayWL(drv
, disp
, display
);
1522 RETURN_EGL_EVAL(disp
, ret
);
1525 EGLBoolean EGLAPIENTRY
1526 eglUnbindWaylandDisplayWL(EGLDisplay dpy
, struct wl_display
*display
)
1528 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1532 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1533 assert(disp
->Extensions
.WL_bind_wayland_display
);
1536 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1538 ret
= drv
->API
.UnbindWaylandDisplayWL(drv
, disp
, display
);
1540 RETURN_EGL_EVAL(disp
, ret
);