eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
{
_EGLDisplay *disp = _eglLookupDisplay(dpy);
- _EGLDriver *drv;
EGLint major_int, minor_int;
if (!disp)
return _eglError(EGL_BAD_DISPLAY, __FUNCTION__);
- drv = disp->Driver;
- if (!drv) {
- _eglPreloadDrivers();
+ if (!disp->Initialized) {
+ _EGLDriver *drv = disp->Driver;
- drv = _eglMatchDriver(disp);
- if (!drv)
- return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__);
+ if (!drv) {
+ _eglPreloadDrivers();
+ drv = _eglMatchDriver(disp);
+ if (!drv)
+ return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__);
+ }
/* Initialize the particular display now */
if (!drv->API.Initialize(drv, disp, &major_int, &minor_int))
disp->ClientAPIsMask &= _EGL_API_ALL_BITS;
disp->Driver = drv;
+ disp->Initialized = EGL_TRUE;
} else {
major_int = disp->APImajor;
minor_int = disp->APIminor;
eglTerminate(EGLDisplay dpy)
{
_EGLDisplay *disp = _eglLookupDisplay(dpy);
- _EGLDriver *drv;
if (!disp)
return _eglError(EGL_BAD_DISPLAY, __FUNCTION__);
- drv = disp->Driver;
- if (drv) {
+ if (disp->Initialized) {
+ _EGLDriver *drv = disp->Driver;
+
drv->API.Terminate(drv, disp);
- disp->Driver = NULL;
+ /* do not reset disp->Driver */
+ disp->Initialized = EGL_FALSE;
}
return EGL_TRUE;
_eglError(EGL_BAD_DISPLAY, msg);
return NULL;
}
- if (!disp->Driver) {
+ if (!disp->Initialized) {
_eglError(EGL_NOT_INITIALIZED, msg);
return NULL;
}
/* a valid current context implies an initialized current display */
disp = ctx->Resource.Display;
+ assert(disp->Initialized);
drv = disp->Driver;
- assert(drv);
return drv->API.WaitClient(drv, disp, ctx);
}
/* a valid current context implies an initialized current display */
disp = ctx->Resource.Display;
+ assert(disp->Initialized);
drv = disp->Driver;
- assert(drv);
return drv->API.WaitNative(drv, disp, engine);
}
if (ctx) {
_EGLDisplay *disp = ctx->Resource.Display;
_EGLDriver *drv = disp->Driver;
- /* what if drv is not avaialbe? */
- if (drv)
+ /* what if display is not initialized? */
+ if (disp->Initialized)
(void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL);
}
}