summaryrefslogtreecommitdiff
path: root/src/egl/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl/main')
-rw-r--r--src/egl/main/eglapi.c18
-rw-r--r--src/egl/main/eglapi.h1
-rw-r--r--src/egl/main/eglcontext.c23
3 files changed, 27 insertions, 15 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 2c26dfada8..d0f9749f84 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -394,9 +394,19 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read,
_EGLSurface *read_surf = _eglLookupSurface(read, disp);
_EGLDriver *drv;
- drv = _eglCheckDisplay(disp, __FUNCTION__);
+ if (!disp)
+ return _eglError(EGL_BAD_DISPLAY, __FUNCTION__);
+ drv = disp->Driver;
+
+ /* display is allowed to be uninitialized under certain condition */
+ if (!disp->Initialized) {
+ if (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE ||
+ ctx != EGL_NO_CONTEXT)
+ return _eglError(EGL_BAD_DISPLAY, __FUNCTION__);
+ }
if (!drv)
- return EGL_FALSE;
+ return EGL_TRUE;
+
if (!context && ctx != EGL_NO_CONTEXT)
return _eglError(EGL_BAD_CONTEXT, __FUNCTION__);
if ((!draw_surf && draw != EGL_NO_SURFACE) ||
@@ -994,9 +1004,7 @@ eglReleaseThread(void)
if (ctx) {
_EGLDisplay *disp = ctx->Resource.Display;
_EGLDriver *drv = disp->Driver;
- /* what if display is not initialized? */
- if (disp->Initialized)
- (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL);
+ (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL);
}
}
}
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index db31c7cf93..a7600820f3 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -23,6 +23,7 @@ typedef EGLBoolean (*GetConfigAttrib_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLC
/* context funcs */
typedef _EGLContext *(*CreateContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, _EGLContext *share_list, const EGLint *attrib_list);
typedef EGLBoolean (*DestroyContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx);
+/* this is the only function (other than Initialize) that may be called with an uninitialized display */
typedef EGLBoolean (*MakeCurrent_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx);
typedef EGLBoolean (*QueryContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value);
diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index 4a9a47204c..60d2efd44b 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -321,16 +321,19 @@ _eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw,
if (!_eglBindContext(&ctx, &draw, &read))
return EGL_FALSE;
- /* avoid double destroy */
- if (read && read == draw)
- read = NULL;
-
- if (ctx && !_eglIsContextLinked(ctx))
- drv->API.DestroyContext(drv, dpy, ctx);
- if (draw && !_eglIsSurfaceLinked(draw))
- drv->API.DestroySurface(drv, dpy, draw);
- if (read && !_eglIsSurfaceLinked(read))
- drv->API.DestroySurface(drv, dpy, read);
+ /* nothing we can do if the display is uninitialized */
+ if (dpy->Initialized) {
+ /* avoid double destroy */
+ if (read && read == draw)
+ read = NULL;
+
+ if (ctx && !_eglIsContextLinked(ctx))
+ drv->API.DestroyContext(drv, dpy, ctx);
+ if (draw && !_eglIsSurfaceLinked(draw))
+ drv->API.DestroySurface(drv, dpy, draw);
+ if (read && !_eglIsSurfaceLinked(read))
+ drv->API.DestroySurface(drv, dpy, read);
+ }
return EGL_TRUE;
}