diff options
Diffstat (limited to 'src/egl/main')
-rw-r--r-- | src/egl/main/eglapi.c | 42 | ||||
-rw-r--r-- | src/egl/main/eglcontext.c | 31 | ||||
-rw-r--r-- | src/egl/main/eglcurrent.c | 15 | ||||
-rw-r--r-- | src/egl/main/eglcurrent.h | 41 |
4 files changed, 22 insertions, 107 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 4700dbe42f6..df2dcd6016f 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -1088,18 +1088,8 @@ eglWaitClient(void) 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(); } @@ -1222,7 +1212,7 @@ eglBindAPI(EGLenum api) 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); } @@ -1238,7 +1228,7 @@ eglQueryAPI(void) 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); } @@ -1271,25 +1261,17 @@ eglReleaseThread(void) /* 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(); diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index ae19862bc59..ebc004d8cf2 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -557,20 +557,16 @@ _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *c, 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; @@ -585,7 +581,6 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read) { _EGLThreadInfo *t = _eglGetCurrentThread(); _EGLDisplay *dpy; - EGLint conflict_api; if (_eglIsCurrentThreadDummy()) return _eglError(EGL_BAD_ALLOC, "eglMakeCurrent"); @@ -617,13 +612,11 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read) 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"); } @@ -644,22 +637,6 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read) 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; } diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index 835631d3ba3..345f4cc8922 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -111,7 +111,7 @@ _eglInitThreadInfo(_EGLThreadInfo *t) 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; } @@ -205,24 +205,13 @@ _eglIsCurrentThreadDummy(void) /** - * 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. */ _EGLContext * _eglGetCurrentContext(void) { _EGLThreadInfo *t = _eglGetCurrentThread(); - return t->CurrentContexts[t->CurrentAPIIndex]; + return t->CurrentContext; } diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h index 3f8a0b28e38..b922435e31f 100644 --- a/src/egl/main/eglcurrent.h +++ b/src/egl/main/eglcurrent.h @@ -46,20 +46,14 @@ extern "C" { 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; }; @@ -71,36 +65,13 @@ _eglIsApiValid(EGLenum api) { #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); @@ -114,10 +85,6 @@ _eglIsCurrentThreadDummy(void); extern _EGLContext * -_eglGetAPIContext(EGLenum api); - - -extern _EGLContext * _eglGetCurrentContext(void); |