egl: Allow binding to any client API.
As a result, EGL_NONE is no longer a valid client API. And it is possible that no config supports the current bound API. Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
This commit is contained in:
@@ -92,8 +92,8 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
|
|||||||
snprintf(disp->Version, sizeof(disp->Version),
|
snprintf(disp->Version, sizeof(disp->Version),
|
||||||
"%d.%d (%s)", major_int, minor_int, drv->Name);
|
"%d.%d (%s)", major_int, minor_int, drv->Name);
|
||||||
|
|
||||||
/* update the global notion of supported APIs */
|
/* limit to APIs supported by core */
|
||||||
_eglGlobal.ClientAPIsMask |= disp->ClientAPIsMask;
|
disp->ClientAPIsMask &= _EGL_API_ALL_BITS;
|
||||||
|
|
||||||
disp->Driver = drv;
|
disp->Driver = drv;
|
||||||
} else {
|
} else {
|
||||||
@@ -842,35 +842,9 @@ eglBindAPI(EGLenum api)
|
|||||||
if (!_eglIsApiValid(api))
|
if (!_eglIsApiValid(api))
|
||||||
return _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
return _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
||||||
|
|
||||||
switch (api) {
|
|
||||||
#ifdef EGL_VERSION_1_4
|
|
||||||
case EGL_OPENGL_API:
|
|
||||||
if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT) {
|
|
||||||
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
|
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
}
|
}
|
||||||
_eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
|
||||||
return EGL_FALSE;
|
|
||||||
#endif
|
|
||||||
case EGL_OPENGL_ES_API:
|
|
||||||
if (_eglGlobal.ClientAPIsMask & (EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT)) {
|
|
||||||
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
_eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
|
||||||
return EGL_FALSE;
|
|
||||||
case EGL_OPENVG_API:
|
|
||||||
if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT) {
|
|
||||||
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
_eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
|
||||||
return EGL_FALSE;
|
|
||||||
default:
|
|
||||||
return EGL_FALSE;
|
|
||||||
}
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
/* This should be kept in sync with _eglInitThreadInfo() */
|
/* This should be kept in sync with _eglInitThreadInfo() */
|
||||||
#define _EGL_THREAD_INFO_INITIALIZER \
|
#define _EGL_THREAD_INFO_INITIALIZER \
|
||||||
{ EGL_SUCCESS, { NULL }, 1 }
|
{ EGL_SUCCESS, { NULL }, 0 }
|
||||||
|
|
||||||
/* a fallback thread info to guarantee that every thread always has one */
|
/* a fallback thread info to guarantee that every thread always has one */
|
||||||
static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
|
static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
|
||||||
|
@@ -4,8 +4,16 @@
|
|||||||
#include "egltypedefs.h"
|
#include "egltypedefs.h"
|
||||||
|
|
||||||
|
|
||||||
#define _EGL_API_NUM_INDICES \
|
#define _EGL_API_ALL_BITS \
|
||||||
(EGL_OPENGL_API - EGL_OPENGL_ES_API + 2) /* idx 0 is for EGL_NONE */
|
(EGL_OPENGL_ES_BIT | \
|
||||||
|
EGL_OPENVG_BIT | \
|
||||||
|
EGL_OPENGL_ES2_BIT | \
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,20 +22,19 @@
|
|||||||
struct _egl_thread_info
|
struct _egl_thread_info
|
||||||
{
|
{
|
||||||
EGLint LastError;
|
EGLint LastError;
|
||||||
_EGLContext *CurrentContexts[_EGL_API_NUM_INDICES];
|
_EGLContext *CurrentContexts[_EGL_API_NUM_APIS];
|
||||||
/* use index for fast access to current context */
|
/* use index for fast access to current context */
|
||||||
EGLint CurrentAPIIndex;
|
EGLint CurrentAPIIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if a client API enum can be converted to an index.
|
* Return true if a client API enum is recognized.
|
||||||
*/
|
*/
|
||||||
static INLINE EGLBoolean
|
static INLINE EGLBoolean
|
||||||
_eglIsApiValid(EGLenum api)
|
_eglIsApiValid(EGLenum api)
|
||||||
{
|
{
|
||||||
return ((api >= EGL_OPENGL_ES_API && api <= EGL_OPENGL_API) ||
|
return (api >= _EGL_API_FIRST_API && api <= _EGL_API_LAST_API);
|
||||||
api == EGL_NONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -38,7 +45,7 @@ _eglIsApiValid(EGLenum api)
|
|||||||
static INLINE EGLint
|
static INLINE EGLint
|
||||||
_eglConvertApiToIndex(EGLenum api)
|
_eglConvertApiToIndex(EGLenum api)
|
||||||
{
|
{
|
||||||
return (api != EGL_NONE) ? api - EGL_OPENGL_ES_API + 1 : 0;
|
return api - _EGL_API_FIRST_API;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -49,7 +56,7 @@ _eglConvertApiToIndex(EGLenum api)
|
|||||||
static INLINE EGLenum
|
static INLINE EGLenum
|
||||||
_eglConvertApiFromIndex(EGLint idx)
|
_eglConvertApiFromIndex(EGLint idx)
|
||||||
{
|
{
|
||||||
return (idx) ? EGL_OPENGL_ES_API + idx - 1 : EGL_NONE;
|
return _EGL_API_FIRST_API + idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@ struct _egl_global _eglGlobal =
|
|||||||
&_eglGlobalMutex, /* Mutex */
|
&_eglGlobalMutex, /* Mutex */
|
||||||
NULL, /* DisplayList */
|
NULL, /* DisplayList */
|
||||||
1, /* FreeScreenHandle */
|
1, /* FreeScreenHandle */
|
||||||
0x0, /* ClientAPIsMask */
|
|
||||||
0, /* NumDrivers */
|
0, /* NumDrivers */
|
||||||
{ NULL }, /* Drivers */
|
{ NULL }, /* Drivers */
|
||||||
2, /* NumAtExitCalls */
|
2, /* NumAtExitCalls */
|
||||||
|
@@ -19,9 +19,6 @@ struct _egl_global
|
|||||||
|
|
||||||
EGLScreenMESA FreeScreenHandle;
|
EGLScreenMESA FreeScreenHandle;
|
||||||
|
|
||||||
/* bitmaks of supported APIs (supported by _some_ driver) */
|
|
||||||
EGLint ClientAPIsMask;
|
|
||||||
|
|
||||||
EGLint NumDrivers;
|
EGLint NumDrivers;
|
||||||
_EGLDriver *Drivers[10];
|
_EGLDriver *Drivers[10];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user