According to the EGL specifications before binding an API we must check whether it's supported first. If not eglBindAPI should return EGL_FALSE and generate a EGL_BAD_PARAMETER error.
Signed-off-by: Plamena Manolova <plamena.manol...@intel.com> --- src/egl/main/eglcurrent.h | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h index 1e386ac..f2e19cc 100644 --- a/src/egl/main/eglcurrent.h +++ b/src/egl/main/eglcurrent.h @@ -32,7 +32,8 @@ #include "c99_compat.h" #include "egltypedefs.h" - +#include "eglglobals.h" +#include "egldisplay.h" #ifdef __cplusplus extern "C" { @@ -62,14 +63,40 @@ struct _egl_thread_info EGLint CurrentAPIIndex; }; - +static inline EGLBoolean +_eglDisplaySupportsApi(_EGLDisplay *dpy, EGLenum api) +{ + if (!dpy->Initialized) { + return EGL_FALSE; + } else if (api == EGL_OPENGL_API && dpy->ClientAPIs & EGL_OPENGL_BIT) { + return EGL_TRUE; + } else if (api == EGL_OPENGL_ES_API && + (dpy->ClientAPIs & EGL_OPENGL_ES_BIT || + dpy->ClientAPIs & EGL_OPENGL_ES2_BIT || + dpy->ClientAPIs & EGL_OPENGL_ES3_BIT_KHR)) { + return EGL_TRUE; + } else if (api == EGL_OPENVG_API && dpy->ClientAPIs & EGL_OPENVG_BIT) { + return EGL_TRUE; + } else { + return EGL_FALSE; + } +} /** * Return true if a client API enum is recognized. */ static inline EGLBoolean _eglIsApiValid(EGLenum api) { - return (api >= _EGL_API_FIRST_API && api <= _EGL_API_LAST_API); + _EGLDisplay *dpy = _eglGlobal.DisplayList; + + while (dpy) { + if (_eglDisplaySupportsApi(dpy, api) == EGL_TRUE) + return EGL_TRUE; + + dpy = dpy->Next; + } + + return EGL_FALSE; } -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev