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