_EGLDriver *best_drv = NULL;
EGLint best_score = -1, i;
+ /*
+ * this function is called after preloading and the drivers never change
+ * after preloading.
+ */
for (i = 0; i < _eglGlobal.NumDrivers; i++) {
_EGLDriver *drv = _eglGlobal.Drivers[i];
EGLint score;
{
EGLBoolean loaded;
+ /* protect the preloading process */
+ _eglLockMutex(_eglGlobal.Mutex);
+
/* already preloaded */
- if (_eglGlobal.NumDrivers)
+ if (_eglGlobal.NumDrivers) {
+ _eglUnlockMutex(_eglGlobal.Mutex);
return EGL_TRUE;
+ }
loaded = (_eglPreloadUserDriver() ||
_eglPreloadDisplayDrivers() ||
_eglPreloadDefaultDriver());
+ _eglUnlockMutex(_eglGlobal.Mutex);
+
return loaded;
}
_eglUnloadDrivers(void)
{
EGLint i;
+
+ /* this is called at atexit time */
for (i = 0; i < _eglGlobal.NumDrivers; i++) {
_EGLDriver *drv = _eglGlobal.Drivers[i];
lib_handle handle = drv->LibHandle;
#include "eglconfig.h"
#include "eglsurface.h"
#include "eglscreen.h"
+#include "eglmutex.h"
/**
* Return a new screen handle/ID.
* NOTE: we never reuse these!
*/
-EGLScreenMESA
+static EGLScreenMESA
_eglAllocScreenHandle(void)
{
- EGLScreenMESA s = _eglGlobal.FreeScreenHandle;
- _eglGlobal.FreeScreenHandle++;
+ EGLScreenMESA s;
+
+ _eglLockMutex(_eglGlobal.Mutex);
+ s = _eglGlobal.FreeScreenHandle++;
+ _eglUnlockMutex(_eglGlobal.Mutex);
+
return s;
}