OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/renderer_main_platform_delegate.h" | 5 #include "content/renderer/renderer_main_platform_delegate.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "base/win/scoped_comptr.h" | 11 #include "base/win/scoped_comptr.h" |
12 #include "base/win/win_util.h" | 12 #include "base/win/win_util.h" |
13 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
14 #include "content/common/sandbox_win.h" | 14 #include "content/common/sandbox_win.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
16 #include "content/public/common/injection_test_win.h" | 16 #include "content/public/common/injection_test_win.h" |
| 17 #include "content/public/renderer/render_font_warmup_win.h" |
17 #include "content/public/renderer/render_thread.h" | 18 #include "content/public/renderer/render_thread.h" |
18 #include "content/renderer/render_thread_impl.h" | 19 #include "content/renderer/render_thread_impl.h" |
19 #include "sandbox/win/src/sandbox.h" | 20 #include "sandbox/win/src/sandbox.h" |
20 #include "skia/ext/vector_platform_device_emf_win.h" | 21 #include "skia/ext/vector_platform_device_emf_win.h" |
21 #include "third_party/WebKit/public/web/win/WebFontRendering.h" | 22 #include "third_party/WebKit/public/web/win/WebFontRendering.h" |
22 #include "third_party/icu/source/i18n/unicode/timezone.h" | 23 #include "third_party/icu/source/i18n/unicode/timezone.h" |
23 #include "third_party/skia/include/ports/SkFontMgr.h" | 24 #include "third_party/skia/include/ports/SkFontMgr.h" |
24 #include "third_party/skia/include/ports/SkTypeface_win.h" | 25 #include "third_party/skia/include/ports/SkTypeface_win.h" |
25 | 26 |
26 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 27 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
(...skipping 18 matching lines...) Expand all Loading... |
45 const wchar_t* text, | 46 const wchar_t* text, |
46 unsigned int text_length) { | 47 unsigned int text_length) { |
47 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); | 48 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
48 if (render_thread_impl) { | 49 if (render_thread_impl) { |
49 render_thread_impl->PreCacheFontCharacters( | 50 render_thread_impl->PreCacheFontCharacters( |
50 logfont, | 51 logfont, |
51 base::string16(text, text_length)); | 52 base::string16(text, text_length)); |
52 } | 53 } |
53 } | 54 } |
54 | 55 |
55 // Windows-only DirectWrite support. These warm up the DirectWrite paths | |
56 // before sandbox lock down to allow Skia access to the Font Manager service. | |
57 void CreateDirectWriteFactory(IDWriteFactory** factory) { | |
58 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc; | |
59 DWriteCreateFactoryProc dwrite_create_factory_proc = | |
60 reinterpret_cast<DWriteCreateFactoryProc>( | |
61 GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory")); | |
62 CHECK(dwrite_create_factory_proc); | |
63 CHECK(SUCCEEDED( | |
64 dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_ISOLATED, | |
65 __uuidof(IDWriteFactory), | |
66 reinterpret_cast<IUnknown**>(factory)))); | |
67 } | |
68 | |
69 void WarmupDirectWrite() { | 56 void WarmupDirectWrite() { |
70 // The objects used here are intentionally not freed as we want the Skia | 57 // The objects used here are intentionally not freed as we want the Skia |
71 // code to use these objects after warmup. | 58 // code to use these objects after warmup. |
72 IDWriteFactory* factory; | 59 SkTypeface* typeface = |
73 CreateDirectWriteFactory(&factory); | 60 GetPreSandboxWarmupFontMgr()->legacyCreateTypeface("Times New Roman", 0); |
74 blink::WebFontRendering::setDirectWriteFactory(factory); | 61 DoPreSandboxWarmupForTypeface(typeface); |
75 SkFontMgr* fontmgr = SkFontMgr_New_DirectWrite(factory); | |
76 SkTypeface* typeface = fontmgr->legacyCreateTypeface("Times New Roman", 0); | |
77 SkPaint paint_warmup; | |
78 paint_warmup.setTypeface(typeface); | |
79 wchar_t glyph = L'S'; | |
80 paint_warmup.measureText(&glyph, 2); | |
81 } | 62 } |
82 | 63 |
83 } // namespace | 64 } // namespace |
84 | 65 |
85 RendererMainPlatformDelegate::RendererMainPlatformDelegate( | 66 RendererMainPlatformDelegate::RendererMainPlatformDelegate( |
86 const MainFunctionParams& parameters) | 67 const MainFunctionParams& parameters) |
87 : parameters_(parameters), | 68 : parameters_(parameters), |
88 sandbox_test_module_(NULL) { | 69 sandbox_test_module_(NULL) { |
89 } | 70 } |
90 | 71 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 if (run_security_tests) { | 158 if (run_security_tests) { |
178 int test_count = 0; | 159 int test_count = 0; |
179 DVLOG(1) << "Running renderer security tests"; | 160 DVLOG(1) << "Running renderer security tests"; |
180 BOOL result = run_security_tests(&test_count); | 161 BOOL result = run_security_tests(&test_count); |
181 CHECK(result) << "Test number " << test_count << " has failed."; | 162 CHECK(result) << "Test number " << test_count << " has failed."; |
182 } | 163 } |
183 } | 164 } |
184 } | 165 } |
185 | 166 |
186 } // namespace content | 167 } // namespace content |
OLD | NEW |