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)
diff --git a/src/gui_w32.c b/src/gui_w32.c
index 119bcd5..3c745b4 100644
--- 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 @@
     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 @@
     s_directx_scrlines = dx_scrlines;
 
     return OK;
-#else
+# else
     return FAIL;
-#endif
+# endif
 }
 #endif
 
@@ -3140,7 +3143,8 @@
     {
 	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 @@
 	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 @@
     {
 	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 +3209,9 @@
 	 * 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 @@
 	    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 @@
 	    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 @@
 		    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 */