mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
render/gles2: save/restore EGL context in destroy_buffer
It can be surprising that destroying a buffer changes the EGL context, especially since this can be triggered from anywhere wlr_buffer_unlock is called. Prevent this from happening by saving and restoring the EGL context.
This commit is contained in:
parent
dc61f471da
commit
02a086599c
1 changed files with 5 additions and 1 deletions
|
@ -41,6 +41,8 @@ static void destroy_buffer(struct wlr_gles2_buffer *buffer) {
|
||||||
wl_list_remove(&buffer->link);
|
wl_list_remove(&buffer->link);
|
||||||
wl_list_remove(&buffer->buffer_destroy.link);
|
wl_list_remove(&buffer->buffer_destroy.link);
|
||||||
|
|
||||||
|
struct wlr_egl_context prev_ctx;
|
||||||
|
wlr_egl_save_context(&prev_ctx);
|
||||||
wlr_egl_make_current(buffer->renderer->egl);
|
wlr_egl_make_current(buffer->renderer->egl);
|
||||||
|
|
||||||
push_gles2_debug(buffer->renderer);
|
push_gles2_debug(buffer->renderer);
|
||||||
|
@ -51,7 +53,9 @@ static void destroy_buffer(struct wlr_gles2_buffer *buffer) {
|
||||||
pop_gles2_debug(buffer->renderer);
|
pop_gles2_debug(buffer->renderer);
|
||||||
|
|
||||||
wlr_egl_destroy_image(buffer->renderer->egl, buffer->image);
|
wlr_egl_destroy_image(buffer->renderer->egl, buffer->image);
|
||||||
wlr_egl_unset_current(buffer->renderer->egl);
|
|
||||||
|
wlr_egl_restore_context(&prev_ctx);
|
||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue