From d6ee9d29da5037a571f71b31659b6322ba04dc20 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Thu, 14 Mar 2019 13:29:26 +0100 Subject: [PATCH] Test --- kitty/child-monitor.c | 15 +++++++++------ kitty/screen.c | 1 + kitty/screen.h | 2 +- kitty/shaders.c | 7 +++++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index 00501e2ac9e..438d8882bd0 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -286,7 +286,7 @@ schedule_write_to_child(unsigned long id, unsigned int num, ...) { } screen->write_buf_sz = screen->write_buf_used + sz; screen->write_buf = PyMem_RawRealloc(screen->write_buf, screen->write_buf_sz); - if (screen->write_buf == NULL) { fatal("Out of memory."); } + if (screen->write_buf == NULL) fatal("Out of memory."); } va_start(ap, num); for (unsigned int i = 0; i < num; i++) { @@ -299,7 +299,7 @@ schedule_write_to_child(unsigned long id, unsigned int num, ...) { if (screen->write_buf_sz > BUFSIZ && screen->write_buf_used < BUFSIZ) { screen->write_buf_sz = BUFSIZ; screen->write_buf = PyMem_RawRealloc(screen->write_buf, screen->write_buf_sz); - if (screen->write_buf == NULL) { fatal("Out of memory."); } + if (screen->write_buf == NULL) fatal("Out of memory."); } if (screen->write_buf_used) wakeup_io_loop(false); screen_mutex(unlock, write); @@ -630,10 +630,13 @@ render_os_window(OSWindow *os_window, double now, unsigned int active_window_id, if (w->visible && WD.screen) { before_render(); bool is_active_window = i == tab->active_window; - draw_cells(WD.vao_idx, WD.gvao_idx, WD.xstart, WD.ystart, WD.dx, WD.dy, WD.screen, os_window, is_active_window, true); - if (WD.screen->start_visual_bell_at != 0) { - double bell_left = global_state.opts.visual_bell_duration - (now - WD.screen->start_visual_bell_at); - set_maximum_wait(bell_left); + if (WD.screen->render_not_only_pixel_scroll) { + WD.screen->render_not_only_pixel_scroll = false; + draw_cells(WD.vao_idx, WD.gvao_idx, WD.xstart, WD.ystart, WD.dx, WD.dy, WD.screen, os_window, is_active_window, true); + if (WD.screen->start_visual_bell_at != 0) { + double bell_left = global_state.opts.visual_bell_duration - (now - WD.screen->start_visual_bell_at); + set_maximum_wait(bell_left); + } } after_render(os_window, (WD.screen->scrolled_by_pixels * 2.0) / os_window->viewport_height); w->cursor_visible_at_last_render = WD.screen->cursor_render_info.is_visible; w->last_cursor_x = WD.screen->cursor_render_info.x; w->last_cursor_y = WD.screen->cursor_render_info.y; w->last_cursor_shape = WD.screen->cursor_render_info.shape; diff --git a/kitty/screen.c b/kitty/screen.c index cc2eedc370b..ac0ada1b739 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -100,6 +100,7 @@ new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) { self->is_dirty = true; self->scroll_changed = false; self->pixel_scroll_changed = false; + self->render_not_only_pixel_scroll = false; self->margin_top = 0; self->margin_bottom = self->lines - 1; self->history_line_added_count = 0; RESET_CHARSETS; diff --git a/kitty/screen.h b/kitty/screen.h index c1176e8e46a..866aedda2ff 100644 --- a/kitty/screen.h +++ b/kitty/screen.h @@ -75,7 +75,7 @@ typedef struct { Selection selection; SelectionBoundary last_rendered_selection_start, last_rendered_selection_end, last_rendered_url_start, last_rendered_url_end; Selection url_range; - bool use_latin1, selection_updated_once, is_dirty, scroll_changed, pixel_scroll_changed; + bool use_latin1, selection_updated_once, is_dirty, scroll_changed, pixel_scroll_changed, render_not_only_pixel_scroll; Cursor *cursor; SavepointBuffer main_savepoints, alt_savepoints; SavemodesBuffer modes_savepoints; diff --git a/kitty/shaders.c b/kitty/shaders.c index ffe54e50aa9..c4ec41d2c3b 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -184,7 +184,7 @@ void setup_scroll(OSWindow *os_window) { glGenTextures(1, &os_window->scroll_texture_id); glBindTexture(GL_TEXTURE_2D, os_window->scroll_texture_id); printf("%d %d\n", os_window->viewport_width, os_window->viewport_height); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, os_window->viewport_width, os_window->viewport_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, os_window->viewport_width, os_window->viewport_height + 100, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 640, 400, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -217,7 +217,7 @@ void before_render() { // first pass glBindFramebuffer(GL_FRAMEBUFFER, scroll_framebuffer); //glClearColor(0.1f, 0.1f, 0.1f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // we're not using the stencil buffer now + //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // we're not using the stencil buffer now } void after_render(OSWindow *os_window, double pixels) { @@ -351,6 +351,7 @@ cell_prepare_to_render(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, GLfloa } if (screen->scroll_changed || screen->is_dirty) { + screen->render_not_only_pixel_scroll = true; sz = sizeof(GPUCell) * screen->lines * screen->columns; address = alloc_and_map_vao_buffer(vao_idx, sz, cell_data_buffer, GL_STREAM_DRAW, GL_WRITE_ONLY); screen_update_cell_data(screen, address, fonts_data); @@ -359,6 +360,7 @@ cell_prepare_to_render(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, GLfloa } if (screen_is_selection_dirty(screen)) { + screen->render_not_only_pixel_scroll = true; sz = screen->lines * screen->columns; address = alloc_and_map_vao_buffer(vao_idx, sz, selection_buffer, GL_STREAM_DRAW, GL_WRITE_ONLY); screen_apply_selection(screen, address, sz); @@ -367,6 +369,7 @@ cell_prepare_to_render(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, GLfloa } if (gvao_idx && grman_update_layers(screen->grman, screen->scrolled_by, xstart, ystart, dx, dy, screen->columns, screen->lines, screen->cell_size)) { + screen->render_not_only_pixel_scroll = true; send_graphics_data_to_gpu(screen->grman->count, gvao_idx, screen->grman->render_data); changed = true; }