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_context
)
431 RETURN_EGL_ERROR(disp
, EGL_BAD_CONFIG
, EGL_NO_CONTEXT
);
434 if (!share
&& share_list
!= EGL_NO_CONTEXT
)
435 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_NO_CONTEXT
);
437 context
= drv
->API
.CreateContext(drv
, disp
, conf
, share
, attrib_list
);
438 ret
= (context
) ? _eglLinkContext(context
) : EGL_NO_CONTEXT
;
440 RETURN_EGL_EVAL(disp
, ret
);
444 EGLBoolean EGLAPIENTRY
445 eglDestroyContext(EGLDisplay dpy
, EGLContext ctx
)
447 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
448 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
452 _EGL_CHECK_CONTEXT(disp
, context
, EGL_FALSE
, drv
);
453 _eglUnlinkContext(context
);
454 ret
= drv
->API
.DestroyContext(drv
, disp
, context
);
456 RETURN_EGL_EVAL(disp
, ret
);
460 EGLBoolean EGLAPIENTRY
461 eglMakeCurrent(EGLDisplay dpy
, EGLSurface draw
, EGLSurface read
,
464 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
465 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
466 _EGLSurface
*draw_surf
= _eglLookupSurface(draw
, disp
);
467 _EGLSurface
*read_surf
= _eglLookupSurface(read
, disp
);
472 RETURN_EGL_ERROR(disp
, EGL_BAD_DISPLAY
, EGL_FALSE
);
475 /* display is allowed to be uninitialized under certain condition */
476 if (!disp
->Initialized
) {
477 if (draw
!= EGL_NO_SURFACE
|| read
!= EGL_NO_SURFACE
||
478 ctx
!= EGL_NO_CONTEXT
)
479 RETURN_EGL_ERROR(disp
, EGL_BAD_DISPLAY
, EGL_FALSE
);
482 RETURN_EGL_SUCCESS(disp
, EGL_TRUE
);
484 if (!context
&& ctx
!= EGL_NO_CONTEXT
)
485 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_FALSE
);
486 if (!draw_surf
|| !read_surf
) {
487 /* surfaces may be NULL if surfaceless */
488 if (!disp
->Extensions
.KHR_surfaceless_context
)
489 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
491 if ((!draw_surf
&& draw
!= EGL_NO_SURFACE
) ||
492 (!read_surf
&& read
!= EGL_NO_SURFACE
))
493 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
494 if (draw_surf
|| read_surf
)
495 RETURN_EGL_ERROR(disp
, EGL_BAD_MATCH
, EGL_FALSE
);
498 ret
= drv
->API
.MakeCurrent(drv
, disp
, draw_surf
, read_surf
, context
);
500 RETURN_EGL_EVAL(disp
, ret
);
504 EGLBoolean EGLAPIENTRY
505 eglQueryContext(EGLDisplay dpy
, EGLContext ctx
,
506 EGLint attribute
, EGLint
*value
)
508 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
509 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
513 _EGL_CHECK_CONTEXT(disp
, context
, EGL_FALSE
, drv
);
514 ret
= drv
->API
.QueryContext(drv
, disp
, context
, attribute
, value
);
516 RETURN_EGL_EVAL(disp
, ret
);
520 EGLSurface EGLAPIENTRY
521 eglCreateWindowSurface(EGLDisplay dpy
, EGLConfig config
,
522 EGLNativeWindowType window
, const EGLint
*attrib_list
)
524 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
525 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
530 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
531 if (disp
->Platform
!= _eglGetNativePlatform(disp
->PlatformDisplay
))
532 RETURN_EGL_ERROR(disp
, EGL_BAD_NATIVE_WINDOW
, EGL_NO_SURFACE
);
534 surf
= drv
->API
.CreateWindowSurface(drv
, disp
, conf
, window
, attrib_list
);
535 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
537 RETURN_EGL_EVAL(disp
, ret
);
541 EGLSurface EGLAPIENTRY
542 eglCreatePixmapSurface(EGLDisplay dpy
, EGLConfig config
,
543 EGLNativePixmapType pixmap
, const EGLint
*attrib_list
)
545 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
546 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
551 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
552 if (disp
->Platform
!= _eglGetNativePlatform(disp
->PlatformDisplay
))
553 RETURN_EGL_ERROR(disp
, EGL_BAD_NATIVE_PIXMAP
, EGL_NO_SURFACE
);
555 surf
= drv
->API
.CreatePixmapSurface(drv
, disp
, conf
, pixmap
, attrib_list
);
556 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
558 RETURN_EGL_EVAL(disp
, ret
);
562 EGLSurface EGLAPIENTRY
563 eglCreatePbufferSurface(EGLDisplay dpy
, EGLConfig config
,
564 const EGLint
*attrib_list
)
566 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
567 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
572 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
574 surf
= drv
->API
.CreatePbufferSurface(drv
, disp
, conf
, attrib_list
);
575 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
577 RETURN_EGL_EVAL(disp
, ret
);
581 EGLBoolean EGLAPIENTRY
582 eglDestroySurface(EGLDisplay dpy
, EGLSurface surface
)
584 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
585 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
589 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
590 _eglUnlinkSurface(surf
);
591 ret
= drv
->API
.DestroySurface(drv
, disp
, surf
);
593 RETURN_EGL_EVAL(disp
, ret
);
596 EGLBoolean EGLAPIENTRY
597 eglQuerySurface(EGLDisplay dpy
, EGLSurface surface
,
598 EGLint attribute
, EGLint
*value
)
600 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
601 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
605 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
606 ret
= drv
->API
.QuerySurface(drv
, disp
, surf
, attribute
, value
);
608 RETURN_EGL_EVAL(disp
, ret
);
611 EGLBoolean EGLAPIENTRY
612 eglSurfaceAttrib(EGLDisplay dpy
, EGLSurface surface
,
613 EGLint attribute
, EGLint value
)
615 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
616 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
620 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
621 ret
= drv
->API
.SurfaceAttrib(drv
, disp
, surf
, attribute
, value
);
623 RETURN_EGL_EVAL(disp
, ret
);
627 EGLBoolean EGLAPIENTRY
628 eglBindTexImage(EGLDisplay dpy
, EGLSurface surface
, EGLint buffer
)
630 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
631 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
635 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
636 ret
= drv
->API
.BindTexImage(drv
, disp
, surf
, buffer
);
638 RETURN_EGL_EVAL(disp
, ret
);
642 EGLBoolean EGLAPIENTRY
643 eglReleaseTexImage(EGLDisplay dpy
, EGLSurface surface
, EGLint buffer
)
645 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
646 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
650 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
651 ret
= drv
->API
.ReleaseTexImage(drv
, disp
, surf
, buffer
);
653 RETURN_EGL_EVAL(disp
, ret
);
657 EGLBoolean EGLAPIENTRY
658 eglSwapInterval(EGLDisplay dpy
, EGLint interval
)
660 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
661 _EGLContext
*ctx
= _eglGetCurrentContext();
666 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
668 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
669 ctx
->Resource
.Display
!= disp
)
670 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_FALSE
);
672 surf
= ctx
->DrawSurface
;
673 if (_eglGetSurfaceHandle(surf
) == EGL_NO_SURFACE
)
674 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
676 ret
= drv
->API
.SwapInterval(drv
, disp
, surf
, interval
);
678 RETURN_EGL_EVAL(disp
, ret
);
682 EGLBoolean EGLAPIENTRY
683 eglSwapBuffers(EGLDisplay dpy
, EGLSurface surface
)
685 _EGLContext
*ctx
= _eglGetCurrentContext();
686 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
687 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
691 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
693 /* surface must be bound to current context in EGL 1.4 */
694 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
695 surf
!= ctx
->DrawSurface
)
696 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
698 ret
= drv
->API
.SwapBuffers(drv
, disp
, surf
);
700 RETURN_EGL_EVAL(disp
, ret
);
704 EGLBoolean EGLAPIENTRY
705 eglCopyBuffers(EGLDisplay dpy
, EGLSurface surface
, EGLNativePixmapType target
)
707 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
708 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
712 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
713 if (disp
->Platform
!= _eglGetNativePlatform(disp
->PlatformDisplay
))
714 RETURN_EGL_ERROR(disp
, EGL_BAD_NATIVE_PIXMAP
, EGL_FALSE
);
715 ret
= drv
->API
.CopyBuffers(drv
, disp
, surf
, target
);
717 RETURN_EGL_EVAL(disp
, ret
);
721 EGLBoolean EGLAPIENTRY
724 _EGLContext
*ctx
= _eglGetCurrentContext();
730 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
732 disp
= ctx
->Resource
.Display
;
733 _eglLockMutex(&disp
->Mutex
);
735 /* let bad current context imply bad current surface */
736 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
737 _eglGetSurfaceHandle(ctx
->DrawSurface
) == EGL_NO_SURFACE
)
738 RETURN_EGL_ERROR(disp
, EGL_BAD_CURRENT_SURFACE
, EGL_FALSE
);
740 /* a valid current context implies an initialized current display */
741 assert(disp
->Initialized
);
743 ret
= drv
->API
.WaitClient(drv
, disp
, ctx
);
745 RETURN_EGL_EVAL(disp
, ret
);
749 EGLBoolean EGLAPIENTRY
752 _EGLThreadInfo
*t
= _eglGetCurrentThread();
753 EGLint api_index
= t
->CurrentAPIIndex
;
754 EGLint es_index
= _eglConvertApiToIndex(EGL_OPENGL_ES_API
);
757 if (api_index
!= es_index
&& _eglIsCurrentThreadDummy())
758 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_FALSE
);
760 t
->CurrentAPIIndex
= es_index
;
761 ret
= eglWaitClient();
762 t
->CurrentAPIIndex
= api_index
;
767 EGLBoolean EGLAPIENTRY
768 eglWaitNative(EGLint engine
)
770 _EGLContext
*ctx
= _eglGetCurrentContext();
776 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
778 disp
= ctx
->Resource
.Display
;
779 _eglLockMutex(&disp
->Mutex
);
781 /* let bad current context imply bad current surface */
782 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
783 _eglGetSurfaceHandle(ctx
->DrawSurface
) == EGL_NO_SURFACE
)
784 RETURN_EGL_ERROR(disp
, EGL_BAD_CURRENT_SURFACE
, EGL_FALSE
);
786 /* a valid current context implies an initialized current display */
787 assert(disp
->Initialized
);
789 ret
= drv
->API
.WaitNative(drv
, disp
, engine
);
791 RETURN_EGL_EVAL(disp
, ret
);
795 EGLDisplay EGLAPIENTRY
796 eglGetCurrentDisplay(void)
798 _EGLContext
*ctx
= _eglGetCurrentContext();
801 ret
= (ctx
) ? _eglGetDisplayHandle(ctx
->Resource
.Display
) : EGL_NO_DISPLAY
;
803 RETURN_EGL_SUCCESS(NULL
, ret
);
807 EGLContext EGLAPIENTRY
808 eglGetCurrentContext(void)
810 _EGLContext
*ctx
= _eglGetCurrentContext();
813 ret
= _eglGetContextHandle(ctx
);
815 RETURN_EGL_SUCCESS(NULL
, ret
);
819 EGLSurface EGLAPIENTRY
820 eglGetCurrentSurface(EGLint readdraw
)
822 _EGLContext
*ctx
= _eglGetCurrentContext();
823 EGLint err
= EGL_SUCCESS
;
828 RETURN_EGL_SUCCESS(NULL
, EGL_NO_SURFACE
);
832 surf
= ctx
->DrawSurface
;
835 surf
= ctx
->ReadSurface
;
839 err
= EGL_BAD_PARAMETER
;
843 ret
= _eglGetSurfaceHandle(surf
);
845 RETURN_EGL_ERROR(NULL
, err
, ret
);
852 _EGLThreadInfo
*t
= _eglGetCurrentThread();
853 EGLint e
= t
->LastError
;
854 if (!_eglIsCurrentThreadDummy())
855 t
->LastError
= EGL_SUCCESS
;
860 __eglMustCastToProperFunctionPointerType EGLAPIENTRY
861 eglGetProcAddress(const char *procname
)
863 static const struct {
866 } egl_functions
[] = {
867 /* core functions should not be queryable, but, well... */
868 #ifdef _EGL_GET_CORE_ADDRESSES
869 /* alphabetical order */
870 { "eglBindAPI", (_EGLProc
) eglBindAPI
},
871 { "eglBindTexImage", (_EGLProc
) eglBindTexImage
},
872 { "eglChooseConfig", (_EGLProc
) eglChooseConfig
},
873 { "eglCopyBuffers", (_EGLProc
) eglCopyBuffers
},
874 { "eglCreateContext", (_EGLProc
) eglCreateContext
},
875 { "eglCreatePbufferFromClientBuffer", (_EGLProc
) eglCreatePbufferFromClientBuffer
},
876 { "eglCreatePbufferSurface", (_EGLProc
) eglCreatePbufferSurface
},
877 { "eglCreatePixmapSurface", (_EGLProc
) eglCreatePixmapSurface
},
878 { "eglCreateWindowSurface", (_EGLProc
) eglCreateWindowSurface
},
879 { "eglDestroyContext", (_EGLProc
) eglDestroyContext
},
880 { "eglDestroySurface", (_EGLProc
) eglDestroySurface
},
881 { "eglGetConfigAttrib", (_EGLProc
) eglGetConfigAttrib
},
882 { "eglGetConfigs", (_EGLProc
) eglGetConfigs
},
883 { "eglGetCurrentContext", (_EGLProc
) eglGetCurrentContext
},
884 { "eglGetCurrentDisplay", (_EGLProc
) eglGetCurrentDisplay
},
885 { "eglGetCurrentSurface", (_EGLProc
) eglGetCurrentSurface
},
886 { "eglGetDisplay", (_EGLProc
) eglGetDisplay
},
887 { "eglGetError", (_EGLProc
) eglGetError
},
888 { "eglGetProcAddress", (_EGLProc
) eglGetProcAddress
},
889 { "eglInitialize", (_EGLProc
) eglInitialize
},
890 { "eglMakeCurrent", (_EGLProc
) eglMakeCurrent
},
891 { "eglQueryAPI", (_EGLProc
) eglQueryAPI
},
892 { "eglQueryContext", (_EGLProc
) eglQueryContext
},
893 { "eglQueryString", (_EGLProc
) eglQueryString
},
894 { "eglQuerySurface", (_EGLProc
) eglQuerySurface
},
895 { "eglReleaseTexImage", (_EGLProc
) eglReleaseTexImage
},
896 { "eglReleaseThread", (_EGLProc
) eglReleaseThread
},
897 { "eglSurfaceAttrib", (_EGLProc
) eglSurfaceAttrib
},
898 { "eglSwapBuffers", (_EGLProc
) eglSwapBuffers
},
899 { "eglSwapInterval", (_EGLProc
) eglSwapInterval
},
900 { "eglTerminate", (_EGLProc
) eglTerminate
},
901 { "eglWaitClient", (_EGLProc
) eglWaitClient
},
902 { "eglWaitGL", (_EGLProc
) eglWaitGL
},
903 { "eglWaitNative", (_EGLProc
) eglWaitNative
},
904 #endif /* _EGL_GET_CORE_ADDRESSES */
905 #ifdef EGL_MESA_screen_surface
906 { "eglChooseModeMESA", (_EGLProc
) eglChooseModeMESA
},
907 { "eglGetModesMESA", (_EGLProc
) eglGetModesMESA
},
908 { "eglGetModeAttribMESA", (_EGLProc
) eglGetModeAttribMESA
},
909 { "eglCopyContextMESA", (_EGLProc
) eglCopyContextMESA
},
910 { "eglGetScreensMESA", (_EGLProc
) eglGetScreensMESA
},
911 { "eglCreateScreenSurfaceMESA", (_EGLProc
) eglCreateScreenSurfaceMESA
},
912 { "eglShowScreenSurfaceMESA", (_EGLProc
) eglShowScreenSurfaceMESA
},
913 { "eglScreenPositionMESA", (_EGLProc
) eglScreenPositionMESA
},
914 { "eglQueryScreenMESA", (_EGLProc
) eglQueryScreenMESA
},
915 { "eglQueryScreenSurfaceMESA", (_EGLProc
) eglQueryScreenSurfaceMESA
},
916 { "eglQueryScreenModeMESA", (_EGLProc
) eglQueryScreenModeMESA
},
917 { "eglQueryModeStringMESA", (_EGLProc
) eglQueryModeStringMESA
},
918 #endif /* EGL_MESA_screen_surface */
919 #ifdef EGL_MESA_drm_display
920 { "eglGetDRMDisplayMESA", (_EGLProc
) eglGetDRMDisplayMESA
},
922 { "eglCreateImageKHR", (_EGLProc
) eglCreateImageKHR
},
923 { "eglDestroyImageKHR", (_EGLProc
) eglDestroyImageKHR
},
924 { "eglCreateSyncKHR", (_EGLProc
) eglCreateSyncKHR
},
925 { "eglDestroySyncKHR", (_EGLProc
) eglDestroySyncKHR
},
926 { "eglClientWaitSyncKHR", (_EGLProc
) eglClientWaitSyncKHR
},
927 { "eglSignalSyncKHR", (_EGLProc
) eglSignalSyncKHR
},
928 { "eglGetSyncAttribKHR", (_EGLProc
) eglGetSyncAttribKHR
},
929 #ifdef EGL_NOK_swap_region
930 { "eglSwapBuffersRegionNOK", (_EGLProc
) eglSwapBuffersRegionNOK
},
932 #ifdef EGL_MESA_drm_image
933 { "eglCreateDRMImageMESA", (_EGLProc
) eglCreateDRMImageMESA
},
934 { "eglExportDRMImageMESA", (_EGLProc
) eglExportDRMImageMESA
},
936 #ifdef EGL_WL_bind_wayland_display
937 { "eglBindWaylandDisplayWL", (_EGLProc
) eglBindWaylandDisplayWL
},
938 { "eglUnbindWaylandDisplayWL", (_EGLProc
) eglUnbindWaylandDisplayWL
},
939 { "eglQueryWaylandBufferWL", (_EGLProc
) eglQueryWaylandBufferWL
},
941 { "eglPostSubBufferNV", (_EGLProc
) eglPostSubBufferNV
},
948 RETURN_EGL_SUCCESS(NULL
, NULL
);
951 if (strncmp(procname
, "egl", 3) == 0) {
952 for (i
= 0; egl_functions
[i
].name
; i
++) {
953 if (strcmp(egl_functions
[i
].name
, procname
) == 0) {
954 ret
= egl_functions
[i
].function
;
960 ret
= _eglGetDriverProc(procname
);
962 RETURN_EGL_SUCCESS(NULL
, ret
);
966 #ifdef EGL_MESA_screen_surface
970 * EGL_MESA_screen extension
973 EGLBoolean EGLAPIENTRY
974 eglChooseModeMESA(EGLDisplay dpy
, EGLScreenMESA screen
,
975 const EGLint
*attrib_list
, EGLModeMESA
*modes
,
976 EGLint modes_size
, EGLint
*num_modes
)
978 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
979 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
983 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
984 ret
= drv
->API
.ChooseModeMESA(drv
, disp
, scrn
, attrib_list
,
985 modes
, modes_size
, num_modes
);
987 RETURN_EGL_EVAL(disp
, ret
);
991 EGLBoolean EGLAPIENTRY
992 eglGetModesMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLModeMESA
*modes
,
993 EGLint mode_size
, EGLint
*num_mode
)
995 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
996 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
1000 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1001 ret
= drv
->API
.GetModesMESA(drv
, disp
, scrn
, modes
, mode_size
, num_mode
);
1003 RETURN_EGL_EVAL(disp
, ret
);
1007 EGLBoolean EGLAPIENTRY
1008 eglGetModeAttribMESA(EGLDisplay dpy
, EGLModeMESA mode
,
1009 EGLint attribute
, EGLint
*value
)
1011 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1012 _EGLMode
*m
= _eglLookupMode(mode
, disp
);
1016 _EGL_CHECK_MODE(disp
, m
, EGL_FALSE
, drv
);
1017 ret
= drv
->API
.GetModeAttribMESA(drv
, disp
, m
, attribute
, value
);
1019 RETURN_EGL_EVAL(disp
, ret
);
1023 EGLBoolean EGLAPIENTRY
1024 eglCopyContextMESA(EGLDisplay dpy
, EGLContext source
, EGLContext dest
,
1027 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1028 _EGLContext
*source_context
= _eglLookupContext(source
, disp
);
1029 _EGLContext
*dest_context
= _eglLookupContext(dest
, disp
);
1033 _EGL_CHECK_CONTEXT(disp
, source_context
, EGL_FALSE
, drv
);
1035 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_FALSE
);
1037 ret
= drv
->API
.CopyContextMESA(drv
, disp
,
1038 source_context
, dest_context
, mask
);
1040 RETURN_EGL_EVAL(disp
, ret
);
1044 EGLBoolean EGLAPIENTRY
1045 eglGetScreensMESA(EGLDisplay dpy
, EGLScreenMESA
*screens
,
1046 EGLint max_screens
, EGLint
*num_screens
)
1048 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1052 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1053 ret
= drv
->API
.GetScreensMESA(drv
, disp
, screens
, max_screens
, num_screens
);
1055 RETURN_EGL_EVAL(disp
, ret
);
1059 EGLSurface EGLAPIENTRY
1060 eglCreateScreenSurfaceMESA(EGLDisplay dpy
, EGLConfig config
,
1061 const EGLint
*attrib_list
)
1063 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1064 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
1069 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
1071 surf
= drv
->API
.CreateScreenSurfaceMESA(drv
, disp
, conf
, attrib_list
);
1072 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
1074 RETURN_EGL_EVAL(disp
, ret
);
1078 EGLBoolean EGLAPIENTRY
1079 eglShowScreenSurfaceMESA(EGLDisplay dpy
, EGLint screen
,
1080 EGLSurface surface
, EGLModeMESA mode
)
1082 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1083 _EGLScreen
*scrn
= _eglLookupScreen((EGLScreenMESA
) screen
, disp
);
1084 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1085 _EGLMode
*m
= _eglLookupMode(mode
, disp
);
1089 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1090 if (!surf
&& surface
!= EGL_NO_SURFACE
)
1091 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1092 if (!m
&& mode
!= EGL_NO_MODE_MESA
)
1093 RETURN_EGL_ERROR(disp
, EGL_BAD_MODE_MESA
, EGL_FALSE
);
1095 ret
= drv
->API
.ShowScreenSurfaceMESA(drv
, disp
, scrn
, surf
, m
);
1097 RETURN_EGL_EVAL(disp
, ret
);
1101 EGLBoolean EGLAPIENTRY
1102 eglScreenPositionMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLint x
, EGLint y
)
1104 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1105 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
1109 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1110 ret
= drv
->API
.ScreenPositionMESA(drv
, disp
, scrn
, x
, y
);
1112 RETURN_EGL_EVAL(disp
, ret
);
1116 EGLBoolean EGLAPIENTRY
1117 eglQueryScreenMESA(EGLDisplay dpy
, EGLScreenMESA screen
,
1118 EGLint attribute
, EGLint
*value
)
1120 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1121 _EGLScreen
*scrn
= _eglLookupScreen(screen
, disp
);
1125 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1126 ret
= drv
->API
.QueryScreenMESA(drv
, disp
, scrn
, attribute
, value
);
1128 RETURN_EGL_EVAL(disp
, ret
);
1132 EGLBoolean EGLAPIENTRY
1133 eglQueryScreenSurfaceMESA(EGLDisplay dpy
, EGLScreenMESA screen
,
1134 EGLSurface
*surface
)
1136 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1137 _EGLScreen
*scrn
= _eglLookupScreen((EGLScreenMESA
) screen
, disp
);
1142 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1143 ret
= drv
->API
.QueryScreenSurfaceMESA(drv
, disp
, scrn
, &surf
);
1145 *surface
= _eglGetSurfaceHandle(surf
);
1147 RETURN_EGL_EVAL(disp
, ret
);
1151 EGLBoolean EGLAPIENTRY
1152 eglQueryScreenModeMESA(EGLDisplay dpy
, EGLScreenMESA screen
, EGLModeMESA
*mode
)
1154 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1155 _EGLScreen
*scrn
= _eglLookupScreen((EGLScreenMESA
) screen
, disp
);
1160 _EGL_CHECK_SCREEN(disp
, scrn
, EGL_FALSE
, drv
);
1161 ret
= drv
->API
.QueryScreenModeMESA(drv
, disp
, scrn
, &m
);
1165 RETURN_EGL_EVAL(disp
, ret
);
1169 const char * EGLAPIENTRY
1170 eglQueryModeStringMESA(EGLDisplay dpy
, EGLModeMESA mode
)
1172 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1173 _EGLMode
*m
= _eglLookupMode(mode
, disp
);
1177 _EGL_CHECK_MODE(disp
, m
, NULL
, drv
);
1178 ret
= drv
->API
.QueryModeStringMESA(drv
, disp
, m
);
1180 RETURN_EGL_EVAL(disp
, ret
);
1184 #endif /* EGL_MESA_screen_surface */
1187 #ifdef EGL_MESA_drm_display
1189 EGLDisplay EGLAPIENTRY
1190 eglGetDRMDisplayMESA(int fd
)
1192 _EGLDisplay
*dpy
= _eglFindDisplay(_EGL_PLATFORM_DRM
, (void *) (intptr_t) fd
);
1193 return _eglGetDisplayHandle(dpy
);
1196 #endif /* EGL_MESA_drm_display */
1203 * Specify the client API to use for subsequent calls including:
1204 * eglCreateContext()
1205 * eglGetCurrentContext()
1206 * eglGetCurrentDisplay()
1207 * eglGetCurrentSurface()
1208 * eglMakeCurrent(when the ctx parameter is EGL NO CONTEXT)
1211 * See section 3.7 "Rendering Context" in the EGL specification for details.
1213 EGLBoolean EGLAPIENTRY
1214 eglBindAPI(EGLenum api
)
1216 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1218 if (_eglIsCurrentThreadDummy())
1219 RETURN_EGL_ERROR(NULL
, EGL_BAD_ALLOC
, EGL_FALSE
);
1221 if (!_eglIsApiValid(api
))
1222 RETURN_EGL_ERROR(NULL
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1224 t
->CurrentAPIIndex
= _eglConvertApiToIndex(api
);
1226 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1231 * Return the last value set with eglBindAPI().
1236 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1239 /* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
1240 ret
= _eglConvertApiFromIndex(t
->CurrentAPIIndex
);
1242 RETURN_EGL_SUCCESS(NULL
, ret
);
1246 EGLSurface EGLAPIENTRY
1247 eglCreatePbufferFromClientBuffer(EGLDisplay dpy
, EGLenum buftype
,
1248 EGLClientBuffer buffer
, EGLConfig config
,
1249 const EGLint
*attrib_list
)
1251 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1252 _EGLConfig
*conf
= _eglLookupConfig(config
, disp
);
1257 _EGL_CHECK_CONFIG(disp
, conf
, EGL_NO_SURFACE
, drv
);
1259 surf
= drv
->API
.CreatePbufferFromClientBuffer(drv
, disp
, buftype
, buffer
,
1261 ret
= (surf
) ? _eglLinkSurface(surf
) : EGL_NO_SURFACE
;
1263 RETURN_EGL_EVAL(disp
, ret
);
1267 EGLBoolean EGLAPIENTRY
1268 eglReleaseThread(void)
1270 /* unbind current contexts */
1271 if (!_eglIsCurrentThreadDummy()) {
1272 _EGLThreadInfo
*t
= _eglGetCurrentThread();
1273 EGLint api_index
= t
->CurrentAPIIndex
;
1276 for (i
= 0; i
< _EGL_API_NUM_APIS
; i
++) {
1277 _EGLContext
*ctx
= t
->CurrentContexts
[i
];
1279 _EGLDisplay
*disp
= ctx
->Resource
.Display
;
1282 t
->CurrentAPIIndex
= i
;
1284 _eglLockMutex(&disp
->Mutex
);
1286 (void) drv
->API
.MakeCurrent(drv
, disp
, NULL
, NULL
, NULL
);
1287 _eglUnlockMutex(&disp
->Mutex
);
1291 t
->CurrentAPIIndex
= api_index
;
1294 _eglDestroyCurrentThread();
1296 RETURN_EGL_SUCCESS(NULL
, EGL_TRUE
);
1300 EGLImageKHR EGLAPIENTRY
1301 eglCreateImageKHR(EGLDisplay dpy
, EGLContext ctx
, EGLenum target
,
1302 EGLClientBuffer buffer
, const EGLint
*attr_list
)
1304 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1305 _EGLContext
*context
= _eglLookupContext(ctx
, disp
);
1310 _EGL_CHECK_DISPLAY(disp
, EGL_NO_IMAGE_KHR
, drv
);
1311 if (!disp
->Extensions
.KHR_image_base
)
1312 RETURN_EGL_EVAL(disp
, EGL_NO_IMAGE_KHR
);
1313 if (!context
&& ctx
!= EGL_NO_CONTEXT
)
1314 RETURN_EGL_ERROR(disp
, EGL_BAD_CONTEXT
, EGL_NO_IMAGE_KHR
);
1316 img
= drv
->API
.CreateImageKHR(drv
,
1317 disp
, context
, target
, buffer
, attr_list
);
1318 ret
= (img
) ? _eglLinkImage(img
) : EGL_NO_IMAGE_KHR
;
1320 RETURN_EGL_EVAL(disp
, ret
);
1324 EGLBoolean EGLAPIENTRY
1325 eglDestroyImageKHR(EGLDisplay dpy
, EGLImageKHR image
)
1327 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1328 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1332 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1333 if (!disp
->Extensions
.KHR_image_base
)
1334 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1336 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1338 _eglUnlinkImage(img
);
1339 ret
= drv
->API
.DestroyImageKHR(drv
, disp
, img
);
1341 RETURN_EGL_EVAL(disp
, ret
);
1345 EGLSyncKHR EGLAPIENTRY
1346 eglCreateSyncKHR(EGLDisplay dpy
, EGLenum type
, const EGLint
*attrib_list
)
1348 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1353 _EGL_CHECK_DISPLAY(disp
, EGL_NO_SYNC_KHR
, drv
);
1354 if (!disp
->Extensions
.KHR_reusable_sync
)
1355 RETURN_EGL_EVAL(disp
, EGL_NO_SYNC_KHR
);
1357 sync
= drv
->API
.CreateSyncKHR(drv
, disp
, type
, attrib_list
);
1358 ret
= (sync
) ? _eglLinkSync(sync
) : EGL_NO_SYNC_KHR
;
1360 RETURN_EGL_EVAL(disp
, ret
);
1364 EGLBoolean EGLAPIENTRY
1365 eglDestroySyncKHR(EGLDisplay dpy
, EGLSyncKHR sync
)
1367 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1368 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1372 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1373 assert(disp
->Extensions
.KHR_reusable_sync
);
1376 ret
= drv
->API
.DestroySyncKHR(drv
, disp
, s
);
1378 RETURN_EGL_EVAL(disp
, ret
);
1383 eglClientWaitSyncKHR(EGLDisplay dpy
, EGLSyncKHR sync
, EGLint flags
, EGLTimeKHR timeout
)
1385 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1386 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1390 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1391 assert(disp
->Extensions
.KHR_reusable_sync
);
1392 ret
= drv
->API
.ClientWaitSyncKHR(drv
, disp
, s
, flags
, timeout
);
1394 RETURN_EGL_EVAL(disp
, ret
);
1398 EGLBoolean EGLAPIENTRY
1399 eglSignalSyncKHR(EGLDisplay dpy
, EGLSyncKHR sync
, EGLenum mode
)
1401 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1402 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1406 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1407 assert(disp
->Extensions
.KHR_reusable_sync
);
1408 ret
= drv
->API
.SignalSyncKHR(drv
, disp
, s
, mode
);
1410 RETURN_EGL_EVAL(disp
, ret
);
1414 EGLBoolean EGLAPIENTRY
1415 eglGetSyncAttribKHR(EGLDisplay dpy
, EGLSyncKHR sync
, EGLint attribute
, EGLint
*value
)
1417 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1418 _EGLSync
*s
= _eglLookupSync(sync
, disp
);
1422 _EGL_CHECK_SYNC(disp
, s
, EGL_FALSE
, drv
);
1423 assert(disp
->Extensions
.KHR_reusable_sync
);
1424 ret
= drv
->API
.GetSyncAttribKHR(drv
, disp
, s
, attribute
, value
);
1426 RETURN_EGL_EVAL(disp
, ret
);
1430 #ifdef EGL_NOK_swap_region
1432 EGLBoolean EGLAPIENTRY
1433 eglSwapBuffersRegionNOK(EGLDisplay dpy
, EGLSurface surface
,
1434 EGLint numRects
, const EGLint
*rects
)
1436 _EGLContext
*ctx
= _eglGetCurrentContext();
1437 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1438 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1442 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1444 if (!disp
->Extensions
.NOK_swap_region
)
1445 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1447 /* surface must be bound to current context in EGL 1.4 */
1448 if (_eglGetContextHandle(ctx
) == EGL_NO_CONTEXT
||
1449 surf
!= ctx
->DrawSurface
)
1450 RETURN_EGL_ERROR(disp
, EGL_BAD_SURFACE
, EGL_FALSE
);
1452 ret
= drv
->API
.SwapBuffersRegionNOK(drv
, disp
, surf
, numRects
, rects
);
1454 RETURN_EGL_EVAL(disp
, ret
);
1457 #endif /* EGL_NOK_swap_region */
1460 #ifdef EGL_MESA_drm_image
1462 EGLImageKHR EGLAPIENTRY
1463 eglCreateDRMImageMESA(EGLDisplay dpy
, const EGLint
*attr_list
)
1465 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1470 _EGL_CHECK_DISPLAY(disp
, EGL_NO_IMAGE_KHR
, drv
);
1471 if (!disp
->Extensions
.MESA_drm_image
)
1472 RETURN_EGL_EVAL(disp
, EGL_NO_IMAGE_KHR
);
1474 img
= drv
->API
.CreateDRMImageMESA(drv
, disp
, attr_list
);
1475 ret
= (img
) ? _eglLinkImage(img
) : EGL_NO_IMAGE_KHR
;
1477 RETURN_EGL_EVAL(disp
, ret
);
1480 EGLBoolean EGLAPIENTRY
1481 eglExportDRMImageMESA(EGLDisplay dpy
, EGLImageKHR image
,
1482 EGLint
*name
, EGLint
*handle
, EGLint
*stride
)
1484 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1485 _EGLImage
*img
= _eglLookupImage(image
, disp
);
1489 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1490 assert(disp
->Extensions
.MESA_drm_image
);
1493 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1495 ret
= drv
->API
.ExportDRMImageMESA(drv
, disp
, img
, name
, handle
, stride
);
1497 RETURN_EGL_EVAL(disp
, ret
);
1502 #ifdef EGL_WL_bind_wayland_display
1505 EGLBoolean EGLAPIENTRY
1506 eglBindWaylandDisplayWL(EGLDisplay dpy
, struct wl_display
*display
)
1508 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1512 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1513 assert(disp
->Extensions
.WL_bind_wayland_display
);
1516 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1518 ret
= drv
->API
.BindWaylandDisplayWL(drv
, disp
, display
);
1520 RETURN_EGL_EVAL(disp
, ret
);
1523 EGLBoolean EGLAPIENTRY
1524 eglUnbindWaylandDisplayWL(EGLDisplay dpy
, struct wl_display
*display
)
1526 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1530 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1531 assert(disp
->Extensions
.WL_bind_wayland_display
);
1534 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1536 ret
= drv
->API
.UnbindWaylandDisplayWL(drv
, disp
, display
);
1538 RETURN_EGL_EVAL(disp
, ret
);
1541 EGLBoolean EGLAPIENTRY
1542 eglQueryWaylandBufferWL(EGLDisplay dpy
,struct wl_buffer
*buffer
,
1543 EGLint attribute
, EGLint
*value
)
1545 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1549 _EGL_CHECK_DISPLAY(disp
, EGL_FALSE
, drv
);
1550 assert(disp
->Extensions
.WL_bind_wayland_display
);
1553 RETURN_EGL_ERROR(disp
, EGL_BAD_PARAMETER
, EGL_FALSE
);
1555 ret
= drv
->API
.QueryWaylandBufferWL(drv
, disp
, buffer
, attribute
, value
);
1557 RETURN_EGL_EVAL(disp
, ret
);
1562 EGLBoolean EGLAPIENTRY
1563 eglPostSubBufferNV(EGLDisplay dpy
, EGLSurface surface
,
1564 EGLint x
, EGLint y
, EGLint width
, EGLint height
)
1566 _EGLDisplay
*disp
= _eglLockDisplay(dpy
);
1567 _EGLSurface
*surf
= _eglLookupSurface(surface
, disp
);
1571 _EGL_CHECK_SURFACE(disp
, surf
, EGL_FALSE
, drv
);
1573 if (!disp
->Extensions
.NV_post_sub_buffer
)
1574 RETURN_EGL_EVAL(disp
, EGL_FALSE
);
1576 ret
= drv
->API
.PostSubBufferNV(drv
, disp
, surf
, x
, y
, width
, height
);
1578 RETURN_EGL_EVAL(disp
, ret
);