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 "ui/gfx/win/direct_write.h" | 5 #include "ui/gfx/win/direct_write.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/win/registry.h" | 9 #include "base/win/registry.h" |
10 #include "base/win/scoped_comptr.h" | 10 #include "base/win/scoped_comptr.h" |
11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
12 #include "skia/ext/fontmgr_default_win.h" | 12 #include "skia/ext/fontmgr_default_win.h" |
| 13 #include "third_party/skia/include/ports/SkFontMgr.h" |
13 #include "third_party/skia/include/ports/SkTypeface_win.h" | 14 #include "third_party/skia/include/ports/SkTypeface_win.h" |
14 #include "ui/gfx/platform_font_win.h" | 15 #include "ui/gfx/platform_font_win.h" |
15 #include "ui/gfx/switches.h" | 16 #include "ui/gfx/switches.h" |
16 | 17 |
17 namespace gfx { | 18 namespace gfx { |
18 namespace win { | 19 namespace win { |
19 | 20 |
20 void CreateDWriteFactory(IDWriteFactory** factory) { | 21 void CreateDWriteFactory(IDWriteFactory** factory) { |
21 base::win::ScopedComPtr<IUnknown> factory_unknown; | 22 base::win::ScopedComPtr<IUnknown> factory_unknown; |
22 HRESULT hr = | 23 HRESULT hr = |
(...skipping 22 matching lines...) Expand all Loading... |
45 CreateDWriteFactory(factory.Receive()); | 46 CreateDWriteFactory(factory.Receive()); |
46 | 47 |
47 if (!factory) | 48 if (!factory) |
48 return; | 49 return; |
49 | 50 |
50 // The skia call to create a new DirectWrite font manager instance can fail | 51 // The skia call to create a new DirectWrite font manager instance can fail |
51 // if we are unable to get the system font collection from the DirectWrite | 52 // if we are unable to get the system font collection from the DirectWrite |
52 // factory. The GetSystemFontCollection method in the IDWriteFactory | 53 // factory. The GetSystemFontCollection method in the IDWriteFactory |
53 // interface fails with E_INVALIDARG on certain Windows 7 gold versions | 54 // interface fails with E_INVALIDARG on certain Windows 7 gold versions |
54 // (6.1.7600.*). We should just use GDI in these cases. | 55 // (6.1.7600.*). We should just use GDI in these cases. |
55 SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory.get()); | 56 sk_sp<SkFontMgr> direct_write_font_mgr = |
| 57 SkFontMgr_New_DirectWrite(factory.get()); |
56 if (!direct_write_font_mgr) | 58 if (!direct_write_font_mgr) |
57 return; | 59 return; |
58 SetDefaultSkiaFactory(direct_write_font_mgr); | 60 SetDefaultSkiaFactory(std::move(direct_write_font_mgr)); |
59 gfx::PlatformFontWin::SetDirectWriteFactory(factory.get()); | 61 gfx::PlatformFontWin::SetDirectWriteFactory(factory.get()); |
60 } | 62 } |
61 | 63 |
62 } // namespace win | 64 } // namespace win |
63 } // namespace gfx | 65 } // namespace gfx |
OLD | NEW |