Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: ui/gfx/win/direct_write.cc

Issue 2111373002: Reland of Link to DirectWrite directly, instead of calling LoadLibrary (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/gfx_tests.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/SkTypeface_win.h" 13 #include "third_party/skia/include/ports/SkTypeface_win.h"
14 #include "ui/gfx/platform_font_win.h" 14 #include "ui/gfx/platform_font_win.h"
15 #include "ui/gfx/switches.h" 15 #include "ui/gfx/switches.h"
16 16
17 namespace gfx { 17 namespace gfx {
18 namespace win { 18 namespace win {
19 19
20 void CreateDWriteFactory(IDWriteFactory** factory) { 20 void CreateDWriteFactory(IDWriteFactory** factory) {
21 using DWriteCreateFactoryProc = decltype(DWriteCreateFactory)*;
22 HMODULE dwrite_dll = LoadLibraryW(L"dwrite.dll");
23 if (!dwrite_dll)
24 return;
25
26 DWriteCreateFactoryProc dwrite_create_factory_proc =
27 reinterpret_cast<DWriteCreateFactoryProc>(
28 GetProcAddress(dwrite_dll, "DWriteCreateFactory"));
29 // Not finding the DWriteCreateFactory function indicates a corrupt dll.
30 if (!dwrite_create_factory_proc)
31 return;
32
33 // Failure to create the DirectWrite factory indicates a corrupt dll.
34 base::win::ScopedComPtr<IUnknown> factory_unknown; 21 base::win::ScopedComPtr<IUnknown> factory_unknown;
35 if (FAILED(dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_SHARED, 22 HRESULT hr =
36 __uuidof(IDWriteFactory), 23 DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
37 factory_unknown.Receive()))) { 24 factory_unknown.Receive());
25 if (FAILED(hr)) {
26 base::debug::Alias(&hr);
27 CHECK(false);
38 return; 28 return;
39 } 29 }
40 factory_unknown.QueryInterface<IDWriteFactory>(factory); 30 factory_unknown.QueryInterface<IDWriteFactory>(factory);
41 } 31 }
42 32
43 void MaybeInitializeDirectWrite() { 33 void MaybeInitializeDirectWrite() {
44 static bool tried_dwrite_initialize = false; 34 static bool tried_dwrite_initialize = false;
45 if (tried_dwrite_initialize) 35 if (tried_dwrite_initialize)
46 return; 36 return;
47 tried_dwrite_initialize = true; 37 tried_dwrite_initialize = true;
(...skipping 16 matching lines...) Expand all
64 // (6.1.7600.*). We should just use GDI in these cases. 54 // (6.1.7600.*). We should just use GDI in these cases.
65 SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory.get()); 55 SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory.get());
66 if (!direct_write_font_mgr) 56 if (!direct_write_font_mgr)
67 return; 57 return;
68 SetDefaultSkiaFactory(direct_write_font_mgr); 58 SetDefaultSkiaFactory(direct_write_font_mgr);
69 gfx::PlatformFontWin::SetDirectWriteFactory(factory.get()); 59 gfx::PlatformFontWin::SetDirectWriteFactory(factory.get());
70 } 60 }
71 61
72 } // namespace win 62 } // namespace win
73 } // namespace gfx 63 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/gfx_tests.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698