mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
render/egl: introduce wlr_egl_unset_current
This function can be called after wlr_egl_make_current to cleanup the EGL context. This avoids having lingering EGL contexts that make things work by chance. Closes: https://github.com/swaywm/wlroots/issues/2197
This commit is contained in:
parent
781ed1ff02
commit
1edc42157b
8 changed files with 62 additions and 29 deletions
11
render/egl.c
11
render/egl.c
|
|
@ -387,6 +387,15 @@ bool wlr_egl_make_current(struct wlr_egl *egl, EGLSurface surface,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool wlr_egl_unset_current(struct wlr_egl *egl) {
|
||||
if (!eglMakeCurrent(egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT)) {
|
||||
wlr_log(WLR_ERROR, "eglMakeCurrent failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wlr_egl_is_current(struct wlr_egl *egl) {
|
||||
return eglGetCurrentContext() == egl->context;
|
||||
}
|
||||
|
|
@ -690,7 +699,7 @@ bool wlr_egl_destroy_surface(struct wlr_egl *egl, EGLSurface surface) {
|
|||
// Reset the current EGL surface in case it's the one we're destroying,
|
||||
// otherwise the next wlr_egl_make_current call will result in a
|
||||
// use-after-free.
|
||||
wlr_egl_make_current(egl, NULL, NULL);
|
||||
wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL);
|
||||
}
|
||||
return eglDestroySurface(egl->display, surface);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue