EGLBoolean EGLAPIENTRY
eglWaitGL(void)
{
- _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_EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_FALSE);
-
- t->CurrentAPIIndex = es_index;
- ret = eglWaitClient();
- t->CurrentAPIIndex = api_index;
- return ret;
+ /* Since we only support OpenGL and GLES, eglWaitGL is equivalent to eglWaitClient. */
+ return eglWaitClient();
}
if (!_eglIsApiValid(api))
RETURN_EGL_ERROR(NULL, EGL_BAD_PARAMETER, EGL_FALSE);
- t->CurrentAPIIndex = _eglConvertApiToIndex(api);
+ t->CurrentAPI = api;
RETURN_EGL_SUCCESS(NULL, EGL_TRUE);
}
EGLenum ret;
/* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
- ret = _eglConvertApiFromIndex(t->CurrentAPIIndex);
+ ret = t->CurrentAPI;
RETURN_EGL_SUCCESS(NULL, ret);
}
/* unbind current contexts */
if (!_eglIsCurrentThreadDummy()) {
_EGLThreadInfo *t = _eglGetCurrentThread();
- EGLint api_index = t->CurrentAPIIndex;
- 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;
- t->CurrentAPIIndex = i;
+ _EGLContext *ctx = t->CurrentContext;
+ if (ctx) {
+ _EGLDisplay *disp = ctx->Resource.Display;
+ _EGLDriver *drv;
- mtx_lock(&disp->Mutex);
- drv = disp->Driver;
- (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL);
- mtx_unlock(&disp->Mutex);
- }
+ mtx_lock(&disp->Mutex);
+ drv = disp->Driver;
+ (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL);
+ mtx_unlock(&disp->Mutex);
}
-
- t->CurrentAPIIndex = api_index;
}
_eglDestroyCurrentThread();
static _EGLContext *
_eglBindContextToThread(_EGLContext *ctx, _EGLThreadInfo *t)
{
- EGLint apiIndex;
_EGLContext *oldCtx;
- apiIndex = (ctx) ?
- _eglConvertApiToIndex(ctx->ClientAPI) : t->CurrentAPIIndex;
-
- oldCtx = t->CurrentContexts[apiIndex];
+ oldCtx = t->CurrentContext;
if (ctx != oldCtx) {
if (oldCtx)
oldCtx->Binding = NULL;
if (ctx)
ctx->Binding = t;
- t->CurrentContexts[apiIndex] = ctx;
+ t->CurrentContext = ctx;
}
return oldCtx;
{
_EGLThreadInfo *t = _eglGetCurrentThread();
_EGLDisplay *dpy;
- EGLint conflict_api;
if (_eglIsCurrentThreadDummy())
return _eglError(EGL_BAD_ALLOC, "eglMakeCurrent");
if (ctx->Binding && ctx->Binding != t)
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
if (draw && draw->CurrentContext && draw->CurrentContext != ctx) {
- if (draw->CurrentContext->Binding != t ||
- draw->CurrentContext->ClientAPI != ctx->ClientAPI)
+ if (draw->CurrentContext->Binding != t)
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
}
if (read && read->CurrentContext && read->CurrentContext != ctx) {
- if (read->CurrentContext->Binding != t ||
- read->CurrentContext->ClientAPI != ctx->ClientAPI)
+ if (read->CurrentContext->Binding != t)
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
}
return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
}
- switch (ctx->ClientAPI) {
- /* OpenGL and OpenGL ES are conflicting */
- case EGL_OPENGL_ES_API:
- conflict_api = EGL_OPENGL_API;
- break;
- case EGL_OPENGL_API:
- conflict_api = EGL_OPENGL_ES_API;
- break;
- default:
- conflict_api = -1;
- break;
- }
-
- if (conflict_api >= 0 && _eglGetAPIContext(conflict_api))
- return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
-
return EGL_TRUE;
}
memset(t, 0, sizeof(*t));
t->LastError = EGL_SUCCESS;
/* default, per EGL spec */
- t->CurrentAPIIndex = _eglConvertApiToIndex(EGL_OPENGL_ES_API);
+ t->CurrentAPI = EGL_OPENGL_ES_API;
}
}
-/**
- * Return the currently bound context of the given API, or NULL.
- */
-_EGLContext *
-_eglGetAPIContext(EGLenum api)
-{
- _EGLThreadInfo *t = _eglGetCurrentThread();
- return t->CurrentContexts[_eglConvertApiToIndex(api)];
-}
-
-
/**
* Return the currently bound context of the current API, or NULL.
*/
_eglGetCurrentContext(void)
{
_EGLThreadInfo *t = _eglGetCurrentThread();
- return t->CurrentContexts[t->CurrentAPIIndex];
+ return t->CurrentContext;
}
EGL_OPENGL_BIT)
-#define _EGL_API_FIRST_API EGL_OPENGL_ES_API
-#define _EGL_API_LAST_API EGL_OPENGL_API
-#define _EGL_API_NUM_APIS (_EGL_API_LAST_API - _EGL_API_FIRST_API + 1)
-
-
/**
* Per-thread info
*/
struct _egl_thread_info
{
EGLint LastError;
- _EGLContext *CurrentContexts[_EGL_API_NUM_APIS];
- /* use index for fast access to current context */
- EGLint CurrentAPIIndex;
+ _EGLContext *CurrentContext;
+ EGLenum CurrentAPI;
};
{
#ifdef ANDROID
/* OpenGL is not a valid/supported API on Android */
- return api >= _EGL_API_FIRST_API && api <= _EGL_API_LAST_API &&
- api != EGL_OPENGL_API;
+ return api == EGL_OPENGL_ES_API;
#else
- return api >= _EGL_API_FIRST_API && api <= _EGL_API_LAST_API;
+ return (api == EGL_OPENGL_ES_API || api == EGL_OPENGL_API);
#endif
}
-/**
- * Convert a client API enum to an index, for use by thread info.
- * The client API enum is assumed to be valid.
- */
-static inline EGLint
-_eglConvertApiToIndex(EGLenum api)
-{
- return api - _EGL_API_FIRST_API;
-}
-
-
-/**
- * Convert an index, used by thread info, to a client API enum.
- * The index is assumed to be valid.
- */
-static inline EGLenum
-_eglConvertApiFromIndex(EGLint idx)
-{
- return _EGL_API_FIRST_API + idx;
-}
-
-
extern _EGLThreadInfo *
_eglGetCurrentThread(void);
_eglIsCurrentThreadDummy(void);
-extern _EGLContext *
-_eglGetAPIContext(EGLenum api);
-
-
extern _EGLContext *
_eglGetCurrentContext(void);