From 8bca84ed6613d7921ba2ec1b44216a3d43da2140 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 28 Oct 2024 12:30:03 +0530 Subject: [PATCH] Fix background image flashing when closing a tab Ensure the correct vertex array object is bound when calling draw_bgimage. Before this fix it was order dependent on draw calls. Fixes #7999 --- docs/changelog.rst | 2 ++ kitty/shaders.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5bd4575187..1fdb77f4a8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -91,6 +91,8 @@ Detailed list of changes - Wayland: Fix :opt:`background_opacity` less than one causing flicker on startup when the Wayland compositor supports single pixel buffers (:iss:`7987`) +- Fix background image flashing when closing a tab (:iss:`7999`) + 0.36.4 [2024-09-27] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/shaders.c b/kitty/shaders.c index e58f781fde..b61f59d33b 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -1092,6 +1092,7 @@ draw_borders(ssize_t vao_idx, unsigned int num_border_rects, BorderRect *rect_bu float background_opacity = w->is_semi_transparent ? w->background_opacity: 1.0f; float tint_opacity = background_opacity; float tint_premult = background_opacity; + bind_vertex_array(vao_idx); if (has_bgimage(w)) { glEnable(GL_BLEND); BLEND_ONTO_OPAQUE; @@ -1103,7 +1104,6 @@ draw_borders(ssize_t vao_idx, unsigned int num_border_rects, BorderRect *rect_bu } if (num_border_rects) { - bind_vertex_array(vao_idx); bind_program(BORDERS_PROGRAM); if (rect_data_is_dirty) { const size_t sz = sizeof(BorderRect) * num_border_rects; @@ -1127,9 +1127,9 @@ draw_borders(ssize_t vao_idx, unsigned int num_border_rects, BorderRect *rect_bu else { BLEND_ONTO_OPAQUE_WITH_OPAQUE_OUTPUT; } } glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, num_border_rects); - unbind_vertex_array(); unbind_program(); } + unbind_vertex_array(); if (has_bgimage(w)) glDisable(GL_BLEND); }