Commit 27c1ec23348d55da55923f88ffb94268cbbb43b4

  • avatar
  • Chia-I Wu <olvaffe @gm…l.com>
  • Tue Sep 29 12:33:53 CEST 2009
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.
  
9393 snprintf(disp->Version, sizeof(disp->Version),
9494 "%d.%d (%s)", major_int, minor_int, drv->Name);
9595
96 /* update the global notion of supported APIs */
97 _eglGlobal.ClientAPIsMask |= disp->ClientAPIsMask;
96 /* limit to APIs supported by core */
97 disp->ClientAPIsMask &= _EGL_API_ALL_BITS;
9898
9999 disp->Driver = drv;
100100 } else {
876876 if (!_eglIsApiValid(api))
877877 return _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
878878
879 switch (api) {
880#ifdef EGL_VERSION_1_4
881 case EGL_OPENGL_API:
882 if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT) {
883 t->CurrentAPIIndex = _eglConvertApiToIndex(api);
884 return EGL_TRUE;
885 }
886 _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
887 return EGL_FALSE;
888#endif
889 case EGL_OPENGL_ES_API:
890 if (_eglGlobal.ClientAPIsMask & (EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT)) {
891 t->CurrentAPIIndex = _eglConvertApiToIndex(api);
892 return EGL_TRUE;
893 }
894 _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
895 return EGL_FALSE;
896 case EGL_OPENVG_API:
897 if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT) {
898 t->CurrentAPIIndex = _eglConvertApiToIndex(api);
899 return EGL_TRUE;
900 }
901 _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
902 return EGL_FALSE;
903 default:
904 return EGL_FALSE;
905 }
879 t->CurrentAPIIndex = _eglConvertApiToIndex(api);
906880 return EGL_TRUE;
907881}
908882
  
99
1010/* This should be kept in sync with _eglInitThreadInfo() */
1111#define _EGL_THREAD_INFO_INITIALIZER \
12 { EGL_SUCCESS, { NULL }, 1 }
12 { EGL_SUCCESS, { NULL }, 0 }
1313
1414/* a fallback thread info to guarantee that every thread always has one */
1515static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
  
44#include "egltypedefs.h"
55
66
7#define _EGL_API_NUM_INDICES \
8 (EGL_OPENGL_API - EGL_OPENGL_ES_API + 2) /* idx 0 is for EGL_NONE */
7#define _EGL_API_ALL_BITS \
8 (EGL_OPENGL_ES_BIT | \
9 EGL_OPENVG_BIT | \
10 EGL_OPENGL_ES2_BIT | \
11 EGL_OPENGL_BIT)
912
1013
14#define _EGL_API_FIRST_API EGL_OPENGL_ES_API
15#define _EGL_API_LAST_API EGL_OPENGL_API
16#define _EGL_API_NUM_APIS (_EGL_API_LAST_API - _EGL_API_FIRST_API + 1)
17
18
1119/**
1220 * Per-thread info
1321 */
1422struct _egl_thread_info
1523{
1624 EGLint LastError;
17 _EGLContext *CurrentContexts[_EGL_API_NUM_INDICES];
25 _EGLContext *CurrentContexts[_EGL_API_NUM_APIS];
1826 /* use index for fast access to current context */
1927 EGLint CurrentAPIIndex;
2028};
2129
2230
2331/**
24 * Return true if a client API enum can be converted to an index.
32 * Return true if a client API enum is recognized.
2533 */
2634static INLINE EGLBoolean
2735_eglIsApiValid(EGLenum api)
2836{
29 return ((api >= EGL_OPENGL_ES_API && api <= EGL_OPENGL_API) ||
30 api == EGL_NONE);
37 return (api >= _EGL_API_FIRST_API && api <= _EGL_API_LAST_API);
3138}
3239
3340
4545static INLINE EGLint
4646_eglConvertApiToIndex(EGLenum api)
4747{
48 return (api != EGL_NONE) ? api - EGL_OPENGL_ES_API + 1 : 0;
48 return api - _EGL_API_FIRST_API;
4949}
5050
5151
5656static INLINE EGLenum
5757_eglConvertApiFromIndex(EGLint idx)
5858{
59 return (idx) ? EGL_OPENGL_ES_API + idx - 1 : EGL_NONE;
59 return _EGL_API_FIRST_API + idx;
6060}
6161
6262
  
1515 &_eglGlobalMutex, /* Mutex */
1616 NULL, /* DisplayList */
1717 1, /* FreeScreenHandle */
18 0x0, /* ClientAPIsMask */
1918 0, /* NumDrivers */
2019 { NULL }, /* Drivers */
2120 2, /* NumAtExitCalls */
  
1919
2020 EGLScreenMESA FreeScreenHandle;
2121
22 /* bitmaks of supported APIs (supported by _some_ driver) */
23 EGLint ClientAPIsMask;
24
2522 EGLint NumDrivers;
2623 _EGLDriver *Drivers[10];
2724