Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Luflosi committed Mar 14, 2019
1 parent ec6cc55 commit d6ee9d2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
15 changes: 9 additions & 6 deletions kitty/child-monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions kitty/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion kitty/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions kitty/shaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down

0 comments on commit d6ee9d2

Please sign in to comment.