egl: clean-up re-org of the client API state
This commit is contained in:
parent
52676207e3
commit
d5078b9432
|
@ -517,6 +517,18 @@ eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode)
|
|||
|
||||
#ifdef EGL_VERSION_1_2
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
EGLBoolean
|
||||
eglBindAPI(EGLenum api)
|
||||
{
|
||||
|
@ -525,7 +537,7 @@ eglBindAPI(EGLenum api)
|
|||
switch (api) {
|
||||
#ifdef EGL_VERSION_1_4
|
||||
case EGL_OPENGL_API:
|
||||
if (_eglGlobal.OpenGLAPISupported) {
|
||||
if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT) {
|
||||
t->CurrentAPI = api;
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
@ -533,14 +545,14 @@ eglBindAPI(EGLenum api)
|
|||
return EGL_FALSE;
|
||||
#endif
|
||||
case EGL_OPENGL_ES_API:
|
||||
if (_eglGlobal.OpenGLESAPISupported) {
|
||||
if (_eglGlobal.ClientAPIsMask & (EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT)) {
|
||||
t->CurrentAPI = api;
|
||||
return EGL_TRUE;
|
||||
}
|
||||
_eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
||||
return EGL_FALSE;
|
||||
case EGL_OPENVG_API:
|
||||
if (_eglGlobal.OpenVGAPISupported) {
|
||||
if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT) {
|
||||
t->CurrentAPI = api;
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
@ -553,6 +565,18 @@ eglBindAPI(EGLenum api)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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();
|
||||
return t->CurrentAPI;
|
||||
}
|
||||
|
||||
|
||||
EGLSurface
|
||||
eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype,
|
||||
EGLClientBuffer buffer, EGLConfig config,
|
||||
|
@ -564,15 +588,6 @@ eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype,
|
|||
}
|
||||
|
||||
|
||||
EGLenum
|
||||
eglQueryAPI(void)
|
||||
{
|
||||
/* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
|
||||
_EGLThreadInfo *t = _eglGetCurrentThread();
|
||||
return t->CurrentAPI;
|
||||
}
|
||||
|
||||
|
||||
EGLBoolean
|
||||
eglReleaseThread(void)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,12 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx,
|
|||
_EGLConfig *conf;
|
||||
_EGLDisplay *display = _eglLookupDisplay(dpy);
|
||||
EGLint i;
|
||||
const EGLenum api = eglQueryAPI();
|
||||
|
||||
if (api == EGL_NONE) {
|
||||
_eglError(EGL_BAD_MATCH, "eglCreateContext(no client API)");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
conf = _eglLookupConfig(drv, dpy, config);
|
||||
if (!conf) {
|
||||
|
@ -30,7 +36,8 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx,
|
|||
for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
|
||||
switch (attrib_list[i]) {
|
||||
case EGL_CONTEXT_CLIENT_VERSION:
|
||||
/* xxx todo */
|
||||
i++;
|
||||
ctx->ClientVersion = attrib_list[i];
|
||||
break;
|
||||
default:
|
||||
_eglError(EGL_BAD_ATTRIBUTE, "_eglInitContext");
|
||||
|
@ -43,6 +50,7 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx,
|
|||
ctx->Config = conf;
|
||||
ctx->DrawSurface = EGL_NO_SURFACE;
|
||||
ctx->ReadSurface = EGL_NO_SURFACE;
|
||||
ctx->ClientAPI = api;
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ struct _egl_context
|
|||
|
||||
EGLBoolean IsBound;
|
||||
EGLBoolean DeletePending;
|
||||
#ifdef EGL_VERSION_1_2
|
||||
EGLint ClientAPI; /* Either EGL_OPENGL_ES_API or EGL_OPENVG_API */
|
||||
#endif /* EGL_VERSION_1_2 */
|
||||
|
||||
EGLint ClientAPI; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API */
|
||||
EGLint ClientVersion; /**< 1 = OpenGLES 1.x, 2 = OpenGLES 2.x */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -97,12 +97,12 @@ _eglChooseDriver(_EGLDisplay *dpy)
|
|||
if (driverName)
|
||||
return _eglstrdup(driverName);
|
||||
|
||||
|
||||
#if 0
|
||||
if (!displayString) {
|
||||
/* choose a default */
|
||||
displayString = DefaultDriverName;
|
||||
}
|
||||
|
||||
#endif
|
||||
/* extract default DriverArgs = whatever follows ':' */
|
||||
if (displayString &&
|
||||
(displayString[0] == '!' ||
|
||||
|
@ -192,6 +192,9 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args)
|
|||
else
|
||||
dlclose(lib);
|
||||
|
||||
/* update the global notion of supported APIs */
|
||||
_eglGlobal.ClientAPIsMask |= drv->ClientAPIsMask;
|
||||
|
||||
return drv;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ struct _egl_driver
|
|||
int APImajor, APIminor; /**< as returned by eglInitialize() */
|
||||
char Version[1000]; /**< initialized from APImajor/minor, Name */
|
||||
|
||||
const char *ClientAPIs;
|
||||
/** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
|
||||
EGLint ClientAPIsMask;
|
||||
|
||||
_EGLAPI API; /**< EGL API dispatch table */
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ _eglInitGlobals(void)
|
|||
_eglGlobal.FreeScreenHandle = 1;
|
||||
_eglGlobal.Initialized = EGL_TRUE;
|
||||
|
||||
_eglGlobal.OpenGLESAPISupported = EGL_TRUE;
|
||||
_eglGlobal.OpenVGAPISupported = EGL_FALSE;
|
||||
_eglGlobal.ClientAPIsMask = 0x0;
|
||||
|
||||
/* XXX temporary */
|
||||
_eglGlobal.ThreadInfo = _eglNewThreadInfo();
|
||||
|
|
|
@ -28,10 +28,10 @@ struct _egl_global
|
|||
|
||||
EGLScreenMESA FreeScreenHandle;
|
||||
|
||||
/* XXX these may be temporary */
|
||||
EGLBoolean OpenGLAPISupported;
|
||||
EGLBoolean OpenGLESAPISupported;
|
||||
EGLBoolean OpenVGAPISupported;
|
||||
/* bitmaks of supported APIs (supported by _some_ driver) */
|
||||
EGLint ClientAPIsMask;
|
||||
|
||||
char ClientAPIs[1000]; /**< updated by eglQueryString */
|
||||
|
||||
/* XXX temporary - should be thread-specific data (TSD) */
|
||||
_EGLThreadInfo *ThreadInfo;
|
||||
|
|
|
@ -54,6 +54,27 @@ _eglUpdateExtensionsString(_EGLDriver *drv)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
_eglUpdateAPIsString(_EGLDriver *drv)
|
||||
{
|
||||
_eglGlobal.ClientAPIs[0] = 0;
|
||||
|
||||
if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT)
|
||||
strcat(_eglGlobal.ClientAPIs, "OpenGL ");
|
||||
|
||||
if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_ES_BIT)
|
||||
strcat(_eglGlobal.ClientAPIs, "OpenGL_ES ");
|
||||
|
||||
if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_ES2_BIT)
|
||||
strcat(_eglGlobal.ClientAPIs, "OpenGL_ES2 ");
|
||||
|
||||
if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT)
|
||||
strcat(_eglGlobal.ClientAPIs, "OpenVG ");
|
||||
|
||||
assert(strlen(_eglGlobal.ClientAPIs) < sizeof(_eglGlobal.ClientAPIs));
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
_eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name)
|
||||
|
@ -70,8 +91,8 @@ _eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name)
|
|||
return drv->Extensions.String;
|
||||
#ifdef EGL_VERSION_1_2
|
||||
case EGL_CLIENT_APIS:
|
||||
/* XXX need to initialize somewhere */
|
||||
return drv->ClientAPIs;
|
||||
_eglUpdateAPIsString(drv);
|
||||
return _eglGlobal.ClientAPIs;
|
||||
#endif
|
||||
default:
|
||||
_eglError(EGL_BAD_PARAMETER, "eglQueryString");
|
||||
|
|
Loading…
Reference in New Issue