Freeze the color profile during paused rendering

This commit is contained in:
Kovid Goyal 2023-12-25 12:17:14 +05:30
parent d9d6bd7ffb
commit 182b0aac98
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 8 additions and 5 deletions

View file

@ -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;
}

View file

@ -153,6 +153,7 @@ typedef struct {
struct {
monotonic_t expires_at;
Cursor cursor;
ColorProfile color_profile;
} paused_rendering;
} Screen;

View file

@ -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;