comparison 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
comparison
equal deleted inserted replaced
13149:46794b7ab97a 13150:808625d4b71b
53 #endif /* MAY_FORK */ 53 #endif /* MAY_FORK */
54 54
55 static void gui_attempt_start(void); 55 static void gui_attempt_start(void);
56 56
57 static int can_update_cursor = TRUE; /* can display the cursor */ 57 static int can_update_cursor = TRUE; /* can display the cursor */
58 static int disable_flush = 0; /* If > 0, gui_mch_flush() is disabled. */
58 59
59 /* 60 /*
60 * The Athena scrollbars can move the thumb to after the end of the scrollbar, 61 * The Athena scrollbars can move the thumb to after the end of the scrollbar,
61 * this makes the thumb indicate the part of the text that is shown. Motif 62 * this makes the thumb indicate the part of the text that is shown. Motif
62 * can't do this. 63 * can't do this.
1974 */ 1975 */
1975 #if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) 1976 #if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK)
1976 gui.dragged_sb = SBAR_NONE; 1977 gui.dragged_sb = SBAR_NONE;
1977 #endif 1978 #endif
1978 1979
1979 gui_mch_flush(); /* In case vim decides to take a nap */ 1980 gui_may_flush(); /* In case vim decides to take a nap */
1980 } 1981 }
1981 1982
1982 /* 1983 /*
1983 * When ScreenLines[] is invalid, updating the cursor should not be done, it 1984 * When ScreenLines[] is invalid, updating the cursor should not be done, it
1984 * produces wrong results. Call gui_dont_update_cursor() before that code and 1985 * produces wrong results. Call gui_dont_update_cursor() before that code and
2000 gui_can_update_cursor(void) 2001 gui_can_update_cursor(void)
2001 { 2002 {
2002 can_update_cursor = TRUE; 2003 can_update_cursor = TRUE;
2003 /* No need to update the cursor right now, there is always more output 2004 /* No need to update the cursor right now, there is always more output
2004 * after scrolling. */ 2005 * after scrolling. */
2006 }
2007
2008 /*
2009 * Disable issuing gui_mch_flush().
2010 */
2011 void
2012 gui_disable_flush(void)
2013 {
2014 ++disable_flush;
2015 }
2016
2017 /*
2018 * Enable issuing gui_mch_flush().
2019 */
2020 void
2021 gui_enable_flush(void)
2022 {
2023 --disable_flush;
2024 }
2025
2026 /*
2027 * Issue gui_mch_flush() if it is not disabled.
2028 */
2029 void
2030 gui_may_flush(void)
2031 {
2032 if (disable_flush == 0)
2033 gui_mch_flush();
2005 } 2034 }
2006 2035
2007 static void 2036 static void
2008 gui_outstr(char_u *s, int len) 2037 gui_outstr(char_u *s, int len)
2009 { 2038 {
3680 if (!gui.starting && starting == 0) 3709 if (!gui.starting && starting == 0)
3681 { 3710 {
3682 /* Updating the tabline uses direct GUI commands, flush 3711 /* Updating the tabline uses direct GUI commands, flush
3683 * outstanding instructions first. (esp. clear screen) */ 3712 * outstanding instructions first. (esp. clear screen) */
3684 out_flush(); 3713 out_flush();
3685 gui_mch_flush();
3686 3714
3687 if (!showit != !shown) 3715 if (!showit != !shown)
3688 gui_mch_show_tabline(showit); 3716 gui_mch_show_tabline(showit);
3689 if (showit != 0) 3717 if (showit != 0)
3690 gui_mch_update_tabline(); 3718 gui_mch_update_tabline();
4120 if (wp->w_redr_type > 0) 4148 if (wp->w_redr_type > 0)
4121 updateWindow(wp); 4149 updateWindow(wp);
4122 setcursor(); 4150 setcursor();
4123 } 4151 }
4124 # endif 4152 # endif
4125 out_flush(); 4153 out_flush_cursor(FALSE, TRUE);
4126 gui_update_cursor(FALSE, TRUE);
4127 #else 4154 #else
4128 add_to_input_buf(bytes, byte_count); 4155 add_to_input_buf(bytes, byte_count);
4129 add_long_to_buf((long_u)value, bytes); 4156 add_long_to_buf((long_u)value, bytes);
4130 add_to_input_buf_csi(bytes, sizeof(long_u)); 4157 add_to_input_buf_csi(bytes, sizeof(long_u));
4131 #endif 4158 #endif
4484 #endif 4511 #endif
4485 /* Don't set must_redraw here, it may cause the popup menu to 4512 /* Don't set must_redraw here, it may cause the popup menu to
4486 * disappear when losing focus after a scrollbar drag. */ 4513 * disappear when losing focus after a scrollbar drag. */
4487 if (wp->w_redr_type < type) 4514 if (wp->w_redr_type < type)
4488 wp->w_redr_type = type; 4515 wp->w_redr_type = type;
4516 mch_disable_flush();
4489 updateWindow(wp); /* update window, status line, and cmdline */ 4517 updateWindow(wp); /* update window, status line, and cmdline */
4518 mch_enable_flush();
4490 } 4519 }
4491 4520
4492 #ifdef FEAT_INS_EXPAND 4521 #ifdef FEAT_INS_EXPAND
4493 /* May need to redraw the popup menu. */ 4522 /* May need to redraw the popup menu. */
4494 if (pum_visible()) 4523 if (pum_visible())
4795 * Skip this code to avoid drawing the cursor when debugging and switching 4824 * Skip this code to avoid drawing the cursor when debugging and switching
4796 * between the debugger window and gvim. 4825 * between the debugger window and gvim.
4797 */ 4826 */
4798 #if 1 4827 #if 1
4799 gui.in_focus = in_focus; 4828 gui.in_focus = in_focus;
4800 out_flush(); /* make sure output has been written */ 4829 out_flush_cursor(TRUE, FALSE);
4801 gui_update_cursor(TRUE, FALSE);
4802 4830
4803 # ifdef FEAT_XIM 4831 # ifdef FEAT_XIM
4804 xim_set_focus(in_focus); 4832 xim_set_focus(in_focus);
4805 # endif 4833 # endif
4806 4834
5155 update_single_line(curwin, conceal_old_cursor_line); 5183 update_single_line(curwin, conceal_old_cursor_line);
5156 update_single_line(curwin, conceal_new_cursor_line); 5184 update_single_line(curwin, conceal_new_cursor_line);
5157 curwin->w_valid &= ~VALID_CROW; 5185 curwin->w_valid &= ~VALID_CROW;
5158 } 5186 }
5159 # endif 5187 # endif
5160 out_flush(); /* make sure output has been written */ 5188 out_flush_cursor(TRUE, FALSE);
5161 gui_update_cursor(TRUE, FALSE);
5162 gui_mch_flush();
5163 } 5189 }
5164 #endif 5190 #endif
5165 5191
5166 #if defined(FIND_REPLACE_DIALOG) || defined(PROTO) 5192 #if defined(FIND_REPLACE_DIALOG) || defined(PROTO)
5167 static void concat_esc(garray_T *gap, char_u *text, int what); 5193 static void concat_esc(garray_T *gap, char_u *text, int what);
5514 # endif 5540 # endif
5515 #ifdef FEAT_TITLE 5541 #ifdef FEAT_TITLE
5516 maketitle(); 5542 maketitle();
5517 #endif 5543 #endif
5518 setcursor(); 5544 setcursor();
5519 out_flush(); 5545 out_flush_cursor(FALSE, FALSE);
5520 gui_update_cursor(FALSE, FALSE);
5521 gui_mch_flush();
5522 } 5546 }
5523 5547
5524 entered = FALSE; 5548 entered = FALSE;
5525 } 5549 }
5526 #endif 5550 #endif