Mercurial > vim
diff src/gui.c @ 13150:808625d4b71b v8.0.1449
patch 8.0.1449: slow redrawing with DirectX
commit https://github.com/vim/vim/commit/a338adcf222b6a24e26ea5ae6a2ad27f914acb38
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 31 20:51:47 2018 +0100
patch 8.0.1449: slow redrawing with DirectX
Problem: Slow redrawing with DirectX.
Solution: Avoid calling gui_mch_flush() unnecessarily, especially when
updating the cursor. (Ken Takata, closes #2560)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 31 Jan 2018 21:00:08 +0100 |
parents | eee366f56b1a |
children | f4c3a7f410f4 |
line wrap: on
line diff
--- a/src/gui.c +++ b/src/gui.c @@ -55,6 +55,7 @@ enum { static void gui_attempt_start(void); static int can_update_cursor = TRUE; /* can display the cursor */ +static int disable_flush = 0; /* If > 0, gui_mch_flush() is disabled. */ /* * The Athena scrollbars can move the thumb to after the end of the scrollbar, @@ -1976,7 +1977,7 @@ gui_write( gui.dragged_sb = SBAR_NONE; #endif - gui_mch_flush(); /* In case vim decides to take a nap */ + gui_may_flush(); /* In case vim decides to take a nap */ } /* @@ -2004,6 +2005,34 @@ gui_can_update_cursor(void) * after scrolling. */ } +/* + * Disable issuing gui_mch_flush(). + */ + void +gui_disable_flush(void) +{ + ++disable_flush; +} + +/* + * Enable issuing gui_mch_flush(). + */ + void +gui_enable_flush(void) +{ + --disable_flush; +} + +/* + * Issue gui_mch_flush() if it is not disabled. + */ + void +gui_may_flush(void) +{ + if (disable_flush == 0) + gui_mch_flush(); +} + static void gui_outstr(char_u *s, int len) { @@ -3682,7 +3711,6 @@ gui_update_tabline(void) /* Updating the tabline uses direct GUI commands, flush * outstanding instructions first. (esp. clear screen) */ out_flush(); - gui_mch_flush(); if (!showit != !shown) gui_mch_show_tabline(showit); @@ -4122,8 +4150,7 @@ gui_drag_scrollbar(scrollbar_T *sb, long setcursor(); } # endif - out_flush(); - gui_update_cursor(FALSE, TRUE); + out_flush_cursor(FALSE, TRUE); #else add_to_input_buf(bytes, byte_count); add_long_to_buf((long_u)value, bytes); @@ -4486,7 +4513,9 @@ gui_do_scroll(void) * disappear when losing focus after a scrollbar drag. */ if (wp->w_redr_type < type) wp->w_redr_type = type; + mch_disable_flush(); updateWindow(wp); /* update window, status line, and cmdline */ + mch_enable_flush(); } #ifdef FEAT_INS_EXPAND @@ -4797,8 +4826,7 @@ gui_focus_change(int in_focus) */ #if 1 gui.in_focus = in_focus; - out_flush(); /* make sure output has been written */ - gui_update_cursor(TRUE, FALSE); + out_flush_cursor(TRUE, FALSE); # ifdef FEAT_XIM xim_set_focus(in_focus); @@ -5157,9 +5185,7 @@ gui_update_screen(void) curwin->w_valid &= ~VALID_CROW; } # endif - out_flush(); /* make sure output has been written */ - gui_update_cursor(TRUE, FALSE); - gui_mch_flush(); + out_flush_cursor(TRUE, FALSE); } #endif @@ -5516,9 +5542,7 @@ gui_handle_drop( maketitle(); #endif setcursor(); - out_flush(); - gui_update_cursor(FALSE, FALSE); - gui_mch_flush(); + out_flush_cursor(FALSE, FALSE); } entered = FALSE;