annotate src/gui_dwrite.cpp @ 23134:26824776adf6 v8.2.2113

patch 8.2.2113: MS-Windows GUI: crash after using ":set guifont=" four times Commit: https://github.com/vim/vim/commit/1b3e0727ce86ca4cfa47f8b5421d82ed47a9bec1 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Dec 8 21:12:40 2020 +0100 patch 8.2.2113: MS-Windows GUI: crash after using ":set guifont=" four times Problem: MS-Windows GUI: crash after using ":set guifont=" four times. Solution: Check for NULL pointer. (Ken Takata, closes https://github.com/vim/vim/issues/7434)
author Bram Moolenaar <Bram@vim.org>
date Tue, 08 Dec 2020 21:15:03 +0100
parents 563163ec0244
children a077948be0f4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet: */
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 /*
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3 * Author: MURAOKA Taro <koron.kaoriya@gmail.com>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4 *
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5 * Contributors:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6 * - Ken Takata
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
7 * - Yasuhiro Matsumoto
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 *
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9 * Copyright (C) 2013 MURAOKA Taro <koron.kaoriya@gmail.com>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 * THIS FILE IS DISTRIBUTED UNDER THE VIM LICENSE.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 */
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 #define WIN32_LEAN_AND_MEAN
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 #ifndef DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16 # if WINVER < 0x0600
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 # error WINVER must be 0x0600 or above to use DirectWrite(DirectX)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 # endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21 #include <windows.h>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22 #include <crtdbg.h>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 #include <assert.h>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 #include <math.h>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 #include <d2d1.h>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26 #include <d2d1helper.h>
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
27
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
28 // Disable these macros to compile with old VC and newer SDK (V8.1 or later).
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
29 #if defined(_MSC_VER) && (_MSC_VER < 1700)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
30 # define _COM_Outptr_ __out
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
31 # define _In_reads_(s)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
32 # define _In_reads_opt_(s)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
33 # define _Maybenull_
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
34 # define _Out_writes_(s)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
35 # define _Out_writes_opt_(s)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
36 # define _Out_writes_to_(x, y)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
37 # define _Out_writes_to_opt_(x, y)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
38 # define _Outptr_
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
39 #endif
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
40
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
41 #ifdef FEAT_DIRECTX_COLOR_EMOJI
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
42 # include <dwrite_2.h>
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
43 #else
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
44 # include <dwrite.h>
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
45 #endif
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
47 #include "gui_dwrite.h"
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
49 #ifdef __MINGW32__
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50 # define __maybenull SAL__maybenull
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
51 # define __in SAL__in
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
52 # define __out SAL__out
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
53 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
54
8641
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
55 #if (defined(_MSC_VER) && (_MSC_VER >= 1700)) || (__cplusplus >= 201103L)
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
56 # define FINAL final
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
57 #else
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
58 # define FINAL
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
59 #endif
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
60
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
61 #ifdef DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
62 extern "C" HINSTANCE vimLoadLib(char *name);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
63
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
64 typedef int (WINAPI *PGETUSERDEFAULTLOCALENAME)(LPWSTR, int);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
65 typedef HRESULT (WINAPI *PD2D1CREATEFACTORY)(D2D1_FACTORY_TYPE,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
66 REFIID, const D2D1_FACTORY_OPTIONS *, void **);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
67 typedef HRESULT (WINAPI *PDWRITECREATEFACTORY)(DWRITE_FACTORY_TYPE,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
68 REFIID, IUnknown **);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
69
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
70 static HINSTANCE hD2D1DLL = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
71 static HINSTANCE hDWriteDLL = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
72
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
73 static PGETUSERDEFAULTLOCALENAME pGetUserDefaultLocaleName = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
74 static PD2D1CREATEFACTORY pD2D1CreateFactory = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
75 static PDWRITECREATEFACTORY pDWriteCreateFactory = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
76
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
77 #define GetUserDefaultLocaleName (*pGetUserDefaultLocaleName)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
78 #define D2D1CreateFactory (*pD2D1CreateFactory)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
79 #define DWriteCreateFactory (*pDWriteCreateFactory)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
80
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
81 static void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
82 unload(HINSTANCE &hinst)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
83 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
84 if (hinst != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
85 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
86 FreeLibrary(hinst);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
87 hinst = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
88 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
89 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
90 #endif // DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
91
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
92 template <class T> inline void SafeRelease(T **ppT)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
93 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
94 if (*ppT)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
95 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
96 (*ppT)->Release();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
97 *ppT = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
98 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
99 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
100
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
101 static DWRITE_PIXEL_GEOMETRY
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
102 ToPixelGeometry(int value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
103 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
104 switch (value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
105 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
106 default:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
107 case 0:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
108 return DWRITE_PIXEL_GEOMETRY_FLAT;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
109 case 1:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
110 return DWRITE_PIXEL_GEOMETRY_RGB;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
111 case 2:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
112 return DWRITE_PIXEL_GEOMETRY_BGR;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
113 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
114 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
115
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
116 static int
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
117 ToInt(DWRITE_PIXEL_GEOMETRY value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
118 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
119 switch (value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
120 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
121 case DWRITE_PIXEL_GEOMETRY_FLAT:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
122 return 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
123 case DWRITE_PIXEL_GEOMETRY_RGB:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
124 return 1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
125 case DWRITE_PIXEL_GEOMETRY_BGR:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
126 return 2;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
127 default:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
128 return -1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
129 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
130 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
131
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
132 static DWRITE_RENDERING_MODE
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
133 ToRenderingMode(int value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
134 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
135 switch (value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
136 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
137 default:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
138 case 0:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
139 return DWRITE_RENDERING_MODE_DEFAULT;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
140 case 1:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
141 return DWRITE_RENDERING_MODE_ALIASED;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
142 case 2:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
143 return DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
144 case 3:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
145 return DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
146 case 4:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
147 return DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
148 case 5:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
149 return DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
150 case 6:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
151 return DWRITE_RENDERING_MODE_OUTLINE;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
152 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
153 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
154
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
155 static D2D1_TEXT_ANTIALIAS_MODE
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
156 ToTextAntialiasMode(int value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
157 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
158 switch (value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
159 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
160 default:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
161 case 0:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
162 return D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
163 case 1:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
164 return D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
165 case 2:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
166 return D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
167 case 3:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
168 return D2D1_TEXT_ANTIALIAS_MODE_ALIASED;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
169 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
170 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
171
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
172 static int
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
173 ToInt(DWRITE_RENDERING_MODE value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
174 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
175 switch (value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
176 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
177 case DWRITE_RENDERING_MODE_DEFAULT:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
178 return 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
179 case DWRITE_RENDERING_MODE_ALIASED:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
180 return 1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
181 case DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
182 return 2;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
183 case DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
184 return 3;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
185 case DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
186 return 4;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
187 case DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
188 return 5;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
189 case DWRITE_RENDERING_MODE_OUTLINE:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
190 return 6;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
191 default:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
192 return -1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
193 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
194 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
195
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
196 class FontCache {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
197 public:
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
198 struct Item {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
199 HFONT hFont;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
200 IDWriteTextFormat* pTextFormat;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
201 DWRITE_FONT_WEIGHT fontWeight;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
202 DWRITE_FONT_STYLE fontStyle;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
203 Item() : hFont(NULL), pTextFormat(NULL) {}
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
204 };
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
205
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
206 private:
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
207 int mSize;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
208 Item *mItems;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
209
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
210 public:
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
211 FontCache(int size = 2) :
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
212 mSize(size),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
213 mItems(new Item[size])
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
214 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
215 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
216
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
217 ~FontCache()
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
218 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
219 for (int i = 0; i < mSize; ++i)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
220 SafeRelease(&mItems[i].pTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
221 delete[] mItems;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
222 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
223
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
224 bool get(HFONT hFont, Item &item)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
225 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
226 int n = find(hFont);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
227 if (n < 0)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
228 return false;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
229 item = mItems[n];
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
230 slide(n);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
231 return true;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
232 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
233
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
234 void put(const Item& item)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
235 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
236 int n = find(item.hFont);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
237 if (n < 0)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
238 n = mSize - 1;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
239 if (mItems[n].pTextFormat != item.pTextFormat)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
240 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
241 SafeRelease(&mItems[n].pTextFormat);
23134
26824776adf6 patch 8.2.2113: MS-Windows GUI: crash after using ":set guifont=" four times
Bram Moolenaar <Bram@vim.org>
parents: 16539
diff changeset
242 if (item.pTextFormat != NULL)
26824776adf6 patch 8.2.2113: MS-Windows GUI: crash after using ":set guifont=" four times
Bram Moolenaar <Bram@vim.org>
parents: 16539
diff changeset
243 item.pTextFormat->AddRef();
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
244 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
245 mItems[n] = item;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
246 slide(n);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
247 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
248
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
249 private:
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
250 int find(HFONT hFont)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
251 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
252 for (int i = 0; i < mSize; ++i)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
253 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
254 if (mItems[i].hFont == hFont)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
255 return i;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
256 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
257 return -1;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
258 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
259
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
260 void slide(int nextTop)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
261 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
262 if (nextTop == 0)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
263 return;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
264 Item tmp = mItems[nextTop];
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
265 for (int i = nextTop - 1; i >= 0; --i)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
266 mItems[i + 1] = mItems[i];
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
267 mItems[0] = tmp;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
268 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
269 };
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
270
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
271 enum DrawingMode {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
272 DM_GDI = 0,
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
273 DM_DIRECTX = 1,
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
274 DM_INTEROP = 2,
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
275 };
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
276
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
277 struct DWriteContext {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
278 HDC mHDC;
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
279 RECT mBindRect;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
280 DrawingMode mDMode;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
281 HDC mInteropHDC;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
282 bool mDrawing;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
283 bool mFallbackDC;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
284
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
285 ID2D1Factory *mD2D1Factory;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
286
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
287 ID2D1DCRenderTarget *mRT;
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
288 ID2D1GdiInteropRenderTarget *mGDIRT;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
289 ID2D1SolidColorBrush *mBrush;
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
290 ID2D1Bitmap *mBitmap;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
291
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
292 IDWriteFactory *mDWriteFactory;
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
293 #ifdef FEAT_DIRECTX_COLOR_EMOJI
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
294 IDWriteFactory2 *mDWriteFactory2;
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
295 #endif
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
296
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
297 IDWriteGdiInterop *mGdiInterop;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
298 IDWriteRenderingParams *mRenderingParams;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
299
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
300 FontCache mFontCache;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
301 IDWriteTextFormat *mTextFormat;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
302 DWRITE_FONT_WEIGHT mFontWeight;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
303 DWRITE_FONT_STYLE mFontStyle;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
304
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
305 D2D1_TEXT_ANTIALIAS_MODE mTextAntialiasMode;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
306
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
307 // METHODS
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
308
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
309 DWriteContext();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
310
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
311 virtual ~DWriteContext();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
312
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
313 HRESULT CreateDeviceResources();
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
314
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
315 void DiscardDeviceResources();
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
316
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
317 HRESULT CreateTextFormatFromLOGFONT(const LOGFONTW &logFont,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
318 IDWriteTextFormat **ppTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
319
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
320 HRESULT SetFontByLOGFONT(const LOGFONTW &logFont);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
321
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
322 void SetFont(HFONT hFont);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
323
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
324 void Rebind();
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
325
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
326 void BindDC(HDC hdc, const RECT *rect);
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
327
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
328 HRESULT SetDrawingMode(DrawingMode mode);
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
329
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
330 ID2D1Brush* SolidBrush(COLORREF color);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
331
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
332 void DrawText(const WCHAR *text, int len,
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
333 int x, int y, int w, int h, int cellWidth, COLORREF color,
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
334 UINT fuOptions, const RECT *lprc, const INT *lpDx);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
335
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
336 void FillRect(const RECT *rc, COLORREF color);
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
337
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
338 void DrawLine(int x1, int y1, int x2, int y2, COLORREF color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
339
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
340 void SetPixel(int x, int y, COLORREF color);
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
341
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
342 void Scroll(int x, int y, const RECT *rc);
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
343
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
344 void Flush();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
345
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
346 void SetRenderingParams(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
347 const DWriteRenderingParams *params);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
348
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
349 DWriteRenderingParams *GetRenderingParams(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
350 DWriteRenderingParams *params);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
351 };
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
352
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
353 class AdjustedGlyphRun : public DWRITE_GLYPH_RUN
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
354 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
355 private:
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
356 FLOAT &mAccum;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
357 FLOAT mDelta;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
358 FLOAT *mAdjustedAdvances;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
359
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
360 public:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
361 AdjustedGlyphRun(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
362 const DWRITE_GLYPH_RUN *glyphRun,
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
363 FLOAT cellWidth,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
364 FLOAT &accum) :
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
365 DWRITE_GLYPH_RUN(*glyphRun),
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
366 mAccum(accum),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
367 mDelta(0.0f),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
368 mAdjustedAdvances(new FLOAT[glyphRun->glyphCount])
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
369 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
370 assert(cellWidth != 0.0f);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
371 for (UINT32 i = 0; i < glyphRun->glyphCount; ++i)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
372 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
373 FLOAT orig = glyphRun->glyphAdvances[i];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
374 FLOAT adjusted = adjustToCell(orig, cellWidth);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
375 mAdjustedAdvances[i] = adjusted;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
376 mDelta += adjusted - orig;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
377 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
378 glyphAdvances = mAdjustedAdvances;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
379 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
380
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
381 ~AdjustedGlyphRun()
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
382 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
383 mAccum += mDelta;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
384 delete[] mAdjustedAdvances;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
385 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
386
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
387 static FLOAT adjustToCell(FLOAT value, FLOAT cellWidth)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
388 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
389 int cellCount = int(floor(value / cellWidth + 0.5f));
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
390 if (cellCount < 1)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
391 cellCount = 1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
392 return cellCount * cellWidth;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
393 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
394 };
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
395
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
396 struct TextRendererContext {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
397 // const fields.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
398 COLORREF color;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
399 FLOAT cellWidth;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
400
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
401 // working fields.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
402 FLOAT offsetX;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
403 };
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
404
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
405 class TextRenderer FINAL : public IDWriteTextRenderer
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
406 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
407 public:
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
408 TextRenderer(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
409 DWriteContext* pDWC) :
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
410 cRefCount_(0),
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
411 pDWC_(pDWC)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
412 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
413 AddRef();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
414 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
415
8271
770774e66011 commit https://github.com/vim/vim/commit/edb4f2b3601b0abd47091606269c0ac3244a805b
Christian Brabandt <cb@256bit.org>
parents: 7547
diff changeset
416 // add "virtual" to avoid a compiler warning
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
417 virtual ~TextRenderer()
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
418 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
419 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
420
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
421 IFACEMETHOD(IsPixelSnappingDisabled)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
422 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
423 __out BOOL* isDisabled)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
424 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
425 *isDisabled = FALSE;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
426 return S_OK;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
427 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
428
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
429 IFACEMETHOD(GetCurrentTransform)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
430 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
431 __out DWRITE_MATRIX* transform)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
432 {
8271
770774e66011 commit https://github.com/vim/vim/commit/edb4f2b3601b0abd47091606269c0ac3244a805b
Christian Brabandt <cb@256bit.org>
parents: 7547
diff changeset
433 // forward the render target's transform
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
434 pDWC_->mRT->GetTransform(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
435 reinterpret_cast<D2D1_MATRIX_3X2_F*>(transform));
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
436 return S_OK;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
437 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
438
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
439 IFACEMETHOD(GetPixelsPerDip)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
440 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
441 __out FLOAT* pixelsPerDip)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
442 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
443 float dpiX, unused;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
444 pDWC_->mRT->GetDpi(&dpiX, &unused);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
445 *pixelsPerDip = dpiX / 96.0f;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
446 return S_OK;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
447 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
448
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
449 IFACEMETHOD(DrawUnderline)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
450 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
451 FLOAT baselineOriginX,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
452 FLOAT baselineOriginY,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
453 __in DWRITE_UNDERLINE const* underline,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
454 IUnknown* clientDrawingEffect)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
455 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
456 return E_NOTIMPL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
457 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
458
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
459 IFACEMETHOD(DrawStrikethrough)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
460 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
461 FLOAT baselineOriginX,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
462 FLOAT baselineOriginY,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
463 __in DWRITE_STRIKETHROUGH const* strikethrough,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
464 IUnknown* clientDrawingEffect)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
465 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
466 return E_NOTIMPL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
467 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
468
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
469 IFACEMETHOD(DrawInlineObject)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
470 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
471 FLOAT originX,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
472 FLOAT originY,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
473 IDWriteInlineObject* inlineObject,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
474 BOOL isSideways,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
475 BOOL isRightToLeft,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
476 IUnknown* clientDrawingEffect)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
477 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
478 return E_NOTIMPL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
479 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
480
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
481 IFACEMETHOD(DrawGlyphRun)(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
482 __maybenull void* clientDrawingContext,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
483 FLOAT baselineOriginX,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
484 FLOAT baselineOriginY,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
485 DWRITE_MEASURING_MODE measuringMode,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
486 __in DWRITE_GLYPH_RUN const* glyphRun,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
487 __in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
488 IUnknown* clientDrawingEffect)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
489 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
490 TextRendererContext *context =
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
491 reinterpret_cast<TextRendererContext*>(clientDrawingContext);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
492
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
493 AdjustedGlyphRun adjustedGlyphRun(glyphRun, context->cellWidth,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
494 context->offsetX);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
495
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
496 #ifdef FEAT_DIRECTX_COLOR_EMOJI
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
497 if (pDWC_->mDWriteFactory2 != NULL)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
498 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
499 IDWriteColorGlyphRunEnumerator *enumerator = NULL;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
500 HRESULT hr = pDWC_->mDWriteFactory2->TranslateColorGlyphRun(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
501 baselineOriginX + context->offsetX,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
502 baselineOriginY,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
503 &adjustedGlyphRun,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
504 NULL,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
505 DWRITE_MEASURING_MODE_GDI_NATURAL,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
506 NULL,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
507 0,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
508 &enumerator);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
509 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
510 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
511 // Draw by IDWriteFactory2 for color emoji
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
512 BOOL hasRun = TRUE;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
513 enumerator->MoveNext(&hasRun);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
514 while (hasRun)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
515 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
516 const DWRITE_COLOR_GLYPH_RUN* colorGlyphRun;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
517 enumerator->GetCurrentRun(&colorGlyphRun);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
518
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
519 pDWC_->mBrush->SetColor(colorGlyphRun->runColor);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
520 pDWC_->mRT->DrawGlyphRun(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
521 D2D1::Point2F(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
522 colorGlyphRun->baselineOriginX,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
523 colorGlyphRun->baselineOriginY),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
524 &colorGlyphRun->glyphRun,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
525 pDWC_->mBrush,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
526 DWRITE_MEASURING_MODE_NATURAL);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
527 enumerator->MoveNext(&hasRun);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
528 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
529 SafeRelease(&enumerator);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
530 return S_OK;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
531 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
532 }
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
533 #endif
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
534
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
535 // Draw by IDWriteFactory (without color emoji)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
536 pDWC_->mRT->DrawGlyphRun(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
537 D2D1::Point2F(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
538 baselineOriginX + context->offsetX,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
539 baselineOriginY),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
540 &adjustedGlyphRun,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
541 pDWC_->SolidBrush(context->color),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
542 DWRITE_MEASURING_MODE_NATURAL);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
543 return S_OK;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
544 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
545
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
546 public:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
547 IFACEMETHOD_(unsigned long, AddRef) ()
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
548 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
549 return InterlockedIncrement(&cRefCount_);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
550 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
551
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
552 IFACEMETHOD_(unsigned long, Release) ()
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
553 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
554 long newCount = InterlockedDecrement(&cRefCount_);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
555
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
556 if (newCount == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
557 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
558 delete this;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
559 return 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
560 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
561 return newCount;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
562 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
563
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
564 IFACEMETHOD(QueryInterface)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
565 IID const& riid,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
566 void** ppvObject)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
567 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
568 if (__uuidof(IDWriteTextRenderer) == riid)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
569 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
570 *ppvObject = this;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
571 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
572 else if (__uuidof(IDWritePixelSnapping) == riid)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
573 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
574 *ppvObject = this;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
575 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
576 else if (__uuidof(IUnknown) == riid)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
577 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
578 *ppvObject = this;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
579 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
580 else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
581 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
582 *ppvObject = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
583 return E_FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
584 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
585
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
586 return S_OK;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
587 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
588
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
589 private:
6120
f62b2e76dd80 updated for version 7.4.398
Bram Moolenaar <bram@vim.org>
parents: 6110
diff changeset
590 long cRefCount_;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
591 DWriteContext* pDWC_;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
592 };
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
593
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
594 DWriteContext::DWriteContext() :
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
595 mHDC(NULL),
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
596 mBindRect(),
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
597 mDMode(DM_GDI),
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
598 mInteropHDC(NULL),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
599 mDrawing(false),
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
600 mFallbackDC(false),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
601 mD2D1Factory(NULL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
602 mRT(NULL),
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
603 mGDIRT(NULL),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
604 mBrush(NULL),
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
605 mBitmap(NULL),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
606 mDWriteFactory(NULL),
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
607 #ifdef FEAT_DIRECTX_COLOR_EMOJI
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
608 mDWriteFactory2(NULL),
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
609 #endif
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
610 mGdiInterop(NULL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
611 mRenderingParams(NULL),
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
612 mFontCache(8),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
613 mTextFormat(NULL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
614 mFontWeight(DWRITE_FONT_WEIGHT_NORMAL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
615 mFontStyle(DWRITE_FONT_STYLE_NORMAL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
616 mTextAntialiasMode(D2D1_TEXT_ANTIALIAS_MODE_DEFAULT)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
617 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
618 HRESULT hr;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
619
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
620 hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
621 __uuidof(ID2D1Factory), NULL,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
622 reinterpret_cast<void**>(&mD2D1Factory));
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
623 _RPT2(_CRT_WARN, "D2D1CreateFactory: hr=%p p=%p\n", hr, mD2D1Factory);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
624
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
625 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
626 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
627 hr = DWriteCreateFactory(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
628 DWRITE_FACTORY_TYPE_SHARED,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
629 __uuidof(IDWriteFactory),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
630 reinterpret_cast<IUnknown**>(&mDWriteFactory));
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
631 _RPT2(_CRT_WARN, "DWriteCreateFactory: hr=%p p=%p\n", hr,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
632 mDWriteFactory);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
633 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
634
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
635 #ifdef FEAT_DIRECTX_COLOR_EMOJI
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
636 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
637 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
638 DWriteCreateFactory(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
639 DWRITE_FACTORY_TYPE_SHARED,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
640 __uuidof(IDWriteFactory2),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
641 reinterpret_cast<IUnknown**>(&mDWriteFactory2));
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
642 _RPT1(_CRT_WARN, "IDWriteFactory2: %s\n", SUCCEEDED(hr) ? "available" : "not available");
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
643 }
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
644 #endif
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
645
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
646 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
647 {
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
648 hr = mDWriteFactory->GetGdiInterop(&mGdiInterop);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
649 _RPT2(_CRT_WARN, "GetGdiInterop: hr=%p p=%p\n", hr, mGdiInterop);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
650 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
651
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
652 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
653 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
654 hr = mDWriteFactory->CreateRenderingParams(&mRenderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
655 _RPT2(_CRT_WARN, "CreateRenderingParams: hr=%p p=%p\n", hr,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
656 mRenderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
657 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
658 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
659
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
660 DWriteContext::~DWriteContext()
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
661 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
662 SafeRelease(&mTextFormat);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
663 SafeRelease(&mRenderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
664 SafeRelease(&mGdiInterop);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
665 SafeRelease(&mDWriteFactory);
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
666 #ifdef FEAT_DIRECTX_COLOR_EMOJI
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
667 SafeRelease(&mDWriteFactory2);
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
668 #endif
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
669 SafeRelease(&mBitmap);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
670 SafeRelease(&mBrush);
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
671 SafeRelease(&mGDIRT);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
672 SafeRelease(&mRT);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
673 SafeRelease(&mD2D1Factory);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
674 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
675
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
676 HRESULT
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
677 DWriteContext::CreateDeviceResources()
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
678 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
679 HRESULT hr;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
680
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
681 if (mRT != NULL)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
682 return S_OK;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
683
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
684 D2D1_RENDER_TARGET_PROPERTIES props = {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
685 D2D1_RENDER_TARGET_TYPE_DEFAULT,
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
686 { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE },
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
687 0, 0,
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
688 D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE,
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
689 D2D1_FEATURE_LEVEL_DEFAULT
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
690 };
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
691 hr = mD2D1Factory->CreateDCRenderTarget(&props, &mRT);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
692 _RPT2(_CRT_WARN, "CreateDCRenderTarget: hr=%p p=%p\n", hr, mRT);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
693
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
694 if (SUCCEEDED(hr))
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
695 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
696 // This always succeeds.
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
697 mRT->QueryInterface(
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
698 __uuidof(ID2D1GdiInteropRenderTarget),
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
699 reinterpret_cast<void**>(&mGDIRT));
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
700 _RPT1(_CRT_WARN, "GdiInteropRenderTarget: p=%p\n", mGDIRT);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
701 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
702
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
703 if (SUCCEEDED(hr))
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
704 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
705 hr = mRT->CreateSolidColorBrush(
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
706 D2D1::ColorF(D2D1::ColorF::Black),
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
707 &mBrush);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
708 _RPT2(_CRT_WARN, "CreateSolidColorBrush: hr=%p p=%p\n", hr, mBrush);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
709 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
710
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
711 if (SUCCEEDED(hr))
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
712 Rebind();
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
713
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
714 return hr;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
715 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
716
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
717 void
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
718 DWriteContext::DiscardDeviceResources()
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
719 {
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
720 SafeRelease(&mBitmap);
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
721 SafeRelease(&mBrush);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
722 SafeRelease(&mGDIRT);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
723 SafeRelease(&mRT);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
724 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
725
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
726 HRESULT
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
727 DWriteContext::CreateTextFormatFromLOGFONT(const LOGFONTW &logFont,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
728 IDWriteTextFormat **ppTextFormat)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
729 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
730 // Most of this function is copied from: https://github.com/Microsoft/Windows-classic-samples/blob/master/Samples/Win7Samples/multimedia/DirectWrite/RenderTest/TextHelpers.cpp
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
731 HRESULT hr = S_OK;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
732 IDWriteTextFormat *pTextFormat = NULL;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
733
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
734 IDWriteFont *font = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
735 IDWriteFontFamily *fontFamily = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
736 IDWriteLocalizedStrings *localizedFamilyNames = NULL;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
737 float fontSize = 0;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
738
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
739 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
740 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
741 hr = mGdiInterop->CreateFontFromLOGFONT(&logFont, &font);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
742 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
743
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
744 // Get the font family to which this font belongs.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
745 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
746 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
747 hr = font->GetFontFamily(&fontFamily);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
748 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
749
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
750 // Get the family names. This returns an object that encapsulates one or
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
751 // more names with the same meaning but in different languages.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
752 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
753 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
754 hr = fontFamily->GetFamilyNames(&localizedFamilyNames);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
755 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
756
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
757 // Get the family name at index zero. If we were going to display the name
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
758 // we'd want to try to find one that matched the use locale, but for
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
759 // purposes of creating a text format object any language will do.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
760
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
761 wchar_t familyName[100];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
762 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
763 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
764 hr = localizedFamilyNames->GetString(0, familyName,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
765 ARRAYSIZE(familyName));
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
766 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
767
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
768 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
769 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
770 // Use lfHeight of the LOGFONT as font size.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
771 fontSize = float(logFont.lfHeight);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
772
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
773 if (fontSize < 0)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
774 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
775 // Negative lfHeight represents the size of the em unit.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
776 fontSize = -fontSize;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
777 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
778 else
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
779 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
780 // Positive lfHeight represents the cell height (ascent +
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
781 // descent).
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
782 DWRITE_FONT_METRICS fontMetrics;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
783 font->GetMetrics(&fontMetrics);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
784
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
785 // Convert the cell height (ascent + descent) from design units
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
786 // to ems.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
787 float cellHeight = static_cast<float>(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
788 fontMetrics.ascent + fontMetrics.descent)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
789 / fontMetrics.designUnitsPerEm;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
790
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
791 // Divide the font size by the cell height to get the font em
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
792 // size.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
793 fontSize /= cellHeight;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
794 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
795 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
796
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
797 // The text format includes a locale name. Ideally, this would be the
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
798 // language of the text, which may or may not be the same as the primary
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
799 // language of the user. However, for our purposes the user locale will do.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
800 wchar_t localeName[LOCALE_NAME_MAX_LENGTH];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
801 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
802 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
803 if (GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH) == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
804 hr = HRESULT_FROM_WIN32(GetLastError());
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
805 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
806
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
807 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
808 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
809 // Create the text format object.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
810 hr = mDWriteFactory->CreateTextFormat(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
811 familyName,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
812 NULL, // no custom font collection
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
813 font->GetWeight(),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
814 font->GetStyle(),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
815 font->GetStretch(),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
816 fontSize,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
817 localeName,
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
818 &pTextFormat);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
819 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
820
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
821 if (SUCCEEDED(hr))
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
822 hr = pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
823
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
824 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
825 hr = pTextFormat->SetParagraphAlignment(
16007
6d869997a8b7 patch 8.1.1009: MS-Windows: some text is not baseline aligned
Bram Moolenaar <Bram@vim.org>
parents: 13150
diff changeset
826 DWRITE_PARAGRAPH_ALIGNMENT_FAR);
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
827
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
828 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
829 hr = pTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
830
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
831 SafeRelease(&localizedFamilyNames);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
832 SafeRelease(&fontFamily);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
833 SafeRelease(&font);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
834
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
835 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
836 *ppTextFormat = pTextFormat;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
837 else
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
838 SafeRelease(&pTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
839
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
840 return hr;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
841 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
842
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
843 HRESULT
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
844 DWriteContext::SetFontByLOGFONT(const LOGFONTW &logFont)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
845 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
846 HRESULT hr = S_OK;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
847 IDWriteTextFormat *pTextFormat = NULL;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
848
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
849 hr = CreateTextFormatFromLOGFONT(logFont, &pTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
850
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
851 if (SUCCEEDED(hr))
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
852 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
853 SafeRelease(&mTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
854 mTextFormat = pTextFormat;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
855 mFontWeight = static_cast<DWRITE_FONT_WEIGHT>(logFont.lfWeight);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
856 mFontStyle = logFont.lfItalic ? DWRITE_FONT_STYLE_ITALIC
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
857 : DWRITE_FONT_STYLE_NORMAL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
858 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
859
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
860 return hr;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
861 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
862
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
863 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
864 DWriteContext::SetFont(HFONT hFont)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
865 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
866 FontCache::Item item;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
867 if (mFontCache.get(hFont, item))
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
868 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
869 if (item.pTextFormat != NULL)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
870 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
871 item.pTextFormat->AddRef();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
872 SafeRelease(&mTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
873 mTextFormat = item.pTextFormat;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
874 mFontWeight = item.fontWeight;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
875 mFontStyle = item.fontStyle;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
876 mFallbackDC = false;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
877 }
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
878 else
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
879 mFallbackDC = true;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
880 return;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
881 }
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
882
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
883 HRESULT hr = E_FAIL;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
884 LOGFONTW lf;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
885 if (GetObjectW(hFont, sizeof(lf), &lf))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
886 hr = SetFontByLOGFONT(lf);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
887
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
888 item.hFont = hFont;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
889 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
890 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
891 item.pTextFormat = mTextFormat;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
892 item.fontWeight = mFontWeight;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
893 item.fontStyle = mFontStyle;
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
894 mFallbackDC = false;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
895 }
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
896 else
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
897 mFallbackDC = true;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
898 mFontCache.put(item);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
899 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
900
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
901 void
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
902 DWriteContext::Rebind()
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
903 {
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
904 SafeRelease(&mBitmap);
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
905
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
906 mRT->BindDC(mHDC, &mBindRect);
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
907 mRT->SetTransform(D2D1::IdentityMatrix());
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
908
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
909 D2D1_BITMAP_PROPERTIES props = {
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
910 {DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE},
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
911 96.0f, 96.0f
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
912 };
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
913 mRT->CreateBitmap(
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
914 D2D1::SizeU(mBindRect.right - mBindRect.left,
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
915 mBindRect.bottom - mBindRect.top),
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
916 props, &mBitmap);
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
917 }
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
918
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
919 void
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
920 DWriteContext::BindDC(HDC hdc, const RECT *rect)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
921 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
922 mHDC = hdc;
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
923 mBindRect = *rect;
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
924
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
925 if (mRT == NULL)
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
926 CreateDeviceResources();
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
927 else
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
928 {
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
929 Flush();
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
930 Rebind();
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
931 }
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
932 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
933
16091
e8d8650fa625 patch 8.1.1050: blank srceen when DirectWrite failed
Bram Moolenaar <Bram@vim.org>
parents: 16048
diff changeset
934 extern "C" void redraw_later_clear(void);
e8d8650fa625 patch 8.1.1050: blank srceen when DirectWrite failed
Bram Moolenaar <Bram@vim.org>
parents: 16048
diff changeset
935
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
936 HRESULT
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
937 DWriteContext::SetDrawingMode(DrawingMode mode)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
938 {
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
939 HRESULT hr = S_OK;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
940
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
941 switch (mode)
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
942 {
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
943 default:
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
944 case DM_GDI:
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
945 if (mInteropHDC != NULL)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
946 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
947 mGDIRT->ReleaseDC(NULL);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
948 mInteropHDC = NULL;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
949 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
950 if (mDrawing)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
951 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
952 hr = mRT->EndDraw();
16539
563163ec0244 patch 8.1.1273: compiler warning in direct write code
Bram Moolenaar <Bram@vim.org>
parents: 16091
diff changeset
953 if (hr == (HRESULT)D2DERR_RECREATE_TARGET)
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
954 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
955 hr = S_OK;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
956 DiscardDeviceResources();
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
957 CreateDeviceResources();
16091
e8d8650fa625 patch 8.1.1050: blank srceen when DirectWrite failed
Bram Moolenaar <Bram@vim.org>
parents: 16048
diff changeset
958 redraw_later_clear();
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
959 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
960 mDrawing = false;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
961 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
962 break;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
963
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
964 case DM_DIRECTX:
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
965 if (mInteropHDC != NULL)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
966 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
967 mGDIRT->ReleaseDC(NULL);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
968 mInteropHDC = NULL;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
969 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
970 else if (mDrawing == false)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
971 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
972 CreateDeviceResources();
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
973 mRT->BeginDraw();
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
974 mDrawing = true;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
975 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
976 break;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
977
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
978 case DM_INTEROP:
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
979 if (mDrawing == false)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
980 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
981 CreateDeviceResources();
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
982 mRT->BeginDraw();
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
983 mDrawing = true;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
984 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
985 if (mInteropHDC == NULL)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
986 hr = mGDIRT->GetDC(D2D1_DC_INITIALIZE_MODE_COPY, &mInteropHDC);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
987 break;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
988 }
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
989 mDMode = mode;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
990 return hr;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
991 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
992
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
993 ID2D1Brush*
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
994 DWriteContext::SolidBrush(COLORREF color)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
995 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
996 mBrush->SetColor(D2D1::ColorF(UINT32(GetRValue(color)) << 16 |
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
997 UINT32(GetGValue(color)) << 8 | UINT32(GetBValue(color))));
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
998 return mBrush;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
999 }
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1000
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1001 void
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1002 DWriteContext::DrawText(const WCHAR *text, int len,
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1003 int x, int y, int w, int h, int cellWidth, COLORREF color,
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1004 UINT fuOptions, const RECT *lprc, const INT *lpDx)
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1005 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1006 if (mFallbackDC)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1007 {
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1008 // Fall back to GDI rendering.
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1009 HRESULT hr = SetDrawingMode(DM_INTEROP);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1010 if (SUCCEEDED(hr))
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1011 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1012 HGDIOBJ hFont = ::GetCurrentObject(mHDC, OBJ_FONT);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1013 HGDIOBJ hOldFont = ::SelectObject(mInteropHDC, hFont);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1014 ::SetTextColor(mInteropHDC, color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1015 ::SetBkMode(mInteropHDC, ::GetBkMode(mHDC));
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1016 ::ExtTextOutW(mInteropHDC, x, y, fuOptions, lprc, text, len, lpDx);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1017 ::SelectObject(mInteropHDC, hOldFont);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1018 }
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1019 return;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1020 }
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1021
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1022 HRESULT hr;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1023 IDWriteTextLayout *textLayout = NULL;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1024
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1025 SetDrawingMode(DM_DIRECTX);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1026
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1027 hr = mDWriteFactory->CreateTextLayout(text, len, mTextFormat,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1028 FLOAT(w), FLOAT(h), &textLayout);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1029
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1030 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1031 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1032 DWRITE_TEXT_RANGE textRange = { 0, UINT32(len) };
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1033 textLayout->SetFontWeight(mFontWeight, textRange);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1034 textLayout->SetFontStyle(mFontStyle, textRange);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1035
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1036 TextRenderer renderer(this);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1037 TextRendererContext context = { color, FLOAT(cellWidth), 0.0f };
16048
728bef04b0d4 patch 8.1.1029: DirectWrite doesn't take 'linespace' into account
Bram Moolenaar <Bram@vim.org>
parents: 16007
diff changeset
1038 textLayout->Draw(&context, &renderer, FLOAT(x), FLOAT(y));
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1039 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1040
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1041 SafeRelease(&textLayout);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1042 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1043
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1044 void
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1045 DWriteContext::FillRect(const RECT *rc, COLORREF color)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1046 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1047 if (mDMode == DM_INTEROP)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1048 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1049 // GDI functions are used before this call. Keep using GDI.
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1050 // (Switching to Direct2D causes terrible slowdown.)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1051 HBRUSH hbr = ::CreateSolidBrush(color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1052 ::FillRect(mInteropHDC, rc, hbr);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1053 ::DeleteObject(HGDIOBJ(hbr));
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1054 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1055 else
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1056 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1057 SetDrawingMode(DM_DIRECTX);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1058 mRT->FillRectangle(
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1059 D2D1::RectF(FLOAT(rc->left), FLOAT(rc->top),
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1060 FLOAT(rc->right), FLOAT(rc->bottom)),
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1061 SolidBrush(color));
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1062 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1063 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1064
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1065 void
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1066 DWriteContext::DrawLine(int x1, int y1, int x2, int y2, COLORREF color)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1067 {
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1068 if (mDMode == DM_INTEROP)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1069 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1070 // GDI functions are used before this call. Keep using GDI.
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1071 // (Switching to Direct2D causes terrible slowdown.)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1072 HPEN hpen = ::CreatePen(PS_SOLID, 1, color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1073 HGDIOBJ old_pen = ::SelectObject(mInteropHDC, HGDIOBJ(hpen));
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1074 ::MoveToEx(mInteropHDC, x1, y1, NULL);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1075 ::LineTo(mInteropHDC, x2, y2);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1076 ::SelectObject(mInteropHDC, old_pen);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1077 ::DeleteObject(HGDIOBJ(hpen));
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1078 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1079 else
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1080 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1081 SetDrawingMode(DM_DIRECTX);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1082 mRT->DrawLine(
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1083 D2D1::Point2F(FLOAT(x1), FLOAT(y1) + 0.5f),
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1084 D2D1::Point2F(FLOAT(x2), FLOAT(y2) + 0.5f),
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1085 SolidBrush(color));
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1086 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1087 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1088
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1089 void
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1090 DWriteContext::SetPixel(int x, int y, COLORREF color)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1091 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1092 if (mDMode == DM_INTEROP)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1093 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1094 // GDI functions are used before this call. Keep using GDI.
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1095 // (Switching to Direct2D causes terrible slowdown.)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1096 ::SetPixel(mInteropHDC, x, y, color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1097 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1098 else
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1099 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1100 SetDrawingMode(DM_DIRECTX);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1101 // Direct2D doesn't have SetPixel API. Use DrawLine instead.
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1102 mRT->DrawLine(
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1103 D2D1::Point2F(FLOAT(x), FLOAT(y) + 0.5f),
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1104 D2D1::Point2F(FLOAT(x+1), FLOAT(y) + 0.5f),
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1105 SolidBrush(color));
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1106 }
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1107 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1108
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1109 void
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1110 DWriteContext::Scroll(int x, int y, const RECT *rc)
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1111 {
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1112 SetDrawingMode(DM_DIRECTX);
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1113 mRT->Flush();
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1114
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1115 D2D1_RECT_U srcRect;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1116 D2D1_POINT_2U destPoint;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1117 if (x >= 0)
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1118 {
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1119 srcRect.left = rc->left;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1120 srcRect.right = rc->right - x;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1121 destPoint.x = rc->left + x;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1122 }
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1123 else
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1124 {
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1125 srcRect.left = rc->left - x;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1126 srcRect.right = rc->right;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1127 destPoint.x = rc->left;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1128 }
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1129 if (y >= 0)
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1130 {
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1131 srcRect.top = rc->top;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1132 srcRect.bottom = rc->bottom - y;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1133 destPoint.y = rc->top + y;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1134 }
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1135 else
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1136 {
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1137 srcRect.top = rc->top - y;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1138 srcRect.bottom = rc->bottom;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1139 destPoint.y = rc->top;
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1140 }
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1141 mBitmap->CopyFromRenderTarget(&destPoint, mRT, &srcRect);
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1142
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1143 D2D1_RECT_F destRect = {
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1144 FLOAT(destPoint.x), FLOAT(destPoint.y),
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1145 FLOAT(destPoint.x + srcRect.right - srcRect.left),
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1146 FLOAT(destPoint.y + srcRect.bottom - srcRect.top)
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1147 };
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1148 mRT->DrawBitmap(mBitmap, destRect, 1.0F,
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1149 D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, destRect);
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1150 }
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1151
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1152 void
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1153 DWriteContext::Flush()
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1154 {
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1155 SetDrawingMode(DM_GDI);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1156 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1157
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1158 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1159 DWriteContext::SetRenderingParams(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1160 const DWriteRenderingParams *params)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1161 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1162 if (mDWriteFactory == NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1163 return;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1164
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1165 IDWriteRenderingParams *renderingParams = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1166 D2D1_TEXT_ANTIALIAS_MODE textAntialiasMode =
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1167 D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1168 HRESULT hr;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1169 if (params != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1170 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1171 hr = mDWriteFactory->CreateCustomRenderingParams(params->gamma,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1172 params->enhancedContrast, params->clearTypeLevel,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1173 ToPixelGeometry(params->pixelGeometry),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1174 ToRenderingMode(params->renderingMode), &renderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1175 textAntialiasMode = ToTextAntialiasMode(params->textAntialiasMode);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1176 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1177 else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1178 hr = mDWriteFactory->CreateRenderingParams(&renderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1179 if (SUCCEEDED(hr) && renderingParams != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1180 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1181 SafeRelease(&mRenderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1182 mRenderingParams = renderingParams;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1183 mTextAntialiasMode = textAntialiasMode;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1184
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1185 Flush();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1186 mRT->SetTextRenderingParams(mRenderingParams);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1187 mRT->SetTextAntialiasMode(mTextAntialiasMode);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1188 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1189 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1190
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1191 DWriteRenderingParams *
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1192 DWriteContext::GetRenderingParams(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1193 DWriteRenderingParams *params)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1194 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1195 if (params != NULL && mRenderingParams != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1196 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1197 params->gamma = mRenderingParams->GetGamma();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1198 params->enhancedContrast = mRenderingParams->GetEnhancedContrast();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1199 params->clearTypeLevel = mRenderingParams->GetClearTypeLevel();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1200 params->pixelGeometry = ToInt(mRenderingParams->GetPixelGeometry());
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1201 params->renderingMode = ToInt(mRenderingParams->GetRenderingMode());
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1202 params->textAntialiasMode = mTextAntialiasMode;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1203 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1204 return params;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1205 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1206
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1207 ////////////////////////////////////////////////////////////////////////////
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1208 // PUBLIC C INTERFACES
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1209
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1210 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1211 DWrite_Init(void)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1212 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1213 #ifdef DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1214 // Load libraries.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1215 hD2D1DLL = vimLoadLib(const_cast<char*>("d2d1.dll"));
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1216 hDWriteDLL = vimLoadLib(const_cast<char*>("dwrite.dll"));
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1217 if (hD2D1DLL == NULL || hDWriteDLL == NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1218 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1219 DWrite_Final();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1220 return;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1221 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1222 // Get address of procedures.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1223 pGetUserDefaultLocaleName = (PGETUSERDEFAULTLOCALENAME)GetProcAddress(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1224 GetModuleHandle("kernel32.dll"), "GetUserDefaultLocaleName");
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1225 pD2D1CreateFactory = (PD2D1CREATEFACTORY)GetProcAddress(hD2D1DLL,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1226 "D2D1CreateFactory");
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1227 pDWriteCreateFactory = (PDWRITECREATEFACTORY)GetProcAddress(hDWriteDLL,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1228 "DWriteCreateFactory");
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1229 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1230 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1231
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1232 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1233 DWrite_Final(void)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1234 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1235 #ifdef DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1236 pGetUserDefaultLocaleName = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1237 pD2D1CreateFactory = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1238 pDWriteCreateFactory = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1239 unload(hDWriteDLL);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1240 unload(hD2D1DLL);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1241 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1242 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1243
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1244 DWriteContext *
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1245 DWriteContext_Open(void)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1246 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1247 #ifdef DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1248 if (pGetUserDefaultLocaleName == NULL || pD2D1CreateFactory == NULL
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1249 || pDWriteCreateFactory == NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1250 return NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1251 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1252 return new DWriteContext();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1253 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1254
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1255 void
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1256 DWriteContext_BindDC(DWriteContext *ctx, HDC hdc, const RECT *rect)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1257 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1258 if (ctx != NULL)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1259 ctx->BindDC(hdc, rect);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1260 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1261
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1262 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1263 DWriteContext_SetFont(DWriteContext *ctx, HFONT hFont)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1264 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1265 if (ctx != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1266 ctx->SetFont(hFont);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1267 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1268
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1269 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1270 DWriteContext_DrawText(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1271 DWriteContext *ctx,
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1272 const WCHAR *text,
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1273 int len,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1274 int x,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1275 int y,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1276 int w,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1277 int h,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1278 int cellWidth,
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1279 COLORREF color,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1280 UINT fuOptions,
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1281 const RECT *lprc,
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1282 const INT *lpDx)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1283 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1284 if (ctx != NULL)
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1285 ctx->DrawText(text, len, x, y, w, h, cellWidth, color,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1286 fuOptions, lprc, lpDx);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1287 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1288
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1289 void
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1290 DWriteContext_FillRect(DWriteContext *ctx, const RECT *rc, COLORREF color)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1291 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1292 if (ctx != NULL)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1293 ctx->FillRect(rc, color);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1294 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1295
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1296 void
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1297 DWriteContext_DrawLine(DWriteContext *ctx, int x1, int y1, int x2, int y2,
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1298 COLORREF color)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1299 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1300 if (ctx != NULL)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1301 ctx->DrawLine(x1, y1, x2, y2, color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1302 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1303
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1304 void
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1305 DWriteContext_SetPixel(DWriteContext *ctx, int x, int y, COLORREF color)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1306 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1307 if (ctx != NULL)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1308 ctx->SetPixel(x, y, color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1309 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1310
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
1311 void
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1312 DWriteContext_Scroll(DWriteContext *ctx, int x, int y, const RECT *rc)
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1313 {
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1314 if (ctx != NULL)
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1315 ctx->Scroll(x, y, rc);
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1316 }
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1317
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
1318 void
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1319 DWriteContext_Flush(DWriteContext *ctx)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1320 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1321 if (ctx != NULL)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1322 ctx->Flush();
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1323 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1324
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1325 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1326 DWriteContext_Close(DWriteContext *ctx)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1327 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1328 delete ctx;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1329 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1330
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1331 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1332 DWriteContext_SetRenderingParams(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1333 DWriteContext *ctx,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1334 const DWriteRenderingParams *params)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1335 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1336 if (ctx != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1337 ctx->SetRenderingParams(params);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1338 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1339
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1340 DWriteRenderingParams *
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1341 DWriteContext_GetRenderingParams(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1342 DWriteContext *ctx,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1343 DWriteRenderingParams *params)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1344 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1345 if (ctx != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1346 return ctx->GetRenderingParams(params);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1347 else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1348 return NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1349 }