diff options
| author | Andri Yngvason <andri@yngvason.is> | 2020-07-13 18:45:57 +0000 | 
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2020-07-14 19:55:20 +0200 | 
| commit | 6ef5d18757ef5ae2f38d41d914f7d7df100e3799 (patch) | |
| tree | 5c65d96fc7ac33aabb494a0327b4da4f21a3b743 | |
| parent | 842df2bd6c940c5f4933622987fc9a296f404d67 (diff) | |
| download | wlroots-6ef5d18757ef5ae2f38d41d914f7d7df100e3799.tar.xz | |
render: egl: Use current display to restore NULL context
eglGetCurrentDisplay() returns EGL_NO_DISPLAY when there is no context current
and eglMakeCurrent() needs a display argument.
Fixes #2327
| -rw-r--r-- | render/egl.c | 15 | 
1 files changed, 14 insertions, 1 deletions
| diff --git a/render/egl.c b/render/egl.c index 797d8f15..f99b37f9 100644 --- a/render/egl.c +++ b/render/egl.c @@ -459,7 +459,20 @@ void wlr_egl_save_context(struct wlr_egl_context *context) {  }  bool wlr_egl_restore_context(struct wlr_egl_context *context) { -	return eglMakeCurrent(context->display, context->draw_surface, +	// If the saved context is a null-context, we must use the current +	// display instead of the saved display because eglMakeCurrent() can't +	// handle EGL_NO_DISPLAY. +	EGLDisplay display = context->display == EGL_NO_DISPLAY ? +		eglGetCurrentDisplay() : context->display; + +	// If the current display is also EGL_NO_DISPLAY, we assume that there +	// is currently no context set and no action needs to be taken to unset +	// the context. +	if (display == EGL_NO_DISPLAY) { +		return true; +	} + +	return eglMakeCurrent(display, context->draw_surface,  			context->read_surface, context->context);  } | 
