Chromium Code Reviews| Index: ui/gfx/win/direct_write.cc |
| diff --git a/ui/gfx/win/direct_write.cc b/ui/gfx/win/direct_write.cc |
| index 38c926a9bd11da661c3e66b614c177427a6bf6ae..cf69be11904c9415d62ff1144f01522311d90e99 100644 |
| --- a/ui/gfx/win/direct_write.cc |
| +++ b/ui/gfx/win/direct_write.cc |
| @@ -24,7 +24,7 @@ namespace win { |
| namespace { |
| static bool dwrite_enabled = false; |
| - |
| +base::win::ScopedComPtr<IDWriteFactory> factory_; |
|
scottmg
2015/11/13 00:51:46
Normally g_factory, instead of factory_.
Ilya Kulshin
2015/11/14 00:25:34
Done.
|
| } |
|
scottmg
2015/11/13 00:51:46
Add newline before }.
Ilya Kulshin
2015/11/14 00:25:34
"git cl format" insists on deleting that newline.
|
| bool ShouldUseDirectWrite() { |
| @@ -81,13 +81,10 @@ void MaybeInitializeDirectWrite() { |
| if (!dwrite_create_factory_proc) |
| return; |
| - base::win::ScopedComPtr<IDWriteFactory> factory; |
| - |
| // Failure to create the DirectWrite factory indicates a corrupt dll. |
| if (FAILED(dwrite_create_factory_proc( |
| - DWRITE_FACTORY_TYPE_SHARED, |
| - __uuidof(IDWriteFactory), |
| - reinterpret_cast<IUnknown**>(factory.Receive())))) |
| + DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), |
| + reinterpret_cast<IUnknown**>(factory_.Receive())))) |
| return; |
| // The skia call to create a new DirectWrite font manager instance can fail |
| @@ -95,17 +92,23 @@ void MaybeInitializeDirectWrite() { |
| // factory. The GetSystemFontCollection method in the IDWriteFactory |
| // interface fails with E_INVALIDARG on certain Windows 7 gold versions |
| // (6.1.7600.*). We should just use GDI in these cases. |
| - SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory.get()); |
| + SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory_.get()); |
| if (!direct_write_font_mgr) |
| return; |
| dwrite_enabled = true; |
| SetDefaultSkiaFactory(direct_write_font_mgr); |
| - gfx::PlatformFontWin::SetDirectWriteFactory(factory.get()); |
| + gfx::PlatformFontWin::SetDirectWriteFactory(factory_.get()); |
| } |
| bool IsDirectWriteEnabled() { |
| return dwrite_enabled; |
| } |
| +void GetDWriteFactory(IDWriteFactory** factory) { |
| + MaybeInitializeDirectWrite(); |
| + base::win::ScopedComPtr<IDWriteFactory> factory_ref = factory_; |
|
scottmg
2015/11/13 00:51:46
It seems like
factory_->AddRef();
*factory =
Ilya Kulshin
2015/11/14 00:25:34
Unfortunately, ScopedComPtr explicitly blocks AddR
|
| + *factory = factory_ref.Detach(); |
| +} |
| + |
| } // namespace win |
| } // namespace gfx |