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