OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/font_warmup_win.h" | 5 #include "content/common/font_warmup_win.h" |
6 | 6 |
7 #include <dwrite.h> | 7 #include <dwrite.h> |
8 | 8 |
9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/win/iat_patch_function.h" | 11 #include "base/win/iat_patch_function.h" |
12 #include "base/win/windows_version.h" | 12 #include "base/win/windows_version.h" |
13 #include "content/public/common/dwrite_font_platform_win.h" | 13 #include "content/public/common/dwrite_font_platform_win.h" |
14 #include "skia/ext/fontmgr_default_win.h" | |
15 #include "skia/ext/refptr.h" | |
14 #include "third_party/WebKit/public/web/win/WebFontRendering.h" | 16 #include "third_party/WebKit/public/web/win/WebFontRendering.h" |
15 #include "third_party/skia/include/core/SkPaint.h" | 17 #include "third_party/skia/include/core/SkPaint.h" |
16 #include "third_party/skia/include/ports/SkFontMgr.h" | 18 #include "third_party/skia/include/ports/SkFontMgr.h" |
17 #include "third_party/skia/include/ports/SkTypeface_win.h" | 19 #include "third_party/skia/include/ports/SkTypeface_win.h" |
20 #include "ui/gfx/hud_font.h" | |
18 | 21 |
19 namespace content { | 22 namespace content { |
20 | 23 |
21 namespace { | 24 namespace { |
22 | 25 |
23 SkFontMgr* g_warmup_fontmgr = nullptr; | 26 SkFontMgr* g_warmup_fontmgr = nullptr; |
24 | 27 |
25 base::win::IATPatchFunction g_iat_patch_open_sc_manager; | 28 base::win::IATPatchFunction g_iat_patch_open_sc_manager; |
26 base::win::IATPatchFunction g_iat_patch_close_service_handle; | 29 base::win::IATPatchFunction g_iat_patch_close_service_handle; |
27 base::win::IATPatchFunction g_iat_patch_open_service; | 30 base::win::IATPatchFunction g_iat_patch_open_service; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 GetCustomFontCollection(factory); | 202 GetCustomFontCollection(factory); |
200 | 203 |
201 PatchDWriteFactory(factory); | 204 PatchDWriteFactory(factory); |
202 | 205 |
203 blink::WebFontRendering::setDirectWriteFactory(factory); | 206 blink::WebFontRendering::setDirectWriteFactory(factory); |
204 g_warmup_fontmgr = SkFontMgr_New_DirectWrite(factory); | 207 g_warmup_fontmgr = SkFontMgr_New_DirectWrite(factory); |
205 } | 208 } |
206 return g_warmup_fontmgr; | 209 return g_warmup_fontmgr; |
207 } | 210 } |
208 | 211 |
212 void WarmupDirectWrite() { | |
213 static bool warmup_initialized = false; | |
214 if (warmup_initialized) | |
215 return; | |
216 warmup_initialized = true; | |
jam
2015/09/21 21:26:26
I don't see why these first four lines are needed?
| |
217 // The objects used here are intentionally not freed as we want the Skia | |
218 // code to use these objects after warmup. | |
219 SetDefaultSkiaFactory(GetPreSandboxWarmupFontMgr()); | |
220 | |
221 // We need to warm up *some* font for DirectWrite. We also need to pass one | |
222 // down for the CC HUD code, so use the same one here. Note that we don't use | |
223 // a monospace as would be nice in an attempt to avoid a small startup time | |
224 // regression, see http://crbug.com/463613. | |
225 skia::RefPtr<SkTypeface> hud_typeface = skia::AdoptRef( | |
226 GetPreSandboxWarmupFontMgr()->legacyCreateTypeface("Times New Roman", 0)); | |
227 DoPreSandboxWarmupForTypeface(hud_typeface.get()); | |
228 gfx::SetHudTypeface(hud_typeface); | |
229 } | |
230 | |
209 } // namespace content | 231 } // namespace content |
OLD | NEW |