Mercurial > vim
diff src/gui_w32.c @ 13028:cfce9ac1d1e8 v8.0.1390
patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
commit https://github.com/vim/vim/commit/7f88b65f6cde3d69386e461f61271a271b79b7e8
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 14 13:15:19 2017 +0100
patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Problem: DirectX scrolling can be slow, vertical positioning is off.
Solution: Make scroll slightly faster when using "scrlines:1". Fix y
position of displayed text. Fix DirectX with non-utf8 encoding.
(Ken Takata, closes #2440)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 14 Dec 2017 13:30:05 +0100 |
parents | 8566eaa08788 |
children | 808625d4b71b |
line wrap: on
line diff
--- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -30,11 +30,14 @@ #endif #if defined(FEAT_DIRECTX) +# ifndef FEAT_MBYTE +# error FEAT_MBYTE is required for FEAT_DIRECTX. +# endif 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) +# define IS_ENABLE_DIRECTX() (s_directx_enabled && s_dwc != NULL && enc_utf8) static int directx_enabled(void); static void directx_binddc(void); #endif @@ -47,7 +50,7 @@ static int gui_mswin_get_menu_height(int int gui_mch_set_rendering_options(char_u *s) { -#ifdef FEAT_DIRECTX +# ifdef FEAT_DIRECTX char_u *p, *q; int dx_enable = 0; @@ -159,9 +162,9 @@ gui_mch_set_rendering_options(char_u *s) s_directx_scrlines = dx_scrlines; return OK; -#else +# else return FAIL; -#endif +# endif } #endif @@ -3140,7 +3143,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 +3156,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 +3194,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,9 +3209,8 @@ 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); @@ -6401,13 +6405,13 @@ gui_mch_draw_string( if (text[n] >= 0x80) break; -#if defined(FEAT_DIRECTX) +# if defined(FEAT_DIRECTX) /* Quick hack to enable DirectWrite. To use DirectWrite (antialias), it is * required that unicode drawing routine, currently. So this forces it * enabled. */ - if (enc_utf8 && IS_ENABLE_DIRECTX()) + if (IS_ENABLE_DIRECTX()) n = 0; /* Keep n < len, to enter block for unicode. */ -#endif +# endif /* Check if the Unicode buffer exists and is big enough. Create it * with the same length as the multi-byte string, the number of wide @@ -6480,7 +6484,7 @@ gui_mch_draw_string( i += utf_ptr2len_len(text + i, len - i); ++clen; } -#if defined(FEAT_DIRECTX) +# if defined(FEAT_DIRECTX) if (IS_ENABLE_DIRECTX()) { /* Add one to "cells" for italics. */ @@ -6490,7 +6494,7 @@ gui_mch_draw_string( foptions, pcliprect, unicodepdy); } else -#endif +# endif ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), foptions, pcliprect, unicodebuf, wlen, unicodepdy); len = cells; /* used for underlining */