Chromium Code Reviews| Index: content/common/font_warmup_win.cc |
| diff --git a/content/common/font_warmup_win.cc b/content/common/font_warmup_win.cc |
| index ddc1889d11dd93d52ef67d13e19dd8ee1febda7b..c5d17e06cf16ce4653dbacdecc4e02e0160cc87f 100644 |
| --- a/content/common/font_warmup_win.cc |
| +++ b/content/common/font_warmup_win.cc |
| @@ -20,7 +20,7 @@ |
| #include "base/trace_event/trace_event.h" |
| #include "base/win/iat_patch_function.h" |
| #include "base/win/windows_version.h" |
| -#include "content/public/common/dwrite_font_platform_win.h" |
| +#include "ppapi/shared_impl/proxy_lock.h" |
| #include "skia/ext/fontmgr_default_win.h" |
| #include "skia/ext/refptr.h" |
| #include "third_party/WebKit/public/web/win/WebFontRendering.h" |
| @@ -96,55 +96,6 @@ NTSTATUS WINAPI NtALpcConnectPortPatch(HANDLE* port_handle, |
| return STATUS_ACCESS_DENIED; |
| } |
| -// Windows-only DirectWrite support. These warm up the DirectWrite paths |
| -// before sandbox lock down to allow Skia access to the Font Manager service. |
| -void CreateDirectWriteFactory(IDWriteFactory** factory) { |
| - typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc; |
| - HMODULE dwrite_dll = LoadLibraryW(L"dwrite.dll"); |
| - // TODO(scottmg): Temporary code to track crash in http://crbug.com/387867. |
| - if (!dwrite_dll) { |
| - DWORD load_library_get_last_error = GetLastError(); |
| - base::debug::Alias(&dwrite_dll); |
| - base::debug::Alias(&load_library_get_last_error); |
| - CHECK(false); |
| - } |
| - |
| - PatchServiceManagerCalls(); |
| - |
| - DWriteCreateFactoryProc dwrite_create_factory_proc = |
| - reinterpret_cast<DWriteCreateFactoryProc>( |
| - GetProcAddress(dwrite_dll, "DWriteCreateFactory")); |
| - // TODO(scottmg): Temporary code to track crash in http://crbug.com/387867. |
| - if (!dwrite_create_factory_proc) { |
| - DWORD get_proc_address_get_last_error = GetLastError(); |
| - base::debug::Alias(&dwrite_create_factory_proc); |
| - base::debug::Alias(&get_proc_address_get_last_error); |
| - CHECK(false); |
| - } |
| - CHECK(SUCCEEDED(dwrite_create_factory_proc( |
| - DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory), |
| - reinterpret_cast<IUnknown**>(factory)))); |
| -} |
| - |
| -HRESULT STDMETHODCALLTYPE StubFontCollection(IDWriteFactory* factory, |
| - IDWriteFontCollection** col, |
| - BOOL checkUpdates) { |
| - // We always return pre-created font collection from here. |
| - IDWriteFontCollection* custom_collection = GetCustomFontCollection(factory); |
| - DCHECK(custom_collection != nullptr); |
| - *col = custom_collection; |
| - return S_OK; |
| -} |
| - |
| -void PatchDWriteFactory(IDWriteFactory* factory) { |
| - const unsigned int kGetSystemFontCollectionVTableIndex = 3; |
| - |
| - PROC* vtable = *reinterpret_cast<PROC**>(factory); |
| - PROC* function_ptr = &vtable[kGetSystemFontCollectionVTableIndex]; |
| - void* stub_function = &StubFontCollection; |
| - base::win::ModifyCode(function_ptr, &stub_function, sizeof(PROC)); |
| -} |
| - |
| // Class to fake out a DC or a Font object. Maintains a reference to a |
| // SkTypeFace to emulate the simple operation of a DC and Font. |
| class FakeGdiObject : public base::RefCountedThreadSafe<FakeGdiObject> { |
| @@ -253,6 +204,7 @@ skia::RefPtr<SkTypeface> GetTypefaceFromLOGFONT(const LOGFONTW* log_font) { |
| : SkFontStyle::kUpright_Slant); |
| std::string family_name = base::WideToUTF8(log_font->lfFaceName); |
| + ppapi::ProxyAutoLock lock; |
|
ananta
2015/12/09 23:14:28
Why do we need this?
Ilya Kulshin
2015/12/15 00:05:57
This is called from the ppapi process, which needs
|
| return skia::AdoptRef( |
| g_warmup_fontmgr->matchFamilyStyle(family_name.c_str(), style)); |
| } |
| @@ -461,30 +413,9 @@ void PatchServiceManagerCalls() { |
| DCHECK(patched == 0); |
| } |
| -void DoPreSandboxWarmupForTypeface(SkTypeface* typeface) { |
| - SkPaint paint_warmup; |
| - paint_warmup.setTypeface(typeface); |
| - wchar_t glyph = L'S'; |
| - paint_warmup.measureText(&glyph, 2); |
| -} |
| - |
| -SkFontMgr* GetPreSandboxWarmupFontMgr() { |
| - if (!g_warmup_fontmgr) { |
| - IDWriteFactory* factory; |
| - CreateDirectWriteFactory(&factory); |
| - |
| - GetCustomFontCollection(factory); |
| - |
| - PatchDWriteFactory(factory); |
| - |
| - blink::WebFontRendering::setDirectWriteFactory(factory); |
| - g_warmup_fontmgr = SkFontMgr_New_DirectWrite(factory); |
| - } |
| - return g_warmup_fontmgr; |
| -} |
| - |
| GdiFontPatchData* PatchGdiFontEnumeration(const base::FilePath& path) { |
| // We assume the fontmgr is already warmed up before calling this. |
| + g_warmup_fontmgr = SkFontMgr_New_DirectWrite(); |
| DCHECK(g_warmup_fontmgr); |
| return new GdiFontPatchDataImpl(path); |
| } |
| @@ -497,25 +428,4 @@ void ResetEmulatedGdiHandlesForTesting() { |
| g_fake_gdi_object_factory.Get().ResetObjectHandles(); |
| } |
| -void SetPreSandboxWarmupFontMgrForTesting(SkFontMgr* fontmgr) { |
| - g_warmup_fontmgr = fontmgr; |
| -} |
| - |
| -void WarmupDirectWrite() { |
| - TRACE_EVENT0("startup", "content::WarmupDirectWrite"); |
| - |
| - // The objects used here are intentionally not freed as we want the Skia |
| - // code to use these objects after warmup. |
| - SetDefaultSkiaFactory(GetPreSandboxWarmupFontMgr()); |
| - |
| - // We need to warm up *some* font for DirectWrite. We also need to pass one |
| - // down for the CC HUD code, so use the same one here. Note that we don't use |
| - // a monospace as would be nice in an attempt to avoid a small startup time |
| - // regression, see http://crbug.com/463613. |
| - skia::RefPtr<SkTypeface> hud_typeface = skia::AdoptRef( |
| - GetPreSandboxWarmupFontMgr()->legacyCreateTypeface("Times New Roman", 0)); |
| - DoPreSandboxWarmupForTypeface(hud_typeface.get()); |
| - gfx::SetHudTypeface(hud_typeface); |
| -} |
| - |
| } // namespace content |