OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" | 5 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" |
6 | 6 |
7 #include <dwrite.h> | 7 #include <dwrite.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 mswr::ComPtr<DWriteFontCollectionProxy> g_font_collection; | 28 mswr::ComPtr<DWriteFontCollectionProxy> g_font_collection; |
29 IPC::Sender* g_sender_override = nullptr; | 29 IPC::Sender* g_sender_override = nullptr; |
30 | 30 |
31 // Windows-only DirectWrite support. These warm up the DirectWrite paths | 31 // Windows-only DirectWrite support. These warm up the DirectWrite paths |
32 // before sandbox lock down to allow Skia access to the Font Manager service. | 32 // before sandbox lock down to allow Skia access to the Font Manager service. |
33 void CreateDirectWriteFactory(IDWriteFactory** factory) { | 33 void CreateDirectWriteFactory(IDWriteFactory** factory) { |
| 34 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc; |
| 35 HMODULE dwrite_dll = LoadLibraryW(L"dwrite.dll"); |
| 36 // TODO(scottmg): Temporary code to track crash in http://crbug.com/387867. |
| 37 if (!dwrite_dll) { |
| 38 DWORD load_library_get_last_error = GetLastError(); |
| 39 base::debug::Alias(&dwrite_dll); |
| 40 base::debug::Alias(&load_library_get_last_error); |
| 41 CHECK(false); |
| 42 } |
| 43 |
34 // This shouldn't be necessary, but not having this causes breakage in | 44 // This shouldn't be necessary, but not having this causes breakage in |
35 // content_browsertests, and possibly other high-stress cases. | 45 // content_browsertests, and possibly other high-stress cases. |
36 PatchServiceManagerCalls(); | 46 PatchServiceManagerCalls(); |
37 | 47 |
38 CHECK(SUCCEEDED(DWriteCreateFactory( | 48 DWriteCreateFactoryProc dwrite_create_factory_proc = |
| 49 reinterpret_cast<DWriteCreateFactoryProc>( |
| 50 GetProcAddress(dwrite_dll, "DWriteCreateFactory")); |
| 51 // TODO(scottmg): Temporary code to track crash in http://crbug.com/387867. |
| 52 if (!dwrite_create_factory_proc) { |
| 53 DWORD get_proc_address_get_last_error = GetLastError(); |
| 54 base::debug::Alias(&dwrite_create_factory_proc); |
| 55 base::debug::Alias(&get_proc_address_get_last_error); |
| 56 CHECK(false); |
| 57 } |
| 58 CHECK(SUCCEEDED(dwrite_create_factory_proc( |
39 DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory), | 59 DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory), |
40 reinterpret_cast<IUnknown**>(factory)))); | 60 reinterpret_cast<IUnknown**>(factory)))); |
41 } | 61 } |
42 | 62 |
43 } // namespace | 63 } // namespace |
44 | 64 |
45 void InitializeDWriteFontProxy() { | 65 void InitializeDWriteFontProxy() { |
46 mswr::ComPtr<IDWriteFactory> factory; | 66 mswr::ComPtr<IDWriteFactory> factory; |
47 | 67 |
48 CreateDirectWriteFactory(&factory); | 68 CreateDirectWriteFactory(&factory); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 void UninitializeDWriteFontProxy() { | 104 void UninitializeDWriteFontProxy() { |
85 if (g_font_collection) | 105 if (g_font_collection) |
86 g_font_collection->Unregister(); | 106 g_font_collection->Unregister(); |
87 } | 107 } |
88 | 108 |
89 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { | 109 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { |
90 g_sender_override = sender; | 110 g_sender_override = sender; |
91 } | 111 } |
92 | 112 |
93 } // namespace content | 113 } // namespace content |
OLD | NEW |