2005-04-22 22:09:39 +01:00
|
|
|
/**
|
|
|
|
* Public EGL API entrypoints
|
|
|
|
*
|
|
|
|
* Generally, we use the EGLDisplay parameter as a key to lookup the
|
|
|
|
* appropriate device driver handle, then jump though the driver's
|
|
|
|
* dispatch table to handle the function.
|
|
|
|
*
|
|
|
|
* That allows us the option of supporting multiple, simultaneous,
|
|
|
|
* heterogeneous hardware devices in the future.
|
|
|
|
*
|
|
|
|
* The EGLDisplay, EGLConfig, EGLContext and EGLSurface types are
|
2009-09-30 08:08:34 +01:00
|
|
|
* opaque handles. Internal objects are linked to a display to
|
|
|
|
* create the handles.
|
2005-04-22 22:09:39 +01:00
|
|
|
*
|
2009-09-30 08:08:34 +01:00
|
|
|
* For each public API entry point, the opaque handles are looked up
|
|
|
|
* before being dispatched to the drivers. When it fails to look up
|
|
|
|
* a handle, one of
|
|
|
|
*
|
|
|
|
* EGL_BAD_DISPLAY
|
|
|
|
* EGL_BAD_CONFIG
|
|
|
|
* EGL_BAD_CONTEXT
|
|
|
|
* EGL_BAD_SURFACE
|
|
|
|
* EGL_BAD_SCREEN_MESA
|
|
|
|
* EGL_BAD_MODE_MESA
|
|
|
|
*
|
|
|
|
* is generated and the driver function is not called. An
|
|
|
|
* uninitialized EGLDisplay has no driver associated with it. When
|
|
|
|
* such display is detected,
|
|
|
|
*
|
|
|
|
* EGL_NOT_INITIALIZED
|
|
|
|
*
|
|
|
|
* is generated.
|
2005-04-22 22:09:39 +01:00
|
|
|
*
|
2009-10-15 04:08:33 +01:00
|
|
|
* Some of the entry points use current display, context, or surface
|
|
|
|
* implicitly. For such entry points, the implicit objects are also
|
|
|
|
* checked before calling the driver function. Other than the
|
|
|
|
* errors listed above,
|
|
|
|
*
|
|
|
|
* EGL_BAD_CURRENT_SURFACE
|
|
|
|
*
|
|
|
|
* may also be generated.
|
|
|
|
*
|
2005-04-22 22:09:39 +01:00
|
|
|
* Notes on naming conventions:
|
|
|
|
*
|
|
|
|
* eglFooBar - public EGL function
|
|
|
|
* EGL_FOO_BAR - public EGL token
|
|
|
|
* EGLDatatype - public EGL datatype
|
|
|
|
*
|
|
|
|
* _eglFooBar - private EGL function
|
|
|
|
* _EGLDatatype - private EGL datatype, typedef'd struct
|
|
|
|
* _egl_struct - private EGL struct, non-typedef'd
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2006-01-30 00:10:55 +00:00
|
|
|
#include <stdlib.h>
|
2005-04-22 22:09:39 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include "eglcontext.h"
|
|
|
|
#include "egldisplay.h"
|
|
|
|
#include "egltypedefs.h"
|
|
|
|
#include "eglglobals.h"
|
|
|
|
#include "egldriver.h"
|
|
|
|
#include "eglsurface.h"
|
2009-08-11 10:09:39 +01:00
|
|
|
#include "eglconfig.h"
|
|
|
|
#include "eglscreen.h"
|
|
|
|
#include "eglmode.h"
|
2009-08-15 15:58:13 +01:00
|
|
|
#include "eglimage.h"
|
2005-04-22 22:09:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-05-27 23:48:23 +01:00
|
|
|
* This is typically the first EGL function that an application calls.
|
|
|
|
* We initialize our global vars and create a private _EGLDisplay object.
|
2005-04-22 22:09:39 +01:00
|
|
|
*/
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLDisplay EGLAPIENTRY
|
2010-01-25 03:55:48 +00:00
|
|
|
eglGetDisplay(EGLNativeDisplayType nativeDisplay)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
|
|
|
_EGLDisplay *dpy;
|
2009-07-17 05:21:56 +01:00
|
|
|
dpy = _eglFindDisplay(nativeDisplay);
|
|
|
|
if (!dpy) {
|
|
|
|
dpy = _eglNewDisplay(nativeDisplay);
|
|
|
|
if (dpy)
|
|
|
|
_eglLinkDisplay(dpy);
|
|
|
|
}
|
2008-05-27 21:33:54 +01:00
|
|
|
return _eglGetDisplayHandle(dpy);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 23:48:23 +01:00
|
|
|
/**
|
|
|
|
* This is typically the second EGL function that an application calls.
|
|
|
|
* Here we load/initialize the actual hardware driver.
|
|
|
|
*/
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
|
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
2008-08-06 20:40:03 +01:00
|
|
|
EGLint major_int, minor_int;
|
|
|
|
|
2009-08-11 10:09:39 +01:00
|
|
|
if (!disp)
|
|
|
|
return _eglError(EGL_BAD_DISPLAY, __FUNCTION__);
|
|
|
|
|
2010-01-27 15:55:58 +00:00
|
|
|
if (!disp->Initialized) {
|
|
|
|
_EGLDriver *drv = disp->Driver;
|
2010-01-19 10:29:21 +00:00
|
|
|
|
2010-01-27 15:55:58 +00:00
|
|
|
if (!drv) {
|
|
|
|
_eglPreloadDrivers();
|
|
|
|
drv = _eglMatchDriver(disp);
|
|
|
|
if (!drv)
|
|
|
|
return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__);
|
|
|
|
}
|
2009-08-11 10:09:39 +01:00
|
|
|
|
|
|
|
/* Initialize the particular display now */
|
2010-01-26 10:41:15 +00:00
|
|
|
if (!drv->API.Initialize(drv, disp, &major_int, &minor_int))
|
2009-08-11 10:09:39 +01:00
|
|
|
return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__);
|
2008-05-28 22:43:41 +01:00
|
|
|
|
2009-08-13 06:38:24 +01:00
|
|
|
disp->APImajor = major_int;
|
|
|
|
disp->APIminor = minor_int;
|
|
|
|
snprintf(disp->Version, sizeof(disp->Version),
|
2009-08-11 10:09:39 +01:00
|
|
|
"%d.%d (%s)", major_int, minor_int, drv->Name);
|
|
|
|
|
2009-08-17 08:53:54 +01:00
|
|
|
/* limit to APIs supported by core */
|
|
|
|
disp->ClientAPIsMask &= _EGL_API_ALL_BITS;
|
2009-08-13 06:38:24 +01:00
|
|
|
|
2009-08-11 10:09:39 +01:00
|
|
|
disp->Driver = drv;
|
2010-01-27 15:55:58 +00:00
|
|
|
disp->Initialized = EGL_TRUE;
|
2009-08-11 10:09:39 +01:00
|
|
|
} else {
|
2009-08-13 06:38:24 +01:00
|
|
|
major_int = disp->APImajor;
|
|
|
|
minor_int = disp->APIminor;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
2009-08-11 10:09:39 +01:00
|
|
|
|
|
|
|
/* Update applications version of major and minor if not NULL */
|
|
|
|
if ((major != NULL) && (minor != NULL)) {
|
|
|
|
*major = major_int;
|
|
|
|
*minor = minor_int;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EGL_TRUE;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglTerminate(EGLDisplay dpy)
|
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
|
|
|
|
if (!disp)
|
|
|
|
return _eglError(EGL_BAD_DISPLAY, __FUNCTION__);
|
|
|
|
|
2010-01-27 15:55:58 +00:00
|
|
|
if (disp->Initialized) {
|
|
|
|
_EGLDriver *drv = disp->Driver;
|
|
|
|
|
2009-08-13 06:39:51 +01:00
|
|
|
drv->API.Terminate(drv, disp);
|
2010-01-27 15:55:58 +00:00
|
|
|
/* do not reset disp->Driver */
|
|
|
|
disp->Initialized = EGL_FALSE;
|
2009-08-11 10:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return EGL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A bunch of check functions and declare macros to simply error checking.
|
|
|
|
*/
|
|
|
|
static INLINE _EGLDriver *
|
|
|
|
_eglCheckDisplay(_EGLDisplay *disp, const char *msg)
|
|
|
|
{
|
|
|
|
if (!disp) {
|
|
|
|
_eglError(EGL_BAD_DISPLAY, msg);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-01-27 15:55:58 +00:00
|
|
|
if (!disp->Initialized) {
|
2009-08-11 10:09:39 +01:00
|
|
|
_eglError(EGL_NOT_INITIALIZED, msg);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return disp->Driver;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static INLINE _EGLDriver *
|
|
|
|
_eglCheckSurface(_EGLDisplay *disp, _EGLSurface *surf, const char *msg)
|
|
|
|
{
|
|
|
|
_EGLDriver *drv = _eglCheckDisplay(disp, msg);
|
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
if (!surf) {
|
|
|
|
_eglError(EGL_BAD_SURFACE, msg);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return drv;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-11 10:09:39 +01:00
|
|
|
static INLINE _EGLDriver *
|
|
|
|
_eglCheckContext(_EGLDisplay *disp, _EGLContext *context, const char *msg)
|
|
|
|
{
|
|
|
|
_EGLDriver *drv = _eglCheckDisplay(disp, msg);
|
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
if (!context) {
|
|
|
|
_eglError(EGL_BAD_CONTEXT, msg);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static INLINE _EGLDriver *
|
|
|
|
_eglCheckConfig(_EGLDisplay *disp, _EGLConfig *conf, const char *msg)
|
|
|
|
{
|
|
|
|
_EGLDriver *drv = _eglCheckDisplay(disp, msg);
|
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
if (!conf) {
|
|
|
|
_eglError(EGL_BAD_CONFIG, msg);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define _EGL_DECLARE_DD(dpy) \
|
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy); \
|
|
|
|
_EGLDriver *drv; \
|
|
|
|
do { \
|
|
|
|
drv = _eglCheckDisplay(disp, __FUNCTION__); \
|
|
|
|
if (!drv) \
|
|
|
|
return EGL_FALSE; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
|
#define _EGL_DECLARE_DD_AND_SURFACE(dpy, surface) \
|
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy); \
|
|
|
|
_EGLSurface *surf = _eglLookupSurface((surface), disp); \
|
|
|
|
_EGLDriver *drv; \
|
|
|
|
do { \
|
|
|
|
drv = _eglCheckSurface(disp, surf, __FUNCTION__); \
|
|
|
|
if (!drv) \
|
|
|
|
return EGL_FALSE; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
|
#define _EGL_DECLARE_DD_AND_CONTEXT(dpy, ctx) \
|
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy); \
|
|
|
|
_EGLContext *context = _eglLookupContext((ctx), disp); \
|
|
|
|
_EGLDriver *drv; \
|
|
|
|
do { \
|
|
|
|
drv = _eglCheckContext(disp, context, __FUNCTION__); \
|
|
|
|
if (!drv) \
|
|
|
|
return EGL_FALSE; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef EGL_MESA_screen_surface
|
|
|
|
|
|
|
|
|
|
|
|
static INLINE _EGLDriver *
|
|
|
|
_eglCheckScreen(_EGLDisplay *disp, _EGLScreen *scrn, const char *msg)
|
|
|
|
{
|
|
|
|
_EGLDriver *drv = _eglCheckDisplay(disp, msg);
|
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
if (!scrn) {
|
|
|
|
_eglError(EGL_BAD_SCREEN_MESA, msg);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static INLINE _EGLDriver *
|
|
|
|
_eglCheckMode(_EGLDisplay *disp, _EGLMode *m, const char *msg)
|
|
|
|
{
|
|
|
|
_EGLDriver *drv = _eglCheckDisplay(disp, msg);
|
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
if (!m) {
|
|
|
|
_eglError(EGL_BAD_MODE_MESA, msg);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define _EGL_DECLARE_DD_AND_SCREEN(dpy, screen) \
|
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy); \
|
|
|
|
_EGLScreen *scrn = _eglLookupScreen((screen), disp); \
|
|
|
|
_EGLDriver *drv; \
|
|
|
|
do { \
|
|
|
|
drv = _eglCheckScreen(disp, scrn, __FUNCTION__); \
|
|
|
|
if (!drv) \
|
|
|
|
return EGL_FALSE; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
|
#define _EGL_DECLARE_DD_AND_MODE(dpy, mode) \
|
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy); \
|
|
|
|
_EGLMode *m = _eglLookupMode((mode), disp); \
|
|
|
|
_EGLDriver *drv; \
|
|
|
|
do { \
|
|
|
|
drv = _eglCheckMode(disp, m, __FUNCTION__); \
|
|
|
|
if (!drv) \
|
|
|
|
return EGL_FALSE; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* EGL_MESA_screen_surface */
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
const char * EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglQueryString(EGLDisplay dpy, EGLint name)
|
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD(dpy);
|
|
|
|
return drv->API.QueryString(drv, disp, name);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
|
|
|
|
EGLint config_size, EGLint *num_config)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD(dpy);
|
|
|
|
return drv->API.GetConfigs(drv, disp, configs, config_size, num_config);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs,
|
|
|
|
EGLint config_size, EGLint *num_config)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD(dpy);
|
|
|
|
return drv->API.ChooseConfig(drv, disp, attrib_list, configs,
|
|
|
|
config_size, num_config);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
|
|
|
|
EGLint attribute, EGLint *value)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLConfig *conf = _eglLookupConfig(config, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
|
|
|
|
drv = _eglCheckConfig(disp, conf, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_FALSE;
|
|
|
|
|
|
|
|
return drv->API.GetConfigAttrib(drv, disp, conf, attribute, value);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLContext EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list,
|
|
|
|
const EGLint *attrib_list)
|
|
|
|
{
|
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLConfig *conf = _eglLookupConfig(config, disp);
|
|
|
|
_EGLContext *share = _eglLookupContext(share_list, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
_EGLContext *context;
|
|
|
|
|
|
|
|
drv = _eglCheckConfig(disp, conf, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_NO_CONTEXT;
|
|
|
|
if (!share && share_list != EGL_NO_CONTEXT) {
|
|
|
|
_eglError(EGL_BAD_CONTEXT, __FUNCTION__);
|
|
|
|
return EGL_NO_CONTEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
context = drv->API.CreateContext(drv, disp, conf, share, attrib_list);
|
|
|
|
if (context)
|
|
|
|
return _eglLinkContext(context, disp);
|
|
|
|
else
|
|
|
|
return EGL_NO_CONTEXT;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
|
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_CONTEXT(dpy, ctx);
|
|
|
|
_eglUnlinkContext(context);
|
|
|
|
return drv->API.DestroyContext(drv, disp, context);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read,
|
|
|
|
EGLContext ctx)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLContext *context = _eglLookupContext(ctx, disp);
|
|
|
|
_EGLSurface *draw_surf = _eglLookupSurface(draw, disp);
|
|
|
|
_EGLSurface *read_surf = _eglLookupSurface(read, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
|
2010-01-27 15:51:54 +00:00
|
|
|
if (!disp)
|
|
|
|
return _eglError(EGL_BAD_DISPLAY, __FUNCTION__);
|
|
|
|
drv = disp->Driver;
|
|
|
|
|
|
|
|
/* display is allowed to be uninitialized under certain condition */
|
|
|
|
if (!disp->Initialized) {
|
|
|
|
if (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE ||
|
|
|
|
ctx != EGL_NO_CONTEXT)
|
|
|
|
return _eglError(EGL_BAD_DISPLAY, __FUNCTION__);
|
|
|
|
}
|
2009-08-11 10:09:39 +01:00
|
|
|
if (!drv)
|
2010-01-27 15:51:54 +00:00
|
|
|
return EGL_TRUE;
|
|
|
|
|
2009-08-11 10:09:39 +01:00
|
|
|
if (!context && ctx != EGL_NO_CONTEXT)
|
|
|
|
return _eglError(EGL_BAD_CONTEXT, __FUNCTION__);
|
|
|
|
if ((!draw_surf && draw != EGL_NO_SURFACE) ||
|
|
|
|
(!read_surf && read != EGL_NO_SURFACE))
|
|
|
|
return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
|
|
|
|
|
|
|
|
return drv->API.MakeCurrent(drv, disp, draw_surf, read_surf, context);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglQueryContext(EGLDisplay dpy, EGLContext ctx,
|
|
|
|
EGLint attribute, EGLint *value)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_CONTEXT(dpy, ctx);
|
|
|
|
return drv->API.QueryContext(drv, disp, context, attribute, value);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLSurface EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
|
2010-01-25 03:55:48 +00:00
|
|
|
EGLNativeWindowType window, const EGLint *attrib_list)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLConfig *conf = _eglLookupConfig(config, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
_EGLSurface *surf;
|
|
|
|
|
|
|
|
drv = _eglCheckConfig(disp, conf, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_NO_SURFACE;
|
|
|
|
|
|
|
|
surf = drv->API.CreateWindowSurface(drv, disp, conf, window, attrib_list);
|
|
|
|
if (surf)
|
|
|
|
return _eglLinkSurface(surf, disp);
|
|
|
|
else
|
|
|
|
return EGL_NO_SURFACE;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLSurface EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
|
2010-01-25 03:55:48 +00:00
|
|
|
EGLNativePixmapType pixmap, const EGLint *attrib_list)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLConfig *conf = _eglLookupConfig(config, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
_EGLSurface *surf;
|
|
|
|
|
|
|
|
drv = _eglCheckConfig(disp, conf, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_NO_SURFACE;
|
|
|
|
|
|
|
|
surf = drv->API.CreatePixmapSurface(drv, disp, conf, pixmap, attrib_list);
|
|
|
|
if (surf)
|
|
|
|
return _eglLinkSurface(surf, disp);
|
|
|
|
else
|
|
|
|
return EGL_NO_SURFACE;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLSurface EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
|
|
|
|
const EGLint *attrib_list)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLConfig *conf = _eglLookupConfig(config, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
_EGLSurface *surf;
|
|
|
|
|
|
|
|
drv = _eglCheckConfig(disp, conf, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_NO_SURFACE;
|
|
|
|
|
|
|
|
surf = drv->API.CreatePbufferSurface(drv, disp, conf, attrib_list);
|
|
|
|
if (surf)
|
|
|
|
return _eglLinkSurface(surf, disp);
|
|
|
|
else
|
|
|
|
return EGL_NO_SURFACE;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
|
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
|
|
|
|
_eglUnlinkSurface(surf);
|
|
|
|
return drv->API.DestroySurface(drv, disp, surf);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
|
|
|
|
EGLint attribute, EGLint *value)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
|
|
|
|
return drv->API.QuerySurface(drv, disp, surf, attribute, value);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
|
|
|
|
EGLint attribute, EGLint value)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
|
|
|
|
return drv->API.SurfaceAttrib(drv, disp, surf, attribute, value);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
|
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
|
|
|
|
return drv->API.BindTexImage(drv, disp, surf, buffer);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
|
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
|
|
|
|
return drv->API.ReleaseTexImage(drv, disp, surf, buffer);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglSwapInterval(EGLDisplay dpy, EGLint interval)
|
|
|
|
{
|
2009-10-15 04:08:48 +01:00
|
|
|
_EGLContext *ctx = _eglGetCurrentContext();
|
|
|
|
_EGLSurface *surf;
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD(dpy);
|
2009-10-15 04:08:48 +01:00
|
|
|
|
2010-01-24 12:32:34 +00:00
|
|
|
if (!ctx || !_eglIsContextLinked(ctx) || ctx->Resource.Display != disp)
|
2009-10-15 04:08:48 +01:00
|
|
|
return _eglError(EGL_BAD_CONTEXT, __FUNCTION__);
|
|
|
|
|
|
|
|
surf = ctx->DrawSurface;
|
|
|
|
if (!_eglIsSurfaceLinked(surf))
|
|
|
|
return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
|
|
|
|
|
|
|
|
return drv->API.SwapInterval(drv, disp, surf, interval);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-10-15 04:08:33 +01:00
|
|
|
_EGLContext *ctx = _eglGetCurrentContext();
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
|
2009-10-15 04:08:33 +01:00
|
|
|
|
|
|
|
/* surface must be bound to current context in EGL 1.4 */
|
|
|
|
if (!ctx || !_eglIsContextLinked(ctx) || surf != ctx->DrawSurface)
|
|
|
|
return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
|
|
|
|
|
2009-08-11 10:09:39 +01:00
|
|
|
return drv->API.SwapBuffers(drv, disp, surf);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2010-01-25 03:55:48 +00:00
|
|
|
eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
|
|
|
|
return drv->API.CopyBuffers(drv, disp, surf, target);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-09-28 07:12:39 +01:00
|
|
|
eglWaitClient(void)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-09-28 07:12:39 +01:00
|
|
|
_EGLContext *ctx = _eglGetCurrentContext();
|
|
|
|
_EGLDisplay *disp;
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDriver *drv;
|
|
|
|
|
2009-09-28 07:12:39 +01:00
|
|
|
if (!ctx)
|
2009-08-11 10:09:39 +01:00
|
|
|
return EGL_TRUE;
|
2009-09-28 07:12:39 +01:00
|
|
|
/* let bad current context imply bad current surface */
|
|
|
|
if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface))
|
|
|
|
return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__);
|
2009-08-11 10:09:39 +01:00
|
|
|
|
2009-09-28 07:12:39 +01:00
|
|
|
/* a valid current context implies an initialized current display */
|
2010-01-24 12:32:34 +00:00
|
|
|
disp = ctx->Resource.Display;
|
2010-01-27 15:55:58 +00:00
|
|
|
assert(disp->Initialized);
|
2009-08-11 10:09:39 +01:00
|
|
|
drv = disp->Driver;
|
2009-09-28 07:12:39 +01:00
|
|
|
|
|
|
|
return drv->API.WaitClient(drv, disp, ctx);
|
|
|
|
}
|
|
|
|
|
2009-08-11 10:09:39 +01:00
|
|
|
|
2009-09-28 07:12:39 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
|
|
|
eglWaitGL(void)
|
|
|
|
{
|
|
|
|
#ifdef EGL_VERSION_1_2
|
|
|
|
_EGLThreadInfo *t = _eglGetCurrentThread();
|
|
|
|
EGLint api_index = t->CurrentAPIIndex;
|
|
|
|
EGLint es_index = _eglConvertApiToIndex(EGL_OPENGL_ES_API);
|
|
|
|
EGLBoolean ret;
|
|
|
|
|
|
|
|
if (api_index != es_index && _eglIsCurrentThreadDummy())
|
|
|
|
return _eglError(EGL_BAD_ALLOC, "eglWaitGL");
|
|
|
|
|
|
|
|
t->CurrentAPIIndex = es_index;
|
|
|
|
ret = eglWaitClient();
|
|
|
|
t->CurrentAPIIndex = api_index;
|
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
return eglWaitClient();
|
|
|
|
#endif
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglWaitNative(EGLint engine)
|
|
|
|
{
|
2009-09-28 07:12:39 +01:00
|
|
|
_EGLContext *ctx = _eglGetCurrentContext();
|
|
|
|
_EGLDisplay *disp;
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDriver *drv;
|
|
|
|
|
2009-09-28 07:12:39 +01:00
|
|
|
if (!ctx)
|
2009-08-11 10:09:39 +01:00
|
|
|
return EGL_TRUE;
|
2009-09-28 07:12:39 +01:00
|
|
|
/* let bad current context imply bad current surface */
|
|
|
|
if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface))
|
|
|
|
return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__);
|
2009-08-11 10:09:39 +01:00
|
|
|
|
2009-09-28 07:12:39 +01:00
|
|
|
/* a valid current context implies an initialized current display */
|
2010-01-24 12:32:34 +00:00
|
|
|
disp = ctx->Resource.Display;
|
2010-01-27 15:55:58 +00:00
|
|
|
assert(disp->Initialized);
|
2009-08-11 10:09:39 +01:00
|
|
|
drv = disp->Driver;
|
|
|
|
|
|
|
|
return drv->API.WaitNative(drv, disp, engine);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLDisplay EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglGetCurrentDisplay(void)
|
|
|
|
{
|
2010-01-26 09:13:51 +00:00
|
|
|
_EGLContext *ctx = _eglGetCurrentContext();
|
|
|
|
return (ctx) ? _eglGetDisplayHandle(ctx->Resource.Display) : EGL_NO_DISPLAY;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLContext EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglGetCurrentContext(void)
|
|
|
|
{
|
|
|
|
_EGLContext *ctx = _eglGetCurrentContext();
|
2008-05-27 21:21:25 +01:00
|
|
|
return _eglGetContextHandle(ctx);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLSurface EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglGetCurrentSurface(EGLint readdraw)
|
|
|
|
{
|
2009-09-30 08:34:45 +01:00
|
|
|
_EGLContext *ctx = _eglGetCurrentContext();
|
|
|
|
_EGLSurface *surf;
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
return EGL_NO_SURFACE;
|
|
|
|
|
|
|
|
switch (readdraw) {
|
|
|
|
case EGL_DRAW:
|
|
|
|
surf = ctx->DrawSurface;
|
|
|
|
break;
|
|
|
|
case EGL_READ:
|
|
|
|
surf = ctx->ReadSurface;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
_eglError(EGL_BAD_PARAMETER, __FUNCTION__);
|
|
|
|
surf = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return _eglGetSurfaceHandle(surf);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLint EGLAPIENTRY
|
2005-04-22 22:09:39 +01:00
|
|
|
eglGetError(void)
|
|
|
|
{
|
2005-12-10 17:54:00 +00:00
|
|
|
_EGLThreadInfo *t = _eglGetCurrentThread();
|
|
|
|
EGLint e = t->LastError;
|
2009-07-17 18:41:02 +01:00
|
|
|
if (!_eglIsCurrentThreadDummy())
|
|
|
|
t->LastError = EGL_SUCCESS;
|
2005-04-22 22:09:39 +01:00
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-15 15:57:47 +01:00
|
|
|
__eglMustCastToProperFunctionPointerType EGLAPIENTRY
|
|
|
|
eglGetProcAddress(const char *procname)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-15 15:44:46 +01:00
|
|
|
static const struct {
|
2005-04-22 22:09:39 +01:00
|
|
|
const char *name;
|
|
|
|
_EGLProc function;
|
2009-08-15 15:44:46 +01:00
|
|
|
} egl_functions[] = {
|
|
|
|
/* extensions only */
|
2006-01-30 00:10:55 +00:00
|
|
|
#ifdef EGL_MESA_screen_surface
|
2005-05-13 19:31:35 +01:00
|
|
|
{ "eglChooseModeMESA", (_EGLProc) eglChooseModeMESA },
|
|
|
|
{ "eglGetModesMESA", (_EGLProc) eglGetModesMESA },
|
|
|
|
{ "eglGetModeAttribMESA", (_EGLProc) eglGetModeAttribMESA },
|
2005-05-14 15:54:38 +01:00
|
|
|
{ "eglCopyContextMESA", (_EGLProc) eglCopyContextMESA },
|
2005-05-13 19:31:35 +01:00
|
|
|
{ "eglGetScreensMESA", (_EGLProc) eglGetScreensMESA },
|
|
|
|
{ "eglCreateScreenSurfaceMESA", (_EGLProc) eglCreateScreenSurfaceMESA },
|
2005-12-10 17:54:00 +00:00
|
|
|
{ "eglShowScreenSurfaceMESA", (_EGLProc) eglShowScreenSurfaceMESA },
|
2005-05-13 19:31:35 +01:00
|
|
|
{ "eglScreenPositionMESA", (_EGLProc) eglScreenPositionMESA },
|
|
|
|
{ "eglQueryScreenMESA", (_EGLProc) eglQueryScreenMESA },
|
|
|
|
{ "eglQueryScreenSurfaceMESA", (_EGLProc) eglQueryScreenSurfaceMESA },
|
|
|
|
{ "eglQueryScreenModeMESA", (_EGLProc) eglQueryScreenModeMESA },
|
|
|
|
{ "eglQueryModeStringMESA", (_EGLProc) eglQueryModeStringMESA },
|
2006-01-30 00:10:55 +00:00
|
|
|
#endif /* EGL_MESA_screen_surface */
|
2009-08-15 15:58:13 +01:00
|
|
|
#ifdef EGL_KHR_image_base
|
|
|
|
{ "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR },
|
|
|
|
{ "eglDestroyImageKHR", (_EGLProc) eglDestroyImageKHR },
|
|
|
|
#endif /* EGL_KHR_image_base */
|
2005-04-22 22:09:39 +01:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
EGLint i;
|
2009-08-15 15:44:46 +01:00
|
|
|
|
|
|
|
if (!procname)
|
|
|
|
return NULL;
|
|
|
|
if (strncmp(procname, "egl", 3) == 0) {
|
|
|
|
for (i = 0; egl_functions[i].name; i++) {
|
|
|
|
if (strcmp(egl_functions[i].name, procname) == 0)
|
|
|
|
return egl_functions[i].function;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
}
|
2008-05-30 21:50:33 +01:00
|
|
|
|
2010-01-19 10:29:21 +00:00
|
|
|
_eglPreloadDrivers();
|
2009-09-28 10:39:07 +01:00
|
|
|
|
2008-05-30 21:50:33 +01:00
|
|
|
/* now loop over drivers to query their procs */
|
|
|
|
for (i = 0; i < _eglGlobal.NumDrivers; i++) {
|
2010-01-12 09:44:03 +00:00
|
|
|
_EGLDriver *drv = _eglGlobal.Drivers[i];
|
|
|
|
_EGLProc p = drv->API.GetProcAddress(drv, procname);
|
2008-05-30 21:50:33 +01:00
|
|
|
if (p)
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2005-04-22 22:09:39 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-15 15:44:46 +01:00
|
|
|
#ifdef EGL_MESA_screen_surface
|
|
|
|
|
|
|
|
|
2005-04-22 22:09:39 +01:00
|
|
|
/*
|
|
|
|
* EGL_MESA_screen extension
|
|
|
|
*/
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2005-05-04 04:33:21 +01:00
|
|
|
eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen,
|
2005-04-22 22:09:39 +01:00
|
|
|
const EGLint *attrib_list, EGLModeMESA *modes,
|
|
|
|
EGLint modes_size, EGLint *num_modes)
|
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_SCREEN(dpy, screen);
|
|
|
|
return drv->API.ChooseModeMESA(drv, disp, scrn, attrib_list,
|
|
|
|
modes, modes_size, num_modes);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes,
|
|
|
|
EGLint mode_size, EGLint *num_mode)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_SCREEN(dpy, screen);
|
|
|
|
return drv->API.GetModesMESA(drv, disp, scrn, modes, mode_size, num_mode);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode,
|
|
|
|
EGLint attribute, EGLint *value)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_MODE(dpy, mode);
|
|
|
|
return drv->API.GetModeAttribMESA(drv, disp, m, attribute, value);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 20:45:41 +01:00
|
|
|
EGLBoolean EGLAPIENTRY
|
2009-08-11 10:09:39 +01:00
|
|
|
eglCopyContextMESA(EGLDisplay dpy, EGLContext source, EGLContext dest,
|
|
|
|
EGLint mask)
|
|
|
|
{
|
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLContext *source_context = _eglLookupContext(source, disp);
|
|
|
|
_EGLContext *dest_context = _eglLookupContext(dest, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
|
|
|
|
drv = _eglCheckContext(disp, source_context, __FUNCTION__);
|
|
|
|
if (!drv || !dest_context) {
|
|
|
|
if (drv)
|
|
|
|
_eglError(EGL_BAD_CONTEXT, __FUNCTION__);
|
2005-05-14 15:54:38 +01:00
|
|
|
return EGL_FALSE;
|
2009-08-11 10:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return drv->API.CopyContextMESA(drv, disp, source_context, dest_context,
|
|
|
|
mask);
|
2005-05-14 15:54:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-22 22:09:39 +01:00
|
|
|
EGLBoolean
|
2009-08-11 10:09:39 +01:00
|
|
|
eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens,
|
|
|
|
EGLint max_screens, EGLint *num_screens)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD(dpy);
|
|
|
|
return drv->API.GetScreensMESA(drv, disp, screens,
|
|
|
|
max_screens, num_screens);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-04 04:33:21 +01:00
|
|
|
EGLSurface
|
2009-08-11 10:09:39 +01:00
|
|
|
eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config,
|
|
|
|
const EGLint *attrib_list)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLConfig *conf = _eglLookupConfig(config, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
_EGLSurface *surf;
|
|
|
|
|
|
|
|
drv = _eglCheckConfig(disp, conf, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_NO_SURFACE;
|
|
|
|
|
|
|
|
surf = drv->API.CreateScreenSurfaceMESA(drv, disp, conf, attrib_list);
|
|
|
|
if (surf)
|
|
|
|
return _eglLinkSurface(surf, disp);
|
|
|
|
else
|
|
|
|
return EGL_NO_SURFACE;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EGLBoolean
|
2009-08-11 10:09:39 +01:00
|
|
|
eglShowScreenSurfaceMESA(EGLDisplay dpy, EGLint screen,
|
|
|
|
EGLSurface surface, EGLModeMESA mode)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLScreen *scrn = _eglLookupScreen((EGLScreenMESA) screen, disp);
|
|
|
|
_EGLSurface *surf = _eglLookupSurface(surface, disp);
|
|
|
|
_EGLMode *m = _eglLookupMode(mode, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
|
|
|
|
drv = _eglCheckScreen(disp, scrn, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_FALSE;
|
|
|
|
if (!surf && surface != EGL_NO_SURFACE)
|
|
|
|
return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
|
|
|
|
if (!m && mode != EGL_NO_MODE_MESA)
|
|
|
|
return _eglError(EGL_BAD_MODE_MESA, __FUNCTION__);
|
|
|
|
|
|
|
|
return drv->API.ShowScreenSurfaceMESA(drv, disp, scrn, surf, m);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EGLBoolean
|
2005-05-13 19:31:35 +01:00
|
|
|
eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_SCREEN(dpy, screen);
|
|
|
|
return drv->API.ScreenPositionMESA(drv, disp, scrn, x, y);
|
2005-05-13 19:31:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EGLBoolean
|
2009-08-11 10:09:39 +01:00
|
|
|
eglQueryScreenMESA(EGLDisplay dpy, EGLScreenMESA screen,
|
|
|
|
EGLint attribute, EGLint *value)
|
2005-05-13 19:31:35 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_SCREEN(dpy, screen);
|
|
|
|
return drv->API.QueryScreenMESA(drv, disp, scrn, attribute, value);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EGLBoolean
|
2009-08-11 10:09:39 +01:00
|
|
|
eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen,
|
|
|
|
EGLSurface *surface)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLScreen *scrn = _eglLookupScreen((EGLScreenMESA) screen, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
_EGLSurface *surf;
|
|
|
|
|
|
|
|
drv = _eglCheckScreen(disp, scrn, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_FALSE;
|
|
|
|
|
|
|
|
if (drv->API.QueryScreenSurfaceMESA(drv, disp, scrn, &surf) != EGL_TRUE)
|
|
|
|
surf = NULL;
|
|
|
|
if (surface)
|
|
|
|
*surface = _eglGetSurfaceHandle(surf);
|
|
|
|
return (surf != NULL);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EGLBoolean
|
2005-05-13 19:31:35 +01:00
|
|
|
eglQueryScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLScreen *scrn = _eglLookupScreen((EGLScreenMESA) screen, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
_EGLMode *m;
|
|
|
|
|
|
|
|
drv = _eglCheckScreen(disp, scrn, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_FALSE;
|
|
|
|
|
|
|
|
if (drv->API.QueryScreenModeMESA(drv, disp, scrn, &m) != EGL_TRUE)
|
|
|
|
m = NULL;
|
|
|
|
if (mode)
|
|
|
|
*mode = m->Handle;
|
|
|
|
|
|
|
|
return (m != NULL);
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-13 19:31:35 +01:00
|
|
|
const char *
|
|
|
|
eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode)
|
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGL_DECLARE_DD_AND_MODE(dpy, mode);
|
|
|
|
return drv->API.QueryModeStringMESA(drv, disp, m);
|
2005-05-13 19:31:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-15 15:44:46 +01:00
|
|
|
#endif /* EGL_MESA_screen_surface */
|
|
|
|
|
|
|
|
|
2006-01-30 00:10:55 +00:00
|
|
|
/**
|
|
|
|
** EGL 1.2
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifdef EGL_VERSION_1_2
|
|
|
|
|
2008-05-30 20:45:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Specify the client API to use for subsequent calls including:
|
|
|
|
* eglCreateContext()
|
|
|
|
* eglGetCurrentContext()
|
|
|
|
* eglGetCurrentDisplay()
|
|
|
|
* eglGetCurrentSurface()
|
|
|
|
* eglMakeCurrent(when the ctx parameter is EGL NO CONTEXT)
|
|
|
|
* eglWaitClient()
|
|
|
|
* eglWaitNative()
|
|
|
|
* See section 3.7 "Rendering Context" in the EGL specification for details.
|
|
|
|
*/
|
2006-01-30 00:10:55 +00:00
|
|
|
EGLBoolean
|
|
|
|
eglBindAPI(EGLenum api)
|
|
|
|
{
|
|
|
|
_EGLThreadInfo *t = _eglGetCurrentThread();
|
|
|
|
|
2009-07-17 18:41:02 +01:00
|
|
|
if (_eglIsCurrentThreadDummy())
|
|
|
|
return _eglError(EGL_BAD_ALLOC, "eglBindAPI");
|
|
|
|
|
2009-07-17 18:42:04 +01:00
|
|
|
if (!_eglIsApiValid(api))
|
|
|
|
return _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
|
|
|
|
2009-08-17 08:53:54 +01:00
|
|
|
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
|
2006-01-30 00:10:55 +00:00
|
|
|
return EGL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-30 20:45:40 +01:00
|
|
|
/**
|
|
|
|
* Return the last value set with eglBindAPI().
|
|
|
|
*/
|
|
|
|
EGLenum
|
|
|
|
eglQueryAPI(void)
|
|
|
|
{
|
|
|
|
/* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
|
|
|
|
_EGLThreadInfo *t = _eglGetCurrentThread();
|
2009-07-17 18:42:04 +01:00
|
|
|
return _eglConvertApiFromIndex(t->CurrentAPIIndex);
|
2008-05-30 20:45:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-30 00:10:55 +00:00
|
|
|
EGLSurface
|
|
|
|
eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype,
|
|
|
|
EGLClientBuffer buffer, EGLConfig config,
|
|
|
|
const EGLint *attrib_list)
|
|
|
|
{
|
2009-08-11 10:09:39 +01:00
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLConfig *conf = _eglLookupConfig(config, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
_EGLSurface *surf;
|
|
|
|
|
|
|
|
drv = _eglCheckConfig(disp, conf, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_NO_SURFACE;
|
|
|
|
|
|
|
|
surf = drv->API.CreatePbufferFromClientBuffer(drv, disp, buftype, buffer,
|
|
|
|
conf, attrib_list);
|
|
|
|
if (surf)
|
|
|
|
return _eglLinkSurface(surf, disp);
|
|
|
|
else
|
|
|
|
return EGL_NO_SURFACE;
|
2006-01-30 00:10:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EGLBoolean
|
|
|
|
eglReleaseThread(void)
|
|
|
|
{
|
2010-01-26 09:22:21 +00:00
|
|
|
/* unbind current contexts */
|
2009-08-11 10:09:39 +01:00
|
|
|
if (!_eglIsCurrentThreadDummy()) {
|
2010-01-26 09:22:21 +00:00
|
|
|
_EGLThreadInfo *t = _eglGetCurrentThread();
|
|
|
|
EGLint i;
|
|
|
|
|
|
|
|
for (i = 0; i < _EGL_API_NUM_APIS; i++) {
|
|
|
|
_EGLContext *ctx = t->CurrentContexts[i];
|
|
|
|
if (ctx) {
|
|
|
|
_EGLDisplay *disp = ctx->Resource.Display;
|
|
|
|
_EGLDriver *drv = disp->Driver;
|
2010-01-27 15:51:54 +00:00
|
|
|
(void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL);
|
2010-01-26 09:22:21 +00:00
|
|
|
}
|
2009-08-11 10:09:39 +01:00
|
|
|
}
|
2006-01-30 00:10:55 +00:00
|
|
|
}
|
2009-08-11 10:09:39 +01:00
|
|
|
|
2009-07-17 18:41:02 +01:00
|
|
|
_eglDestroyCurrentThread();
|
2006-01-30 00:10:55 +00:00
|
|
|
return EGL_TRUE;
|
|
|
|
}
|
2005-05-13 19:31:35 +01:00
|
|
|
|
|
|
|
|
2006-01-30 00:10:55 +00:00
|
|
|
#endif /* EGL_VERSION_1_2 */
|
2009-08-15 15:58:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef EGL_KHR_image_base
|
|
|
|
|
|
|
|
|
|
|
|
EGLImageKHR
|
|
|
|
eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
|
|
|
|
EGLClientBuffer buffer, const EGLint *attr_list)
|
|
|
|
{
|
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLContext *context = _eglLookupContext(ctx, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
_EGLImage *img;
|
|
|
|
|
|
|
|
drv = _eglCheckDisplay(disp, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_NO_IMAGE_KHR;
|
|
|
|
if (!context && ctx != EGL_NO_CONTEXT) {
|
|
|
|
_eglError(EGL_BAD_CONTEXT, __FUNCTION__);
|
|
|
|
return EGL_NO_IMAGE_KHR;
|
|
|
|
}
|
|
|
|
|
|
|
|
img = drv->API.CreateImageKHR(drv,
|
|
|
|
disp, context, target, buffer, attr_list);
|
|
|
|
if (img)
|
|
|
|
return _eglLinkImage(img, disp);
|
|
|
|
else
|
|
|
|
return EGL_NO_IMAGE_KHR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
|
|
|
|
{
|
|
|
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
|
|
|
_EGLImage *img = _eglLookupImage(image, disp);
|
|
|
|
_EGLDriver *drv;
|
|
|
|
|
|
|
|
drv = _eglCheckDisplay(disp, __FUNCTION__);
|
|
|
|
if (!drv)
|
|
|
|
return EGL_FALSE;
|
|
|
|
if (!img)
|
|
|
|
return _eglError(EGL_BAD_PARAMETER, __FUNCTION__);
|
|
|
|
|
|
|
|
_eglUnlinkImage(img);
|
|
|
|
return drv->API.DestroyImageKHR(drv, disp, img);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* EGL_KHR_image_base */
|