From c4c99fbd1cbbb8e7a53b28988de1022a762fe044 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Sat, 9 Dec 2017 13:05:51 +0900 Subject: [PATCH 01/10] directx: Make scroll faster when scrlines:1 Redraw directly instead of using WM_PAINT. --- src/gui_w32.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gui_w32.c b/src/gui_w32.c index 119bcd579063f..3c2b1fda37991 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -3140,7 +3140,8 @@ gui_mch_delete_lines( { if (s_directx_scrlines > 0 && s_directx_scrlines <= num_lines) { - RedrawWindow(s_textArea, &rc, NULL, RDW_INVALIDATE); + gui_redraw(rc.left, rc.top, + rc.right - rc.left + 1, rc.bottom - rc.top + 1); use_redraw = 1; } else @@ -3152,9 +3153,9 @@ gui_mch_delete_lines( intel_gpu_workaround(); ScrollWindowEx(s_textArea, 0, -num_lines * gui.char_height, &rc, &rc, NULL, NULL, get_scroll_flags()); + UpdateWindow(s_textArea); } - UpdateWindow(s_textArea); /* This seems to be required to avoid the cursor disappearing when * scrolling such that the cursor ends up in the top-left character on * the screen... But why? (Webb) */ @@ -3190,7 +3191,8 @@ gui_mch_insert_lines( { if (s_directx_scrlines > 0 && s_directx_scrlines <= num_lines) { - RedrawWindow(s_textArea, &rc, NULL, RDW_INVALIDATE); + gui_redraw(rc.left, rc.top, + rc.right - rc.left + 1, rc.bottom - rc.top + 1); use_redraw = 1; } else @@ -3204,10 +3206,9 @@ gui_mch_insert_lines( * off-screen. How do we avoid it when it's not needed? */ ScrollWindowEx(s_textArea, 0, num_lines * gui.char_height, &rc, &rc, NULL, NULL, get_scroll_flags()); + UpdateWindow(s_textArea); } - UpdateWindow(s_textArea); - gui_clear_block(row, gui.scroll_region_left, row + num_lines - 1, gui.scroll_region_right); } From f29c6213f02be10de6684317e9866bb4dd25a21c Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Sat, 9 Dec 2017 13:09:25 +0900 Subject: [PATCH 02/10] Don't issue gui_mch_flush() twice when updating cursor When updating the cursor, functions were called in the following sequence: * out_flush() * gui_update_cursor() * gui_mch_flush() However, out_flush() itself calls gui_mch_flush() from inside it (through some functions). Therefore gui_mch_flush() was called twice. Unfortunately gui_mch_flush() is very slow when the directx renderer is used. Now the out_flush_cursor() function can be used instead of those 3 functions. It issues gui_mch_flush() only once after drawing the cursor. This also disables issuing gui_mch_flush() via update_single_line() in the main_loop() function. --- src/channel.c | 9 +-------- src/edit.c | 6 ++---- src/getchar.c | 14 ++++---------- src/gui.c | 36 +++++++++++++++++++++++----------- src/main.c | 13 ++++++++----- src/netbeans.c | 48 +++++++--------------------------------------- src/proto/gui.pro | 2 ++ src/proto/term.pro | 1 + src/screen.c | 20 +++++++++---------- src/search.c | 10 ++-------- src/term.c | 23 ++++++++++++++++++++++ src/ui.c | 11 ++--------- 12 files changed, 86 insertions(+), 107 deletions(-) diff --git a/src/channel.c b/src/channel.c index 8fc705058a1fc..9d1ba9073c952 100644 --- a/src/channel.c +++ b/src/channel.c @@ -2207,14 +2207,7 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv) ex_redraw(&ea); showruler(FALSE); setcursor(); - out_flush(); -#ifdef FEAT_GUI - if (gui.in_use) - { - gui_update_cursor(TRUE, FALSE); - gui_mch_flush(); - } -#endif + out_flush_cursor(TRUE, FALSE); } else if (STRCMP(cmd, "expr") == 0 || STRCMP(cmd, "call") == 0) { diff --git a/src/edit.c b/src/edit.c index bf2cf314043c0..b5aa29c3c2eac 100644 --- a/src/edit.c +++ b/src/edit.c @@ -3553,8 +3553,7 @@ ins_compl_new_leader(void) { /* Show the cursor after the match, not after the redrawn text. */ setcursor(); - out_flush(); - gui_update_cursor(FALSE, FALSE); + out_flush_cursor(FALSE, FALSE); } #endif compl_restarting = TRUE; @@ -4936,8 +4935,7 @@ ins_compl_next( { /* Show the cursor after the match, not after the redrawn text. */ setcursor(); - out_flush(); - gui_update_cursor(FALSE, FALSE); + out_flush_cursor(FALSE, FALSE); } #endif diff --git a/src/getchar.c b/src/getchar.c index 18dc1a670db20..70cf4f172783c 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -2972,16 +2972,10 @@ inchar( if (wait_time == -1L || wait_time > 100L) /* flush output before waiting */ { cursor_on(); - out_flush(); -#ifdef FEAT_GUI - if (gui.in_use) - { - gui_update_cursor(FALSE, FALSE); -# ifdef FEAT_MOUSESHAPE - if (postponed_mouseshape) - update_mouseshape(-1); -# endif - } + out_flush_cursor(FALSE, FALSE); +#if defined(FEAT_GUI) && defined(FEAT_MOUSESHAPE) + if (gui.in_use && postponed_mouseshape) + update_mouseshape(-1); #endif } diff --git a/src/gui.c b/src/gui.c index 4f03ed8096db0..e48c93906916b 100644 --- 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 cursor_updating = FALSE; /* * The Athena scrollbars can move the thumb to after the end of the scrollbar, @@ -1976,7 +1977,8 @@ gui_write( gui.dragged_sb = SBAR_NONE; #endif - gui_mch_flush(); /* In case vim decides to take a nap */ + if (!cursor_updating) + gui_mch_flush(); /* In case vim decides to take a nap */ } /* @@ -2004,6 +2006,24 @@ gui_can_update_cursor(void) * after scrolling. */ } +/* + * Start updating the cursor. No need to call gui_mch_flush() yet. + */ + void +gui_start_updating_cursor(void) +{ + cursor_updating = TRUE; +} + +/* + * End updating the cursor. gui_mch_flush() can be called. + */ + void +gui_end_updating_cursor(void) +{ + cursor_updating = FALSE; +} + static void gui_outstr(char_u *s, int len) { @@ -4107,8 +4127,7 @@ gui_drag_scrollbar(scrollbar_T *sb, long value, int still_dragging) 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); @@ -4782,8 +4801,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); @@ -5142,9 +5160,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 @@ -5501,9 +5517,7 @@ gui_handle_drop( maketitle(); #endif setcursor(); - out_flush(); - gui_update_cursor(FALSE, FALSE); - gui_mch_flush(); + out_flush_cursor(FALSE, FALSE); } entered = FALSE; diff --git a/src/main.c b/src/main.c index e8006c30bd3fd..890b9caa49f7d 100644 --- a/src/main.c +++ b/src/main.c @@ -1283,11 +1283,18 @@ main_loop( || conceal_cursor_line(curwin) || need_cursor_line_redraw)) { +# ifdef FEAT_GUI + /* Stop issuing gui_mch_flush(). */ + gui_start_updating_cursor(); +# endif if (conceal_old_cursor_line != conceal_new_cursor_line && conceal_old_cursor_line <= curbuf->b_ml.ml_line_count) update_single_line(curwin, conceal_old_cursor_line); update_single_line(curwin, conceal_new_cursor_line); +# ifdef FEAT_GUI + gui_end_updating_cursor(); +# endif curwin->w_valid &= ~VALID_CROW; } # endif @@ -4207,11 +4214,7 @@ eval_client_expr_to_string(char_u *expr) /* A client can tell us to redraw, but not to display the cursor, so do * that here. */ setcursor(); - out_flush(); -#ifdef FEAT_GUI - if (gui.in_use) - gui_update_cursor(FALSE, FALSE); -#endif + out_flush_cursor(FALSE, FALSE); return res; } diff --git a/src/netbeans.c b/src/netbeans.c index f4b42dc8adacb..c906d289120eb 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -121,14 +121,7 @@ netbeans_close(void) update_screen(CLEAR); setcursor(); cursor_on(); - out_flush(); -#ifdef FEAT_GUI - if (gui.in_use) - { - gui_update_cursor(TRUE, FALSE); - gui_mch_flush(); - } -#endif + out_flush_cursor(TRUE, FALSE); } #define NB_DEF_HOST "localhost" @@ -1848,14 +1841,8 @@ nb_do_cmd( update_screen(VALID); setcursor(); cursor_on(); - out_flush(); -#ifdef FEAT_GUI - if (gui.in_use) - { - gui_update_cursor(TRUE, FALSE); - gui_mch_flush(); - } -#endif + out_flush_cursor(TRUE, FALSE); + /* Quit a hit-return or more prompt. */ if (State == HITRETURN || State == ASKMORE) { @@ -2248,14 +2235,8 @@ nb_do_cmd( update_screen(NOT_VALID); setcursor(); cursor_on(); - out_flush(); -#ifdef FEAT_GUI - if (gui.in_use) - { - gui_update_cursor(TRUE, FALSE); - gui_mch_flush(); - } -#endif + out_flush_cursor(TRUE, FALSE); + /* Quit a hit-return or more prompt. */ if (State == HITRETURN || State == ASKMORE) { @@ -2307,15 +2288,7 @@ coloncmd(char *cmd, ...) /* ALT_INPUT_LOCK_OFF; */ setcursor(); /* restore the cursor position */ - out_flush(); /* make sure output has been written */ - -#ifdef FEAT_GUI - if (gui.in_use) - { - gui_update_cursor(TRUE, FALSE); - gui_mch_flush(); - } -#endif + out_flush_cursor(TRUE, FALSE); } @@ -2569,14 +2542,7 @@ netbeans_open(char *params, int doabort) update_screen(CLEAR); setcursor(); cursor_on(); - out_flush(); -#ifdef FEAT_GUI - if (gui.in_use) - { - gui_update_cursor(TRUE, FALSE); - gui_mch_flush(); - } -#endif + out_flush_cursor(TRUE, FALSE); } /* diff --git a/src/proto/gui.pro b/src/proto/gui.pro index 26466ae025225..20b5345f8538b 100644 --- a/src/proto/gui.pro +++ b/src/proto/gui.pro @@ -25,6 +25,8 @@ void gui_update_cursor_later(void); void gui_write(char_u *s, int len); void gui_dont_update_cursor(int undraw); void gui_can_update_cursor(void); +void gui_start_updating_cursor(void); +void gui_end_updating_cursor(void); int gui_outstr_nowrap(char_u *s, int len, int flags, guicolor_T fg, guicolor_T bg, int back); void gui_undraw_cursor(void); void gui_redraw(int x, int y, int w, int h); diff --git a/src/proto/term.pro b/src/proto/term.pro index ef74f5647c6cb..b0ad418e800d0 100644 --- a/src/proto/term.pro +++ b/src/proto/term.pro @@ -12,6 +12,7 @@ int term_is_gui(char_u *name); char_u *tltoa(unsigned long i); void termcapinit(char_u *name); void out_flush(void); +void out_flush_cursor(int force, int clear_selection); void out_flush_check(void); void out_trash(void); void out_char(unsigned c); diff --git a/src/screen.c b/src/screen.c index a74f750711d77..05d8663fdd56d 100644 --- a/src/screen.c +++ b/src/screen.c @@ -468,16 +468,14 @@ redraw_after_callback(int call_update_screen) setcursor(); } cursor_on(); - out_flush(); #ifdef FEAT_GUI - if (gui.in_use) - { + if (gui.in_use && !gui_mch_is_blink_off()) /* Don't update the cursor when it is blinking and off to avoid * flicker. */ - if (!gui_mch_is_blink_off()) - gui_update_cursor(FALSE, FALSE); - gui_mch_flush(); - } + out_flush_cursor(FALSE, FALSE); + else +#else + out_flush(); #endif --redrawing_for_callback; @@ -800,7 +798,6 @@ update_screen(int type_arg) * done. */ if (gui.in_use) { - out_flush(); /* required before updating the cursor */ if (did_undraw && !gui_mch_is_blink_off()) { /* Put the GUI position where the cursor was, gui_update_cursor() @@ -810,10 +807,12 @@ update_screen(int type_arg) # ifdef FEAT_MBYTE gui.col = mb_fix_col(gui.col, gui.row); # endif - gui_update_cursor(FALSE, FALSE); + out_flush_cursor(FALSE, FALSE); screen_cur_col = gui.col; screen_cur_row = gui.row; } + else + out_flush(); gui_update_scrollbars(FALSE); } #endif @@ -863,8 +862,7 @@ update_finish(void) * done. */ if (gui.in_use) { - out_flush(); /* required before updating the cursor */ - gui_update_cursor(FALSE, FALSE); + out_flush_cursor(FALSE, FALSE); gui_update_scrollbars(FALSE); } # endif diff --git a/src/search.c b/src/search.c index 8bb5f3d97aabc..0aebea4f95919 100644 --- a/src/search.c +++ b/src/search.c @@ -2675,14 +2675,8 @@ showmatch( showruler(FALSE); setcursor(); cursor_on(); /* make sure that the cursor is shown */ - out_flush(); -#ifdef FEAT_GUI - if (gui.in_use) - { - gui_update_cursor(TRUE, FALSE); - gui_mch_flush(); - } -#endif + out_flush_cursor(TRUE, FALSE); + /* Restore dollar_vcol(), because setcursor() may call curs_rows() * which resets it if the matching position is in a previous line * and has a higher column number. */ diff --git a/src/term.c b/src/term.c index 4e38bae5f9851..23f3e9b852e02 100644 --- a/src/term.c +++ b/src/term.c @@ -2501,6 +2501,29 @@ out_flush(void) } } +/* + * out_flush_cursor(): flush the output buffer and redraw the cursor + */ + void +out_flush_cursor( + int force, /* when TRUE, update even when not moved */ + int clear_selection)/* clear selection under cursor */ +{ +#ifdef FEAT_GUI + gui_start_updating_cursor(); +#endif + out_flush(); +#ifdef FEAT_GUI + gui_end_updating_cursor(); + if (gui.in_use) + { + gui_update_cursor(force, clear_selection); + gui_mch_flush(); + } +#endif +} + + #if defined(FEAT_MBYTE) || defined(PROTO) /* * Sometimes a byte out of a multi-byte character is written with out_char(). diff --git a/src/ui.c b/src/ui.c index 7d969fec861ca..6d397d2675a75 100644 --- a/src/ui.c +++ b/src/ui.c @@ -537,11 +537,7 @@ clip_lose_selection(VimClipboard *cbd) update_curbuf(INVERTED_ALL); setcursor(); cursor_on(); - out_flush(); -# ifdef FEAT_GUI - if (gui.in_use) - gui_update_cursor(TRUE, FALSE); -# endif + out_flush_cursor(TRUE, FALSE); } } #endif @@ -3290,13 +3286,10 @@ ui_focus_change( setcursor(); } cursor_on(); /* redrawing may have switched it off */ - out_flush(); + out_flush_cursor(FALSE, TRUE); # ifdef FEAT_GUI if (gui.in_use) - { - gui_update_cursor(FALSE, TRUE); gui_update_scrollbars(FALSE); - } # endif } #ifdef FEAT_TITLE From 4b5a05ed4d8a458fe58d6dffbd83dae149960637 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Mon, 11 Dec 2017 22:30:19 +0900 Subject: [PATCH 03/10] Fix cursor updating issue --- src/screen.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/screen.c b/src/screen.c index 05d8663fdd56d..d530a95bb161e 100644 --- a/src/screen.c +++ b/src/screen.c @@ -800,6 +800,10 @@ update_screen(int type_arg) { if (did_undraw && !gui_mch_is_blink_off()) { + gui_start_updating_cursor(); + out_flush(); /* required before updating the cursor */ + gui_end_updating_cursor(); + /* Put the GUI position where the cursor was, gui_update_cursor() * uses that. */ gui.col = gui_cursor_col; @@ -807,7 +811,8 @@ update_screen(int type_arg) # ifdef FEAT_MBYTE gui.col = mb_fix_col(gui.col, gui.row); # endif - out_flush_cursor(FALSE, FALSE); + gui_update_cursor(FALSE, FALSE); + gui_mch_flush(); screen_cur_col = gui.col; screen_cur_row = gui.row; } From 0e7d0764cc24d7563a9eb8c97f3020274a52d09c Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Mon, 11 Dec 2017 23:27:44 +0900 Subject: [PATCH 04/10] More optimization for gui_mch_flush() --- src/gui.c | 19 +++++++++++++++---- src/main.c | 9 +++++++++ src/proto/gui.pro | 1 + src/screen.c | 3 ++- src/term.c | 3 ++- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/gui.c b/src/gui.c index e48c93906916b..721e71fcbced8 100644 --- a/src/gui.c +++ b/src/gui.c @@ -55,7 +55,7 @@ enum { static void gui_attempt_start(void); static int can_update_cursor = TRUE; /* can display the cursor */ -static int cursor_updating = FALSE; +static int cursor_updating = 0; /* * The Athena scrollbars can move the thumb to after the end of the scrollbar, @@ -1977,7 +1977,7 @@ gui_write( gui.dragged_sb = SBAR_NONE; #endif - if (!cursor_updating) + if (!gui_is_updating_cursor()) gui_mch_flush(); /* In case vim decides to take a nap */ } @@ -2012,7 +2012,7 @@ gui_can_update_cursor(void) void gui_start_updating_cursor(void) { - cursor_updating = TRUE; + ++cursor_updating; } /* @@ -2021,7 +2021,16 @@ gui_start_updating_cursor(void) void gui_end_updating_cursor(void) { - cursor_updating = FALSE; + --cursor_updating; +} + +/* + * Return whether updating the cursor. + */ + int +gui_is_updating_cursor(void) +{ + return cursor_updating > 0; } static void @@ -4490,7 +4499,9 @@ gui_do_scroll(void) * disappear when losing focus after a scrollbar drag. */ if (wp->w_redr_type < type) wp->w_redr_type = type; + gui_start_updating_cursor(); updateWindow(wp); /* update window, status line, and cmdline */ + gui_end_updating_cursor(); } #ifdef FEAT_INS_EXPAND diff --git a/src/main.c b/src/main.c index 890b9caa49f7d..da5db21367449 100644 --- a/src/main.c +++ b/src/main.c @@ -1242,7 +1242,16 @@ main_loop( if (VIsual_active) update_curbuf(INVERTED);/* update inverted part */ else if (must_redraw) + { +#ifdef FEAT_GUI + /* Stop issuing gui_mch_flush(). */ + gui_start_updating_cursor(); +#endif update_screen(0); +#ifdef FEAT_GUI + gui_end_updating_cursor(); +#endif + } else if (redraw_cmdline || clear_cmdline) showmode(); redraw_statuslines(); diff --git a/src/proto/gui.pro b/src/proto/gui.pro index 20b5345f8538b..cd1ec25708252 100644 --- a/src/proto/gui.pro +++ b/src/proto/gui.pro @@ -27,6 +27,7 @@ void gui_dont_update_cursor(int undraw); void gui_can_update_cursor(void); void gui_start_updating_cursor(void); void gui_end_updating_cursor(void); +int gui_is_updating_cursor(void); int gui_outstr_nowrap(char_u *s, int len, int flags, guicolor_T fg, guicolor_T bg, int back); void gui_undraw_cursor(void); void gui_redraw(int x, int y, int w, int h); diff --git a/src/screen.c b/src/screen.c index d530a95bb161e..6af3a3955ddd5 100644 --- a/src/screen.c +++ b/src/screen.c @@ -812,7 +812,8 @@ update_screen(int type_arg) gui.col = mb_fix_col(gui.col, gui.row); # endif gui_update_cursor(FALSE, FALSE); - gui_mch_flush(); + if (!gui_is_updating_cursor()) + gui_mch_flush(); screen_cur_col = gui.col; screen_cur_row = gui.row; } diff --git a/src/term.c b/src/term.c index 23f3e9b852e02..b299af709a9c1 100644 --- a/src/term.c +++ b/src/term.c @@ -2518,7 +2518,8 @@ out_flush_cursor( if (gui.in_use) { gui_update_cursor(force, clear_selection); - gui_mch_flush(); + if (!gui_is_updating_cursor()) + gui_mch_flush(); } #endif } From 9af94dbea8389a5e31a946f53d9d7a11561d1456 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Tue, 12 Dec 2017 23:50:21 +0900 Subject: [PATCH 05/10] Revise the implementation --- src/gui.c | 31 +++++++++++++++---------------- src/main.c | 8 ++++---- src/proto/gui.pro | 6 +++--- src/screen.c | 7 +++---- src/term.c | 7 +++---- 5 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/gui.c b/src/gui.c index 721e71fcbced8..a9cc02ffbb7f6 100644 --- a/src/gui.c +++ b/src/gui.c @@ -55,7 +55,7 @@ enum { static void gui_attempt_start(void); static int can_update_cursor = TRUE; /* can display the cursor */ -static int cursor_updating = 0; +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, @@ -1977,8 +1977,7 @@ gui_write( gui.dragged_sb = SBAR_NONE; #endif - if (!gui_is_updating_cursor()) - gui_mch_flush(); /* In case vim decides to take a nap */ + gui_may_flush(); /* In case vim decides to take a nap */ } /* @@ -2007,30 +2006,31 @@ gui_can_update_cursor(void) } /* - * Start updating the cursor. No need to call gui_mch_flush() yet. + * Disable issuing gui_mch_flush(). */ void -gui_start_updating_cursor(void) +gui_disable_flush(void) { - ++cursor_updating; + ++disable_flush; } /* - * End updating the cursor. gui_mch_flush() can be called. + * Enable issuing gui_mch_flush(). */ void -gui_end_updating_cursor(void) +gui_enable_flush(void) { - --cursor_updating; + --disable_flush; } /* - * Return whether updating the cursor. + * Issue gui_mch_flush() if it is not disabled. */ - int -gui_is_updating_cursor(void) + void +gui_may_flush(void) { - return cursor_updating > 0; + if (disable_flush == 0) + gui_mch_flush(); } static void @@ -3696,7 +3696,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); @@ -4499,9 +4498,9 @@ gui_do_scroll(void) * disappear when losing focus after a scrollbar drag. */ if (wp->w_redr_type < type) wp->w_redr_type = type; - gui_start_updating_cursor(); + gui_disable_flush(); updateWindow(wp); /* update window, status line, and cmdline */ - gui_end_updating_cursor(); + gui_enable_flush(); } #ifdef FEAT_INS_EXPAND diff --git a/src/main.c b/src/main.c index da5db21367449..36918daa909d0 100644 --- a/src/main.c +++ b/src/main.c @@ -1245,11 +1245,11 @@ main_loop( { #ifdef FEAT_GUI /* Stop issuing gui_mch_flush(). */ - gui_start_updating_cursor(); + gui_disable_flush(); #endif update_screen(0); #ifdef FEAT_GUI - gui_end_updating_cursor(); + gui_enable_flush(); #endif } else if (redraw_cmdline || clear_cmdline) @@ -1294,7 +1294,7 @@ main_loop( { # ifdef FEAT_GUI /* Stop issuing gui_mch_flush(). */ - gui_start_updating_cursor(); + gui_disable_flush(); # endif if (conceal_old_cursor_line != conceal_new_cursor_line && conceal_old_cursor_line @@ -1302,7 +1302,7 @@ main_loop( update_single_line(curwin, conceal_old_cursor_line); update_single_line(curwin, conceal_new_cursor_line); # ifdef FEAT_GUI - gui_end_updating_cursor(); + gui_enable_flush(); # endif curwin->w_valid &= ~VALID_CROW; } diff --git a/src/proto/gui.pro b/src/proto/gui.pro index cd1ec25708252..6540e58a4f7c1 100644 --- a/src/proto/gui.pro +++ b/src/proto/gui.pro @@ -25,9 +25,9 @@ void gui_update_cursor_later(void); void gui_write(char_u *s, int len); void gui_dont_update_cursor(int undraw); void gui_can_update_cursor(void); -void gui_start_updating_cursor(void); -void gui_end_updating_cursor(void); -int gui_is_updating_cursor(void); +void gui_disable_flush(void); +void gui_enable_flush(void); +void gui_may_flush(void); int gui_outstr_nowrap(char_u *s, int len, int flags, guicolor_T fg, guicolor_T bg, int back); void gui_undraw_cursor(void); void gui_redraw(int x, int y, int w, int h); diff --git a/src/screen.c b/src/screen.c index 6af3a3955ddd5..3820e95388b4b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -800,9 +800,9 @@ update_screen(int type_arg) { if (did_undraw && !gui_mch_is_blink_off()) { - gui_start_updating_cursor(); + gui_disable_flush(); out_flush(); /* required before updating the cursor */ - gui_end_updating_cursor(); + gui_enable_flush(); /* Put the GUI position where the cursor was, gui_update_cursor() * uses that. */ @@ -812,8 +812,7 @@ update_screen(int type_arg) gui.col = mb_fix_col(gui.col, gui.row); # endif gui_update_cursor(FALSE, FALSE); - if (!gui_is_updating_cursor()) - gui_mch_flush(); + gui_may_flush(); screen_cur_col = gui.col; screen_cur_row = gui.row; } diff --git a/src/term.c b/src/term.c index b299af709a9c1..0c968969fb80c 100644 --- a/src/term.c +++ b/src/term.c @@ -2510,16 +2510,15 @@ out_flush_cursor( int clear_selection)/* clear selection under cursor */ { #ifdef FEAT_GUI - gui_start_updating_cursor(); + gui_disable_flush(); #endif out_flush(); #ifdef FEAT_GUI - gui_end_updating_cursor(); + gui_enable_flush(); if (gui.in_use) { gui_update_cursor(force, clear_selection); - if (!gui_is_updating_cursor()) - gui_mch_flush(); + gui_may_flush(); } #endif } From 849c800402777b6fbb88b3427f9fb00600f67c1e Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Wed, 20 Dec 2017 18:50:53 +0900 Subject: [PATCH 06/10] Fix cursor updating issue When doing `dd`, sometimes cursor was left in a wrong place. --- src/gui_w32.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui_w32.c b/src/gui_w32.c index 3c2b1fda37991..44a967a4d9655 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -3142,6 +3142,7 @@ gui_mch_delete_lines( { gui_redraw(rc.left, rc.top, rc.right - rc.left + 1, rc.bottom - rc.top + 1); + gui_undraw_cursor(); use_redraw = 1; } else @@ -3193,6 +3194,7 @@ gui_mch_insert_lines( { gui_redraw(rc.left, rc.top, rc.right - rc.left + 1, rc.bottom - rc.top + 1); + gui_undraw_cursor(); use_redraw = 1; } else From fdc0ffe49407e37db74606b020b16f6f69f003b2 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Thu, 21 Dec 2017 22:15:51 +0900 Subject: [PATCH 07/10] Make scroll faster when scrlines:0 --- src/gui_w32.c | 28 ++++++++++++++++++---------- src/message.c | 4 ++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/gui_w32.c b/src/gui_w32.c index 44a967a4d9655..9c2606305abf8 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -3126,9 +3126,6 @@ gui_mch_delete_lines( int num_lines) { RECT rc; -#if defined(FEAT_DIRECTX) - int use_redraw = 0; -#endif rc.left = FILL_X(gui.scroll_region_left); rc.right = FILL_X(gui.scroll_region_right + 1); @@ -3143,12 +3140,16 @@ gui_mch_delete_lines( gui_redraw(rc.left, rc.top, rc.right - rc.left + 1, rc.bottom - rc.top + 1); gui_undraw_cursor(); - use_redraw = 1; + DWriteContext_Flush(s_dwc); } else + { DWriteContext_Flush(s_dwc); + ScrollWindowEx(s_textArea, 0, -num_lines * gui.char_height, + &rc, &rc, NULL, NULL, 0); + } } - if (!use_redraw) + else #endif { intel_gpu_workaround(); @@ -3178,9 +3179,6 @@ gui_mch_insert_lines( int num_lines) { RECT rc; -#if defined(FEAT_DIRECTX) - int use_redraw = 0; -#endif rc.left = FILL_X(gui.scroll_region_left); rc.right = FILL_X(gui.scroll_region_right + 1); @@ -3195,12 +3193,16 @@ gui_mch_insert_lines( gui_redraw(rc.left, rc.top, rc.right - rc.left + 1, rc.bottom - rc.top + 1); gui_undraw_cursor(); - use_redraw = 1; + DWriteContext_Flush(s_dwc); } else + { DWriteContext_Flush(s_dwc); + ScrollWindowEx(s_textArea, 0, num_lines * gui.char_height, + &rc, &rc, NULL, NULL, 0); + } } - if (!use_redraw) + else #endif { intel_gpu_workaround(); @@ -4023,7 +4025,10 @@ _OnScroll( * position, but don't actually scroll by setting "dont_scroll". */ dont_scroll = !allow_scrollbar; + gui_disable_flush(); gui_drag_scrollbar(sb, val, dragging); + gui_enable_flush(); + gui_may_flush(); s_busy_processing = FALSE; dont_scroll = dont_scroll_save; @@ -4650,6 +4655,7 @@ _OnMouseWheel( if (mouse_scroll_lines == 0) init_mouse_wheel(); + gui_disable_flush(); if (mouse_scroll_lines > 0 && mouse_scroll_lines < (size > 2 ? size - 2 : 1)) { @@ -4658,6 +4664,8 @@ _OnMouseWheel( } else _OnScroll(hwnd, hwndCtl, zDelta >= 0 ? SB_PAGEUP : SB_PAGEDOWN, 0); + gui_enable_flush(); + gui_may_flush(); } #ifdef USE_SYSMENU_FONT diff --git a/src/message.c b/src/message.c index c40b6cf15b06a..82efd293e2863 100644 --- a/src/message.c +++ b/src/message.c @@ -2314,9 +2314,13 @@ msg_scroll_up(void) * to become invalid. */ if (gui.in_use) gui_undraw_cursor(); + gui_disable_flush(); #endif /* scrolling up always works */ screen_del_lines(0, 0, 1, (int)Rows, TRUE, 0, NULL); +#ifdef FEAT_GUI + gui_enable_flush(); +#endif if (!can_clear((char_u *)" ")) { From 47eca6d9dd740b09c6e6d2f59164304905dadded Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Fri, 22 Dec 2017 21:27:27 +0900 Subject: [PATCH 08/10] Refactor flush functions --- src/gui.c | 4 ++-- src/gui_w32.c | 8 ++++---- src/macros.h | 17 ++++++++++++++--- src/main.c | 18 ++++-------------- src/message.c | 6 ++---- src/screen.c | 4 ++-- src/term.c | 10 ++++------ 7 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/gui.c b/src/gui.c index 93bcf9617b6e3..45bf49ac9c001 100644 --- a/src/gui.c +++ b/src/gui.c @@ -4513,9 +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; - gui_disable_flush(); + mch_disable_flush(); updateWindow(wp); /* update window, status line, and cmdline */ - gui_enable_flush(); + mch_enable_flush(); } #ifdef FEAT_INS_EXPAND diff --git a/src/gui_w32.c b/src/gui_w32.c index 1430f00fa8a16..0f79cd1d5c4f3 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -4028,9 +4028,9 @@ _OnScroll( * position, but don't actually scroll by setting "dont_scroll". */ dont_scroll = !allow_scrollbar; - gui_disable_flush(); + mch_disable_flush(); gui_drag_scrollbar(sb, val, dragging); - gui_enable_flush(); + mch_enable_flush(); gui_may_flush(); s_busy_processing = FALSE; @@ -4658,7 +4658,7 @@ _OnMouseWheel( if (mouse_scroll_lines == 0) init_mouse_wheel(); - gui_disable_flush(); + mch_disable_flush(); if (mouse_scroll_lines > 0 && mouse_scroll_lines < (size > 2 ? size - 2 : 1)) { @@ -4667,7 +4667,7 @@ _OnMouseWheel( } else _OnScroll(hwnd, hwndCtl, zDelta >= 0 ? SB_PAGEUP : SB_PAGEDOWN, 0); - gui_enable_flush(); + mch_enable_flush(); gui_may_flush(); } diff --git a/src/macros.h b/src/macros.h index 1b54b91bae39e..6e4b813c0a715 100644 --- a/src/macros.h +++ b/src/macros.h @@ -365,6 +365,17 @@ * HIKEY2DI() converts a hashitem key pointer to a dictitem pointer. * HI2DI() converts a hashitem pointer to a dictitem pointer. */ -# define DI2HIKEY(di) ((di)->di_key) -# define HIKEY2DI(p) ((dictitem_T *)(p - offsetof(dictitem_T, di_key))) -# define HI2DI(hi) HIKEY2DI((hi)->hi_key) +#define DI2HIKEY(di) ((di)->di_key) +#define HIKEY2DI(p) ((dictitem_T *)(p - offsetof(dictitem_T, di_key))) +#define HI2DI(hi) HIKEY2DI((hi)->hi_key) + +/* + * Flush control functions. + */ +#ifdef FEAT_GUI +# define mch_enable_flush() gui_enable_flush() +# define mch_disable_flush() gui_disable_flush() +#else +# define mch_enable_flush() +# define mch_disable_flush() +#endif diff --git a/src/main.c b/src/main.c index 194c898c03f61..9cf10bd781792 100644 --- a/src/main.c +++ b/src/main.c @@ -1243,14 +1243,9 @@ main_loop( update_curbuf(INVERTED);/* update inverted part */ else if (must_redraw) { -#ifdef FEAT_GUI - /* Stop issuing gui_mch_flush(). */ - gui_disable_flush(); -#endif + mch_disable_flush(); /* Stop issuing gui_mch_flush(). */ update_screen(0); -#ifdef FEAT_GUI - gui_enable_flush(); -#endif + mch_enable_flush(); } else if (redraw_cmdline || clear_cmdline) showmode(); @@ -1292,18 +1287,13 @@ main_loop( || conceal_cursor_line(curwin) || need_cursor_line_redraw)) { -# ifdef FEAT_GUI - /* Stop issuing gui_mch_flush(). */ - gui_disable_flush(); -# endif + mch_disable_flush(); /* Stop issuing gui_mch_flush(). */ if (conceal_old_cursor_line != conceal_new_cursor_line && conceal_old_cursor_line <= curbuf->b_ml.ml_line_count) update_single_line(curwin, conceal_old_cursor_line); update_single_line(curwin, conceal_new_cursor_line); -# ifdef FEAT_GUI - gui_enable_flush(); -# endif + mch_enable_flush(); curwin->w_valid &= ~VALID_CROW; } # endif diff --git a/src/message.c b/src/message.c index 82efd293e2863..211403384a631 100644 --- a/src/message.c +++ b/src/message.c @@ -2314,13 +2314,11 @@ msg_scroll_up(void) * to become invalid. */ if (gui.in_use) gui_undraw_cursor(); - gui_disable_flush(); #endif /* scrolling up always works */ + mch_disable_flush(); screen_del_lines(0, 0, 1, (int)Rows, TRUE, 0, NULL); -#ifdef FEAT_GUI - gui_enable_flush(); -#endif + mch_enable_flush(); if (!can_clear((char_u *)" ")) { diff --git a/src/screen.c b/src/screen.c index d5001fbaad2cb..9a5385159ec9a 100644 --- a/src/screen.c +++ b/src/screen.c @@ -800,9 +800,9 @@ update_screen(int type_arg) { if (did_undraw && !gui_mch_is_blink_off()) { - gui_disable_flush(); + mch_disable_flush(); out_flush(); /* required before updating the cursor */ - gui_enable_flush(); + mch_enable_flush(); /* Put the GUI position where the cursor was, gui_update_cursor() * uses that. */ diff --git a/src/term.c b/src/term.c index af9eec0b26e6e..6303e10d59f7a 100644 --- a/src/term.c +++ b/src/term.c @@ -2506,15 +2506,13 @@ out_flush(void) */ void out_flush_cursor( - int force, /* when TRUE, update even when not moved */ - int clear_selection)/* clear selection under cursor */ + int force UNUSED, /* when TRUE, update cursor even when not moved */ + int clear_selection UNUSED) /* clear selection under cursor */ { -#ifdef FEAT_GUI - gui_disable_flush(); -#endif + mch_disable_flush(); out_flush(); + mch_enable_flush(); #ifdef FEAT_GUI - gui_enable_flush(); if (gui.in_use) { gui_update_cursor(force, clear_selection); From 5c58414a6b3f8286c5a6bc4b7f7f805ab7f246a6 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Mon, 25 Dec 2017 21:35:25 +0900 Subject: [PATCH 09/10] Scroll by using DirectX instead of ScrollWindowEx --- src/gui_dwrite.cpp | 98 ++++++++++++++++++++++++++++++++++++++++------ src/gui_dwrite.h | 1 + src/gui_w32.c | 18 +++------ 3 files changed, 92 insertions(+), 25 deletions(-) diff --git a/src/gui_dwrite.cpp b/src/gui_dwrite.cpp index 3c940a3042d62..8e03dff64e365 100644 --- a/src/gui_dwrite.cpp +++ b/src/gui_dwrite.cpp @@ -286,6 +286,7 @@ struct DWriteContext { ID2D1DCRenderTarget *mRT; ID2D1GdiInteropRenderTarget *mGDIRT; ID2D1SolidColorBrush *mBrush; + ID2D1Bitmap *mBitmap; IDWriteFactory *mDWriteFactory; #ifdef FEAT_DIRECTX_COLOR_EMOJI @@ -319,6 +320,8 @@ struct DWriteContext { void SetFont(HFONT hFont); + void Rebind(); + void BindDC(HDC hdc, const RECT *rect); HRESULT SetDrawingMode(DrawingMode mode); @@ -335,6 +338,8 @@ struct DWriteContext { void SetPixel(int x, int y, COLORREF color); + void Scroll(int x, int y, const RECT *rc); + void Flush(); void SetRenderingParams( @@ -596,6 +601,7 @@ DWriteContext::DWriteContext() : mRT(NULL), mGDIRT(NULL), mBrush(NULL), + mBitmap(NULL), mDWriteFactory(NULL), #ifdef FEAT_DIRECTX_COLOR_EMOJI mDWriteFactory2(NULL), @@ -615,9 +621,6 @@ DWriteContext::DWriteContext() : reinterpret_cast(&mD2D1Factory)); _RPT2(_CRT_WARN, "D2D1CreateFactory: hr=%p p=%p\n", hr, mD2D1Factory); - if (SUCCEEDED(hr)) - hr = CreateDeviceResources(); - if (SUCCEEDED(hr)) { hr = DWriteCreateFactory( @@ -662,6 +665,7 @@ DWriteContext::~DWriteContext() #ifdef FEAT_DIRECTX_COLOR_EMOJI SafeRelease(&mDWriteFactory2); #endif + SafeRelease(&mBitmap); SafeRelease(&mBrush); SafeRelease(&mGDIRT); SafeRelease(&mRT); @@ -704,13 +708,7 @@ DWriteContext::CreateDeviceResources() } if (SUCCEEDED(hr)) - { - if (mHDC != NULL) - { - mRT->BindDC(mHDC, &mBindRect); - mRT->SetTransform(D2D1::IdentityMatrix()); - } - } + Rebind(); return hr; } @@ -718,6 +716,7 @@ DWriteContext::CreateDeviceResources() void DWriteContext::DiscardDeviceResources() { + SafeRelease(&mBitmap); SafeRelease(&mBrush); SafeRelease(&mGDIRT); SafeRelease(&mRT); @@ -899,13 +898,36 @@ DWriteContext::SetFont(HFONT hFont) } void -DWriteContext::BindDC(HDC hdc, const RECT *rect) +DWriteContext::Rebind() { - Flush(); - mRT->BindDC(hdc, rect); + SafeRelease(&mBitmap); + + mRT->BindDC(mHDC, &mBindRect); mRT->SetTransform(D2D1::IdentityMatrix()); + + D2D1_BITMAP_PROPERTIES props = { + {DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE}, + 96.0f, 96.0f + }; + mRT->CreateBitmap( + D2D1::SizeU(mBindRect.right - mBindRect.left, + mBindRect.bottom - mBindRect.top), + props, &mBitmap); +} + + void +DWriteContext::BindDC(HDC hdc, const RECT *rect) +{ mHDC = hdc; mBindRect = *rect; + + if (mRT == NULL) + CreateDeviceResources(); + else + { + Flush(); + Rebind(); + } } HRESULT @@ -1080,6 +1102,49 @@ DWriteContext::SetPixel(int x, int y, COLORREF color) } } + void +DWriteContext::Scroll(int x, int y, const RECT *rc) +{ + SetDrawingMode(DM_DIRECTX); + mRT->Flush(); + + D2D1_RECT_U srcRect; + D2D1_POINT_2U destPoint; + if (x >= 0) + { + srcRect.left = rc->left; + srcRect.right = rc->right - x; + destPoint.x = rc->left + x; + } + else + { + srcRect.left = rc->left - x; + srcRect.right = rc->right; + destPoint.x = rc->left; + } + if (y >= 0) + { + srcRect.top = rc->top; + srcRect.bottom = rc->bottom - y; + destPoint.y = rc->top + y; + } + else + { + srcRect.top = rc->top - y; + srcRect.bottom = rc->bottom; + destPoint.y = rc->top; + } + mBitmap->CopyFromRenderTarget(&destPoint, mRT, &srcRect); + + D2D1_RECT_F destRect = { + FLOAT(destPoint.x), FLOAT(destPoint.y), + FLOAT(destPoint.x + srcRect.right - srcRect.left), + FLOAT(destPoint.y + srcRect.bottom - srcRect.top) + }; + mRT->DrawBitmap(mBitmap, destRect, 1.0F, + D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, destRect); +} + void DWriteContext::Flush() { @@ -1239,6 +1304,13 @@ DWriteContext_SetPixel(DWriteContext *ctx, int x, int y, COLORREF color) ctx->SetPixel(x, y, color); } + void +DWriteContext_Scroll(DWriteContext *ctx, int x, int y, const RECT *rc) +{ + if (ctx != NULL) + ctx->Scroll(x, y, rc); +} + void DWriteContext_Flush(DWriteContext *ctx) { diff --git a/src/gui_dwrite.h b/src/gui_dwrite.h index 9c98c4ce0dfc8..5de06f92b199e 100644 --- a/src/gui_dwrite.h +++ b/src/gui_dwrite.h @@ -74,6 +74,7 @@ void DWriteContext_FillRect(DWriteContext *ctx, const RECT *rc, COLORREF color); void DWriteContext_DrawLine(DWriteContext *ctx, int x1, int y1, int x2, int y2, COLORREF color); void DWriteContext_SetPixel(DWriteContext *ctx, int x, int y, COLORREF color); +void DWriteContext_Scroll(DWriteContext *ctx, int x, int y, const RECT *rc); void DWriteContext_Flush(DWriteContext *ctx); void DWriteContext_Close(DWriteContext *ctx); diff --git a/src/gui_w32.c b/src/gui_w32.c index 0f79cd1d5c4f3..f6eeace95d4b0 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -3143,14 +3143,11 @@ gui_mch_delete_lines( gui_redraw(rc.left, rc.top, rc.right - rc.left + 1, rc.bottom - rc.top + 1); gui_undraw_cursor(); - DWriteContext_Flush(s_dwc); } else - { - DWriteContext_Flush(s_dwc); - ScrollWindowEx(s_textArea, 0, -num_lines * gui.char_height, - &rc, &rc, NULL, NULL, 0); - } + DWriteContext_Scroll(s_dwc, 0, -num_lines * gui.char_height, &rc); + + DWriteContext_Flush(s_dwc); } else #endif @@ -3196,14 +3193,11 @@ gui_mch_insert_lines( gui_redraw(rc.left, rc.top, rc.right - rc.left + 1, rc.bottom - rc.top + 1); gui_undraw_cursor(); - DWriteContext_Flush(s_dwc); } else - { - DWriteContext_Flush(s_dwc); - ScrollWindowEx(s_textArea, 0, num_lines * gui.char_height, - &rc, &rc, NULL, NULL, 0); - } + DWriteContext_Scroll(s_dwc, 0, num_lines * gui.char_height, &rc); + + DWriteContext_Flush(s_dwc); } else #endif From 3d273aa787f1e4a62af2ff45e1944e9a3e2608f6 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Tue, 26 Dec 2017 22:15:20 +0900 Subject: [PATCH 10/10] directx: Deprecate scrlines Now scrlines:0 becomes fast enough and no need to set sclines >= 1 anymore. Make it deprecated. --- runtime/doc/options.txt | 22 ++++------------------ src/gui_w32.c | 25 +++---------------------- 2 files changed, 7 insertions(+), 40 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 41f621b20a42a..a70c733e93949 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6122,7 +6122,7 @@ A jump table for the options with a short description can be found at |Q_op|. geom pixelGeometry int 0 - 2 (see below) renmode renderingMode int 0 - 6 (see below) taamode textAntialiasMode int 0 - 3 (see below) - scrlines Scroll Lines int >= 0 (see below) + scrlines Scroll Lines int (deprecated) See this URL for detail (except for scrlines): https://msdn.microsoft.com/en-us/library/dd368190.aspx @@ -6156,23 +6156,9 @@ A jump table for the options with a short description can be found at |Q_op|. See this URL for detail: https://msdn.microsoft.com/en-us/library/dd368170.aspx - For scrlines: threshold for lines to be scrolled. - 0 - Always use scrolling. (default) - 1 - Use full page redrawing. - > 1 - If the lines to be scrolled is grater or equal to the - specified value, use redrawing. Otherwise use - scrolling. - - If you feel scrolling a page (CTRL-F) is too slow with DirectX - renderer, try this "scrlines" option. - When set it "1", Vim uses full page redrawing instead of - scrolling. Redrawing a page is faster than scrolling a - page in some environments. - After that, when you feel scrolling lines (CTRL-Y) becomes - slow, please try "2" or greater value for this option. - It works threshold line number to switch scrolling to - redrawing. Scrolling a few lines might be faster than - redrawing a page in some environments. + For scrlines: + This was used for optimizing scrolling behavior, however this + is now deprecated. If specified, it is simply ignored. Example: > set encoding=utf-8 diff --git a/src/gui_w32.c b/src/gui_w32.c index f6eeace95d4b0..074954a6ca640 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -36,7 +36,6 @@ static DWriteContext *s_dwc = NULL; static int s_directx_enabled = 0; static int s_directx_load_attempted = 0; -static int s_directx_scrlines = 0; # define IS_ENABLE_DIRECTX() (s_directx_enabled && s_dwc != NULL && enc_utf8) static int directx_enabled(void); static void directx_binddc(void); @@ -61,7 +60,6 @@ gui_mch_set_rendering_options(char_u *s) int dx_geom = 0; int dx_renmode = 0; int dx_taamode = 0; - int dx_scrlines = 0; /* parse string as rendering options. */ for (p = s; p != NULL && *p != NUL; ) @@ -124,7 +122,7 @@ gui_mch_set_rendering_options(char_u *s) } else if (STRCMP(name, "scrlines") == 0) { - dx_scrlines = atoi((char *)value); + /* Deprecated. Simply ignore it. */ } else return FAIL; @@ -159,7 +157,6 @@ gui_mch_set_rendering_options(char_u *s) } } s_directx_enabled = dx_enable; - s_directx_scrlines = dx_scrlines; return OK; # else @@ -3138,15 +3135,7 @@ gui_mch_delete_lines( #if defined(FEAT_DIRECTX) if (IS_ENABLE_DIRECTX()) { - if (s_directx_scrlines > 0 && s_directx_scrlines <= num_lines) - { - gui_redraw(rc.left, rc.top, - rc.right - rc.left + 1, rc.bottom - rc.top + 1); - gui_undraw_cursor(); - } - else - DWriteContext_Scroll(s_dwc, 0, -num_lines * gui.char_height, &rc); - + DWriteContext_Scroll(s_dwc, 0, -num_lines * gui.char_height, &rc); DWriteContext_Flush(s_dwc); } else @@ -3188,15 +3177,7 @@ gui_mch_insert_lines( #if defined(FEAT_DIRECTX) if (IS_ENABLE_DIRECTX()) { - if (s_directx_scrlines > 0 && s_directx_scrlines <= num_lines) - { - gui_redraw(rc.left, rc.top, - rc.right - rc.left + 1, rc.bottom - rc.top + 1); - gui_undraw_cursor(); - } - else - DWriteContext_Scroll(s_dwc, 0, num_lines * gui.char_height, &rc); - + DWriteContext_Scroll(s_dwc, 0, num_lines * gui.char_height, &rc); DWriteContext_Flush(s_dwc); } else