From 182b0aac98c857f976a6bebd869d56190c41107b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 25 Dec 2023 12:17:14 +0530 Subject: [PATCH] Freeze the color profile during paused rendering --- kitty/screen.c | 1 + kitty/screen.h | 1 + kitty/shaders.c | 11 ++++++----- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/kitty/screen.c b/kitty/screen.c index f03565ab0..d1c00a1bf 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -2375,6 +2375,7 @@ screen_pause_rendering(Screen *self, bool pause, int for_in_ms) { if (for_in_ms <= 0) for_in_ms = 2000; self->paused_rendering.expires_at = monotonic() + ms_to_monotonic_t(for_in_ms); memcpy(&self->paused_rendering.cursor, self->cursor, sizeof(self->paused_rendering.cursor)); + memcpy(&self->paused_rendering.color_profile, self->color_profile, sizeof(self->paused_rendering.color_profile)); return true; } diff --git a/kitty/screen.h b/kitty/screen.h index 3e7416718..d37174dfb 100644 --- a/kitty/screen.h +++ b/kitty/screen.h @@ -153,6 +153,7 @@ typedef struct { struct { monotonic_t expires_at; Cursor cursor; + ColorProfile color_profile; } paused_rendering; } Screen; diff --git a/kitty/shaders.c b/kitty/shaders.c index 336e18412..58b7bda1a 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -301,10 +301,11 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c }; // Send the uniform data struct GPUCellRenderData *rd = (struct GPUCellRenderData*)map_vao_buffer(vao_idx, uniform_buffer, GL_WRITE_ONLY); - if (UNLIKELY(screen->color_profile->dirty || screen->reload_all_gpu_data)) { - copy_color_table_to_buffer(screen->color_profile, (GLuint*)rd, cell_program_layouts[CELL_PROGRAM].color_table.offset / sizeof(GLuint), cell_program_layouts[CELL_PROGRAM].color_table.stride / sizeof(GLuint)); + ColorProfile *cp = screen->paused_rendering.expires_at ? &screen->paused_rendering.color_profile : screen->color_profile; + if (UNLIKELY(cp->dirty || screen->reload_all_gpu_data)) { + copy_color_table_to_buffer(cp, (GLuint*)rd, cell_program_layouts[CELL_PROGRAM].color_table.offset / sizeof(GLuint), cell_program_layouts[CELL_PROGRAM].color_table.stride / sizeof(GLuint)); } -#define COLOR(name) colorprofile_to_color(screen->color_profile, screen->color_profile->overridden.name, screen->color_profile->configured.name).rgb +#define COLOR(name) colorprofile_to_color(cp, cp->overridden.name, cp->configured.name).rgb rd->default_fg = COLOR(default_fg); rd->default_bg = COLOR(default_bg); rd->highlight_fg = COLOR(highlight_fg); rd->highlight_bg = COLOR(highlight_bg); // selection @@ -338,10 +339,10 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c bool reversed = false; if (cursor_ok) { linebuf_init_line(screen->linebuf, cursor->y); - colors_for_cell(screen->linebuf->line, screen->color_profile, &cell_color_x, &cell_fg, &cell_bg, &reversed); + colors_for_cell(screen->linebuf->line, cp, &cell_color_x, &cell_fg, &cell_bg, &reversed); } if (IS_SPECIAL_COLOR(cursor_color)) { - if (cursor_ok) pick_cursor_color(screen->linebuf->line, screen->color_profile, cell_fg, cell_bg, cell_color_x, &rd->cursor_fg, &rd->cursor_bg, rd->default_fg, rd->default_bg); + if (cursor_ok) pick_cursor_color(screen->linebuf->line, cp, cell_fg, cell_bg, cell_color_x, &rd->cursor_fg, &rd->cursor_bg, rd->default_fg, rd->default_bg); else { rd->cursor_fg = rd->default_bg; rd->cursor_bg = rd->default_fg; } if (cell_bg == cell_fg) { rd->cursor_fg = rd->default_bg; rd->cursor_bg = rd->default_fg;