Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" | 5 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" |
| 6 | 6 |
| 7 #include <dwrite.h> | 7 #include <dwrite.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/debug/alias.h" | 11 #include "base/debug/alias.h" |
| 12 #include "base/win/iat_patch_function.h" | 12 #include "base/win/iat_patch_function.h" |
| 13 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
| 14 #include "content/child/child_thread_impl.h" | |
| 14 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" | 15 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" |
| 15 #include "content/child/dwrite_font_proxy/font_fallback_win.h" | 16 #include "content/child/dwrite_font_proxy/font_fallback_win.h" |
| 16 #include "content/child/font_warmup_win.h" | 17 #include "content/child/font_warmup_win.h" |
| 18 #include "content/child/thread_safe_sender.h" | |
| 17 #include "skia/ext/fontmgr_default_win.h" | 19 #include "skia/ext/fontmgr_default_win.h" |
| 18 #include "third_party/WebKit/public/web/win/WebFontRendering.h" | 20 #include "third_party/WebKit/public/web/win/WebFontRendering.h" |
| 19 #include "third_party/skia/include/ports/SkFontMgr.h" | 21 #include "third_party/skia/include/ports/SkFontMgr.h" |
| 20 #include "third_party/skia/include/ports/SkTypeface_win.h" | 22 #include "third_party/skia/include/ports/SkTypeface_win.h" |
| 21 | 23 |
| 22 namespace mswr = Microsoft::WRL; | 24 namespace mswr = Microsoft::WRL; |
| 23 | 25 |
| 24 namespace content { | 26 namespace content { |
| 25 | 27 |
| 26 namespace { | 28 namespace { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 69 |
| 68 CreateDirectWriteFactory(&factory); | 70 CreateDirectWriteFactory(&factory); |
| 69 | 71 |
| 70 if (!g_font_collection) { | 72 if (!g_font_collection) { |
| 71 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( | 73 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( |
| 72 &g_font_collection, factory.Get(), g_sender_override); | 74 &g_font_collection, factory.Get(), g_sender_override); |
| 73 } | 75 } |
| 74 | 76 |
| 75 mswr::ComPtr<IDWriteFontFallback> font_fallback; | 77 mswr::ComPtr<IDWriteFontFallback> font_fallback; |
| 76 mswr::ComPtr<IDWriteFactory2> factory2; | 78 mswr::ComPtr<IDWriteFactory2> factory2; |
| 79 IPC::Sender* sender = g_sender_override; | |
| 80 | |
| 81 // Hack for crbug.com/631254: set the sender if we can get one, so that when | |
|
jam
2016/07/28 22:04:43
nit: saying hack makes it sound like this should b
Ilya Kulshin
2016/07/28 22:10:41
This should be fixed properly. One possible fix we
jam
2016/07/29 22:34:58
I don't understand this comment. That's what the S
| |
| 82 // Flash calls into the font proxy from a different thread we will have a | |
| 83 // sender available. | |
| 84 if (!sender && ChildThreadImpl::current()) | |
|
jam
2016/07/28 22:04:43
are you sure you need the ChildThreadImpl::current
Ilya Kulshin
2016/07/28 22:10:41
Yes, otherwise it crashes in the renderer because
| |
| 85 sender = ChildThreadImpl::current()->thread_safe_sender(); | |
| 86 | |
| 77 if (SUCCEEDED(factory.As(&factory2)) && factory2.Get()) { | 87 if (SUCCEEDED(factory.As(&factory2)) && factory2.Get()) { |
| 78 mswr::MakeAndInitialize<FontFallback>( | 88 mswr::MakeAndInitialize<FontFallback>( |
| 79 &font_fallback, g_font_collection.Get(), g_sender_override); | 89 &font_fallback, g_font_collection.Get(), sender); |
| 80 } | 90 } |
| 81 | 91 |
| 82 sk_sp<SkFontMgr> skia_font_manager(SkFontMgr_New_DirectWrite( | 92 sk_sp<SkFontMgr> skia_font_manager(SkFontMgr_New_DirectWrite( |
| 83 factory.Get(), g_font_collection.Get(), font_fallback.Get())); | 93 factory.Get(), g_font_collection.Get(), font_fallback.Get())); |
| 84 blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get()); | 94 blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get()); |
| 85 | 95 |
| 86 // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't | 96 // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't |
| 87 // addref. | 97 // addref. |
| 88 skia_font_manager->ref(); | 98 skia_font_manager->ref(); |
| 89 SetDefaultSkiaFactory(skia_font_manager.get()); | 99 SetDefaultSkiaFactory(skia_font_manager.get()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 104 void UninitializeDWriteFontProxy() { | 114 void UninitializeDWriteFontProxy() { |
| 105 if (g_font_collection) | 115 if (g_font_collection) |
| 106 g_font_collection->Unregister(); | 116 g_font_collection->Unregister(); |
| 107 } | 117 } |
| 108 | 118 |
| 109 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { | 119 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { |
| 110 g_sender_override = sender; | 120 g_sender_override = sender; |
| 111 } | 121 } |
| 112 | 122 |
| 113 } // namespace content | 123 } // namespace content |
| OLD | NEW |