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" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 DWriteCreateFactoryProc dwrite_create_factory_proc = | 59 DWriteCreateFactoryProc dwrite_create_factory_proc = |
60 reinterpret_cast<DWriteCreateFactoryProc>( | 60 reinterpret_cast<DWriteCreateFactoryProc>( |
61 GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory")); | 61 GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory")); |
62 CHECK(dwrite_create_factory_proc); | 62 CHECK(dwrite_create_factory_proc); |
63 CHECK(SUCCEEDED( | 63 CHECK(SUCCEEDED( |
64 dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_ISOLATED, | 64 dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_ISOLATED, |
65 __uuidof(IDWriteFactory), | 65 __uuidof(IDWriteFactory), |
66 reinterpret_cast<IUnknown**>(factory)))); | 66 reinterpret_cast<IUnknown**>(factory)))); |
67 } | 67 } |
68 | 68 |
69 void WarmupFontPaint(SkTypeface* typeface) { | |
70 SkPaint paint_warmup; | |
71 paint_warmup.setTypeface(typeface); | |
72 wchar_t glyph = L'S'; | |
73 paint_warmup.measureText(&glyph, 2); | |
74 } | |
75 | |
76 // DirectWrite only has access to %WINDIR%\Fonts by default. For developer | |
77 // side-loading, support kRegisterFontFiles to allow access to additional fonts. | |
78 void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) { | |
79 std::vector<std::string> files; | |
80 if (GetSideloadFontFiles(&files)) { | |
81 for (std::vector<std::string>::const_iterator i(files.begin()); | |
82 i != files.end(); | |
83 ++i) { | |
84 SkTypeface* typeface = fontmgr->createFromFile(i->c_str()); | |
85 WarmupFontPaint(typeface); | |
86 blink::WebFontRendering::addSideloadedFontForTesting(typeface); | |
87 } | |
88 } | |
89 } | |
90 | |
69 void WarmupDirectWrite() { | 91 void WarmupDirectWrite() { |
70 // The objects used here are intentionally not freed as we want the Skia | 92 // The objects used here are intentionally not freed as we want the Skia |
71 // code to use these objects after warmup. | 93 // code to use these objects after warmup. |
72 IDWriteFactory* factory; | 94 IDWriteFactory* factory; |
73 CreateDirectWriteFactory(&factory); | 95 CreateDirectWriteFactory(&factory); |
74 blink::WebFontRendering::setDirectWriteFactory(factory); | 96 blink::WebFontRendering::setDirectWriteFactory(factory); |
75 SkFontMgr* fontmgr = SkFontMgr_New_DirectWrite(factory); | 97 SkFontMgr* fontmgr = SkFontMgr_New_DirectWrite(factory); |
76 SkTypeface* typeface = fontmgr->legacyCreateTypeface("Times New Roman", 0); | 98 SkTypeface* typeface = fontmgr->legacyCreateTypeface("Times New Roman", 0); |
77 SkPaint paint_warmup; | 99 WarmupFontPaint(typeface); |
78 paint_warmup.setTypeface(typeface); | 100 |
79 wchar_t glyph = L'S'; | 101 // Register auxiliary non-system installed fonts. This is primarily for |
80 paint_warmup.measureText(&glyph, 2); | 102 // Blink layout tests. |
jam
2014/04/14 05:40:02
since this is only for layout tests, can you do th
scottmg
2014/04/14 15:48:58
It's mostly for Blink but is useful for testing to
jschuh
2014/04/14 15:58:51
I'm inclined to say keep it in Chrome just to make
jam
2014/04/14 16:20:59
note that testing could still be done using conten
| |
103 RegisterSideloadedTypefaces(fontmgr); | |
81 } | 104 } |
82 | 105 |
83 } // namespace | 106 } // namespace |
84 | 107 |
85 RendererMainPlatformDelegate::RendererMainPlatformDelegate( | 108 RendererMainPlatformDelegate::RendererMainPlatformDelegate( |
86 const MainFunctionParams& parameters) | 109 const MainFunctionParams& parameters) |
87 : parameters_(parameters), | 110 : parameters_(parameters), |
88 sandbox_test_module_(NULL) { | 111 sandbox_test_module_(NULL) { |
89 } | 112 } |
90 | 113 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 if (run_security_tests) { | 200 if (run_security_tests) { |
178 int test_count = 0; | 201 int test_count = 0; |
179 DVLOG(1) << "Running renderer security tests"; | 202 DVLOG(1) << "Running renderer security tests"; |
180 BOOL result = run_security_tests(&test_count); | 203 BOOL result = run_security_tests(&test_count); |
181 CHECK(result) << "Test number " << test_count << " has failed."; | 204 CHECK(result) << "Test number " << test_count << " has failed."; |
182 } | 205 } |
183 } | 206 } |
184 } | 207 } |
185 | 208 |
186 } // namespace content | 209 } // namespace content |
OLD | NEW |