egl: Extend per-thread info for multiple current contexts.
EGL allows multiple current contexts, as long as they are bound to different client APIs. Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
This commit is contained in:
@@ -550,11 +550,14 @@ eglBindAPI(EGLenum api)
|
|||||||
if (_eglIsCurrentThreadDummy())
|
if (_eglIsCurrentThreadDummy())
|
||||||
return _eglError(EGL_BAD_ALLOC, "eglBindAPI");
|
return _eglError(EGL_BAD_ALLOC, "eglBindAPI");
|
||||||
|
|
||||||
|
if (!_eglIsApiValid(api))
|
||||||
|
return _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
||||||
|
|
||||||
switch (api) {
|
switch (api) {
|
||||||
#ifdef EGL_VERSION_1_4
|
#ifdef EGL_VERSION_1_4
|
||||||
case EGL_OPENGL_API:
|
case EGL_OPENGL_API:
|
||||||
if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT) {
|
if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT) {
|
||||||
t->CurrentAPI = api;
|
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
}
|
}
|
||||||
_eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
_eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
||||||
@@ -562,14 +565,14 @@ eglBindAPI(EGLenum api)
|
|||||||
#endif
|
#endif
|
||||||
case EGL_OPENGL_ES_API:
|
case EGL_OPENGL_ES_API:
|
||||||
if (_eglGlobal.ClientAPIsMask & (EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT)) {
|
if (_eglGlobal.ClientAPIsMask & (EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT)) {
|
||||||
t->CurrentAPI = api;
|
t->CurrentAPIIndex = _eglConvertApiToIndex(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.ClientAPIsMask & EGL_OPENVG_BIT) {
|
if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT) {
|
||||||
t->CurrentAPI = api;
|
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
}
|
}
|
||||||
_eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
_eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
||||||
@@ -589,7 +592,7 @@ eglQueryAPI(void)
|
|||||||
{
|
{
|
||||||
/* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
|
/* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
|
||||||
_EGLThreadInfo *t = _eglGetCurrentThread();
|
_EGLThreadInfo *t = _eglGetCurrentThread();
|
||||||
return t->CurrentAPI;
|
return _eglConvertApiFromIndex(t->CurrentAPIIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -203,10 +203,10 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
|||||||
_EGLContext *ctx = _eglLookupContext(context);
|
_EGLContext *ctx = _eglLookupContext(context);
|
||||||
_EGLSurface *draw = _eglLookupSurface(d);
|
_EGLSurface *draw = _eglLookupSurface(d);
|
||||||
_EGLSurface *read = _eglLookupSurface(r);
|
_EGLSurface *read = _eglLookupSurface(r);
|
||||||
|
_EGLContext *oldContext = NULL;
|
||||||
_EGLContext *oldContext = _eglGetCurrentContext();
|
_EGLSurface *oldDrawSurface = NULL;
|
||||||
_EGLSurface *oldDrawSurface = _eglGetCurrentSurface(EGL_DRAW);
|
_EGLSurface *oldReadSurface = NULL;
|
||||||
_EGLSurface *oldReadSurface = _eglGetCurrentSurface(EGL_READ);
|
EGLint apiIndex;
|
||||||
|
|
||||||
if (_eglIsCurrentThreadDummy())
|
if (_eglIsCurrentThreadDummy())
|
||||||
return _eglError(EGL_BAD_ALLOC, "eglMakeCurrent");
|
return _eglError(EGL_BAD_ALLOC, "eglMakeCurrent");
|
||||||
@@ -225,6 +225,32 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
|||||||
_eglError(EGL_BAD_MATCH, "eglMakeCurrent");
|
_eglError(EGL_BAD_MATCH, "eglMakeCurrent");
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef EGL_VERSION_1_4
|
||||||
|
/* OpenGL and OpenGL ES are conflicting */
|
||||||
|
switch (ctx->ClientAPI) {
|
||||||
|
case EGL_OPENGL_ES_API:
|
||||||
|
if (t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_API)])
|
||||||
|
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
|
||||||
|
break;
|
||||||
|
case EGL_OPENGL_API:
|
||||||
|
if (t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_ES_API)])
|
||||||
|
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
apiIndex = _eglConvertApiToIndex(ctx->ClientAPI);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
apiIndex = t->CurrentAPIIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
oldContext = t->CurrentContexts[apiIndex];
|
||||||
|
if (oldContext) {
|
||||||
|
oldDrawSurface = oldContext->DrawSurface;
|
||||||
|
oldReadSurface = oldContext->ReadSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -275,9 +301,11 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
|||||||
ctx->IsBound = EGL_TRUE;
|
ctx->IsBound = EGL_TRUE;
|
||||||
draw->IsBound = EGL_TRUE;
|
draw->IsBound = EGL_TRUE;
|
||||||
read->IsBound = EGL_TRUE;
|
read->IsBound = EGL_TRUE;
|
||||||
|
t->CurrentContexts[apiIndex] = ctx;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
t->CurrentContexts[apiIndex] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
t->CurrentContext = ctx;
|
|
||||||
|
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user