To: vim_dev@googlegroups.com Subject: Patch 8.0.1390 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1390 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) Files: src/INSTALLpc.txt, src/Make_cyg_ming.mak, src/Make_mvc.mak, src/gui_dwrite.cpp, src/gui_w32.c *** ../vim-8.0.1389/src/INSTALLpc.txt 2017-12-10 18:17:21.369310972 +0100 --- src/INSTALLpc.txt 2017-12-14 13:07:27.373828493 +0100 *************** *** 34,43 **** 11. Building with Ruby support 12. Building with Tcl support 13. Building with Terminal support ! 14. Windows 3.1 ! 15. MS-DOS ! 16. Installing after building from sources The currently recommended way (that means it has been verified to work) is --- 34,44 ---- 11. Building with Ruby support 12. Building with Tcl support 13. Building with Terminal support ! 14. Building with DirectX (DirectWrite) support ! 15. Windows 3.1 ! 16. MS-DOS ! 17. Installing after building from sources The currently recommended way (that means it has been verified to work) is *************** *** 787,811 **** nmake -f Make_mvc.mak TERMINAL=yes ! Or when using MinGW (as one line): mingw32-make -f Make_ming.mak TERMINAL=yes ! 14. Windows 3.1x ================ The Windows 3.1x support was removed in patch 7.4.1364. ! 15. MS-DOS ========== The MS-DOS support was removed in patch 7.4.1399. Only very old Vim versions work on MS-DOS because of the limited amount of memory available. ! 16. Installing after building from sources ========================================== [provided by Michael Soyka, updated by Ken Takata] --- 788,846 ---- nmake -f Make_mvc.mak TERMINAL=yes ! Or when using MinGW: mingw32-make -f Make_ming.mak TERMINAL=yes ! 14. Building with DirectX (DirectWrite) support ! =============================================== ! ! Vim with DirectX (DirectWrite) support can be built with either MSVC or MinGW. ! This requires dwrite_2.h and some other header files which come with Windows ! SDK 8.1 or later (or MinGW-w64), if you want to enable color emoji support. ! This also requires MBYTE=yes which is enabled by default. ! ! A) Using MSVC ! ! If you use MSVC 2013 or later, Windows SDK 8.1 or later is used by default. ! You just need to specify DIRECTX=yes: ! ! nmake -f Make_mvc.mak DIRECTX=yes ! ! If you use MSVC 2012 or earlier, the required header files are not available ! by default. However, you can use the header files from newer SDKs with older ! compilers. E.g.: ! ! set "INCLUDE=%INCLUDE%;C:\Program Files (x86)\Windows Kits\8.1\Include\um" ! nmake -f Make_mvc.mak DIRECTX=yes ! ! If you don't need color emoji support, only dwrite.h is required. You can use ! older compilers (e.g. VC2010) without Windows SDK 8.1. E.g.: ! ! nmake -f Make_mvc.mak DIRECTX=yes COLOR_EMOJI=no ! ! B) Using MinGW-w64 ! ! Just set DIRECTX to yes: ! ! mingw32-make -f Make_ming.mak DIRECTX=yes ! ! ! 15. Windows 3.1x ================ The Windows 3.1x support was removed in patch 7.4.1364. ! 16. MS-DOS ========== The MS-DOS support was removed in patch 7.4.1399. Only very old Vim versions work on MS-DOS because of the limited amount of memory available. ! 17. Installing after building from sources ========================================== [provided by Michael Soyka, updated by Ken Takata] *** ../vim-8.0.1389/src/Make_cyg_ming.mak 2017-12-10 18:17:21.369310972 +0100 --- src/Make_cyg_ming.mak 2017-12-14 13:07:27.373828493 +0100 *************** *** 588,594 **** ifeq ($(DIRECTX),yes) # Only allow DirectWrite for a GUI build. ifeq (yes, $(GUI)) ! DEFINES += -DFEAT_DIRECTX -DDYNAMIC_DIRECTX endif endif --- 588,594 ---- ifeq ($(DIRECTX),yes) # Only allow DirectWrite for a GUI build. ifeq (yes, $(GUI)) ! DEFINES += -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DFEAT_DIRECTX_COLOR_EMOJI endif endif *** ../vim-8.0.1389/src/Make_mvc.mak 2017-12-10 18:17:21.369310972 +0100 --- src/Make_mvc.mak 2017-12-14 13:07:27.373828493 +0100 *************** *** 25,36 **** # # GUI interface: GUI=yes (default is no) # ! # GUI with DirectWrite(DirectX): DIRECTX=yes ! # (default is no, requires GUI=yes) # # OLE interface: OLE=yes (usually with GUI=yes) # ! # Multibyte support: MBYTE=yes (default is no) # # IME support: IME=yes (requires GUI=yes) # DYNAMIC_IME=[yes or no] (to load the imm32.dll dynamically, default --- 25,39 ---- # # GUI interface: GUI=yes (default is no) # ! # GUI with DirectWrite (DirectX): DIRECTX=yes ! # (default is no, requires GUI=yes and MBYTE=yes) ! # ! # Color emoji support: COLOR_EMOJI=yes ! # (default is yes if DIRECTX=yes, requires WinSDK 8.1 or later.) # # OLE interface: OLE=yes (usually with GUI=yes) # ! # Multibyte support: MBYTE=yes (default is yes for NORMAL, BIG, HUGE) # # IME support: IME=yes (requires GUI=yes) # DYNAMIC_IME=[yes or no] (to load the imm32.dll dynamically, default *************** *** 419,427 **** NETBEANS_LIB = WSock32.lib !endif ! # DirectWrite(DirectX) !if "$(DIRECTX)" == "yes" DIRECTX_DEFS = -DFEAT_DIRECTX -DDYNAMIC_DIRECTX DIRECTX_INCL = gui_dwrite.h DIRECTX_OBJ = $(OUTDIR)\gui_dwrite.obj !endif --- 422,433 ---- NETBEANS_LIB = WSock32.lib !endif ! # DirectWrite (DirectX) !if "$(DIRECTX)" == "yes" DIRECTX_DEFS = -DFEAT_DIRECTX -DDYNAMIC_DIRECTX + !if "$(COLOR_EMOJI)" != "no" + DIRECTX_DEFS = $(DIRECTX_DEFS) -DFEAT_DIRECTX_COLOR_EMOJI + !endif DIRECTX_INCL = gui_dwrite.h DIRECTX_OBJ = $(OUTDIR)\gui_dwrite.obj !endif *** ../vim-8.0.1389/src/gui_dwrite.cpp 2017-12-05 13:22:08.414402079 +0100 --- src/gui_dwrite.cpp 2017-12-14 13:07:27.377828468 +0100 *************** *** 38,44 **** # define _Outptr_ #endif ! #include #include "gui_dwrite.h" --- 38,48 ---- # define _Outptr_ #endif ! #ifdef FEAT_DIRECTX_COLOR_EMOJI ! # include ! #else ! # include ! #endif #include "gui_dwrite.h" *************** *** 284,290 **** --- 288,296 ---- ID2D1SolidColorBrush *mBrush; IDWriteFactory *mDWriteFactory; + #ifdef FEAT_DIRECTX_COLOR_EMOJI IDWriteFactory2 *mDWriteFactory2; + #endif IDWriteGdiInterop *mGdiInterop; IDWriteRenderingParams *mRenderingParams; *************** *** 481,486 **** --- 487,493 ---- AdjustedGlyphRun adjustedGlyphRun(glyphRun, context->cellWidth, context->offsetX); + #ifdef FEAT_DIRECTX_COLOR_EMOJI if (pDWC_->mDWriteFactory2 != NULL) { IDWriteColorGlyphRunEnumerator *enumerator = NULL; *************** *** 517,522 **** --- 524,530 ---- return S_OK; } } + #endif // Draw by IDWriteFactory (without color emoji) pDWC_->mRT->DrawGlyphRun( *************** *** 589,595 **** --- 597,605 ---- mGDIRT(NULL), mBrush(NULL), mDWriteFactory(NULL), + #ifdef FEAT_DIRECTX_COLOR_EMOJI mDWriteFactory2(NULL), + #endif mGdiInterop(NULL), mRenderingParams(NULL), mFontCache(8), *************** *** 618,623 **** --- 628,634 ---- mDWriteFactory); } + #ifdef FEAT_DIRECTX_COLOR_EMOJI if (SUCCEEDED(hr)) { DWriteCreateFactory( *************** *** 626,631 **** --- 637,643 ---- reinterpret_cast(&mDWriteFactory2)); _RPT1(_CRT_WARN, "IDWriteFactory2: %s\n", SUCCEEDED(hr) ? "available" : "not available"); } + #endif if (SUCCEEDED(hr)) { *************** *** 647,653 **** --- 659,667 ---- SafeRelease(&mRenderingParams); SafeRelease(&mGdiInterop); SafeRelease(&mDWriteFactory); + #ifdef FEAT_DIRECTX_COLOR_EMOJI SafeRelease(&mDWriteFactory2); + #endif SafeRelease(&mBrush); SafeRelease(&mGDIRT); SafeRelease(&mRT); *************** *** 995,1001 **** TextRenderer renderer(this); TextRendererContext context = { color, FLOAT(cellWidth), 0.0f }; ! textLayout->Draw(&context, &renderer, FLOAT(x), FLOAT(y)); } SafeRelease(&textLayout); --- 1009,1015 ---- TextRenderer renderer(this); TextRendererContext context = { color, FLOAT(cellWidth), 0.0f }; ! textLayout->Draw(&context, &renderer, FLOAT(x), FLOAT(y) - 0.5f); } SafeRelease(&textLayout); *** ../vim-8.0.1389/src/gui_w32.c 2017-12-05 16:57:52.222668130 +0100 --- src/gui_w32.c 2017-12-14 13:07:27.377828468 +0100 *************** *** 30,40 **** #endif #if defined(FEAT_DIRECTX) 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) static int directx_enabled(void); static void directx_binddc(void); #endif --- 30,43 ---- #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 && enc_utf8) static int directx_enabled(void); static void directx_binddc(void); #endif *************** *** 47,53 **** int gui_mch_set_rendering_options(char_u *s) { ! #ifdef FEAT_DIRECTX char_u *p, *q; int dx_enable = 0; --- 50,56 ---- int gui_mch_set_rendering_options(char_u *s) { ! # ifdef FEAT_DIRECTX char_u *p, *q; int dx_enable = 0; *************** *** 159,167 **** s_directx_scrlines = dx_scrlines; return OK; ! #else return FAIL; ! #endif } #endif --- 162,170 ---- s_directx_scrlines = dx_scrlines; return OK; ! # else return FAIL; ! # endif } #endif *************** *** 3140,3146 **** { if (s_directx_scrlines > 0 && s_directx_scrlines <= num_lines) { ! RedrawWindow(s_textArea, &rc, NULL, RDW_INVALIDATE); use_redraw = 1; } else --- 3143,3150 ---- { 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); use_redraw = 1; } else *************** *** 3152,3160 **** intel_gpu_workaround(); ScrollWindowEx(s_textArea, 0, -num_lines * gui.char_height, &rc, &rc, NULL, NULL, get_scroll_flags()); } - 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) */ --- 3156,3164 ---- intel_gpu_workaround(); ScrollWindowEx(s_textArea, 0, -num_lines * gui.char_height, &rc, &rc, NULL, NULL, get_scroll_flags()); + 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,3196 **** { if (s_directx_scrlines > 0 && s_directx_scrlines <= num_lines) { ! RedrawWindow(s_textArea, &rc, NULL, RDW_INVALIDATE); use_redraw = 1; } else --- 3194,3201 ---- { 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); use_redraw = 1; } else *************** *** 3204,3213 **** * 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); - gui_clear_block(row, gui.scroll_region_left, row + num_lines - 1, gui.scroll_region_right); } --- 3209,3217 ---- * 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); } gui_clear_block(row, gui.scroll_region_left, row + num_lines - 1, gui.scroll_region_right); } *************** *** 6401,6413 **** if (text[n] >= 0x80) break; ! #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()) n = 0; /* Keep n < len, to enter block for unicode. */ ! #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 --- 6405,6417 ---- if (text[n] >= 0x80) break; ! # 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 (IS_ENABLE_DIRECTX()) n = 0; /* Keep n < len, to enter block for unicode. */ ! # 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,6486 **** i += utf_ptr2len_len(text + i, len - i); ++clen; } ! #if defined(FEAT_DIRECTX) if (IS_ENABLE_DIRECTX()) { /* Add one to "cells" for italics. */ --- 6484,6490 ---- i += utf_ptr2len_len(text + i, len - i); ++clen; } ! # if defined(FEAT_DIRECTX) if (IS_ENABLE_DIRECTX()) { /* Add one to "cells" for italics. */ *************** *** 6490,6496 **** foptions, pcliprect, unicodepdy); } else ! #endif ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), foptions, pcliprect, unicodebuf, wlen, unicodepdy); len = cells; /* used for underlining */ --- 6494,6500 ---- foptions, pcliprect, unicodepdy); } else ! # endif ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), foptions, pcliprect, unicodebuf, wlen, unicodepdy); len = cells; /* used for underlining */ *** ../vim-8.0.1389/src/version.c 2017-12-12 22:45:07.141808185 +0100 --- src/version.c 2017-12-14 13:07:55.085653165 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1390, /**/ -- hundred-and-one symptoms of being an internet addict: 92. It takes you two hours to check all 14 of your mailboxes. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///