| 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" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 reinterpret_cast<IUnknown**>(factory)))); | 62 reinterpret_cast<IUnknown**>(factory)))); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 void InitializeDWriteFontProxy() { | 67 void InitializeDWriteFontProxy() { |
| 68 mswr::ComPtr<IDWriteFactory> factory; | 68 mswr::ComPtr<IDWriteFactory> factory; |
| 69 | 69 |
| 70 CreateDirectWriteFactory(&factory); | 70 CreateDirectWriteFactory(&factory); |
| 71 | 71 |
| 72 if (!g_font_collection) { | |
| 73 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( | |
| 74 &g_font_collection, factory.Get(), g_sender_override); | |
| 75 } | |
| 76 | |
| 77 mswr::ComPtr<IDWriteFontFallback> font_fallback; | |
| 78 mswr::ComPtr<IDWriteFactory2> factory2; | |
| 79 IPC::Sender* sender = g_sender_override; | 72 IPC::Sender* sender = g_sender_override; |
| 80 | 73 |
| 81 // Hack for crbug.com/631254: set the sender if we can get one, so that when | 74 // Hack for crbug.com/631254: set the sender if we can get one, so that when |
| 82 // Flash calls into the font proxy from a different thread we will have a | 75 // Flash calls into the font proxy from a different thread we will have a |
| 83 // sender available. | 76 // sender available. |
| 84 if (!sender && ChildThreadImpl::current()) | 77 if (!sender && ChildThreadImpl::current()) |
| 85 sender = ChildThreadImpl::current()->thread_safe_sender(); | 78 sender = ChildThreadImpl::current()->thread_safe_sender(); |
| 86 | 79 |
| 80 if (!g_font_collection) { |
| 81 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( |
| 82 &g_font_collection, factory.Get(), sender); |
| 83 } |
| 84 |
| 85 mswr::ComPtr<IDWriteFontFallback> font_fallback; |
| 86 mswr::ComPtr<IDWriteFactory2> factory2; |
| 87 |
| 87 if (SUCCEEDED(factory.As(&factory2)) && factory2.Get()) { | 88 if (SUCCEEDED(factory.As(&factory2)) && factory2.Get()) { |
| 88 mswr::MakeAndInitialize<FontFallback>( | 89 mswr::MakeAndInitialize<FontFallback>( |
| 89 &font_fallback, g_font_collection.Get(), sender); | 90 &font_fallback, g_font_collection.Get(), sender); |
| 90 } | 91 } |
| 91 | 92 |
| 92 sk_sp<SkFontMgr> skia_font_manager(SkFontMgr_New_DirectWrite( | 93 sk_sp<SkFontMgr> skia_font_manager(SkFontMgr_New_DirectWrite( |
| 93 factory.Get(), g_font_collection.Get(), font_fallback.Get())); | 94 factory.Get(), g_font_collection.Get(), font_fallback.Get())); |
| 94 blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get()); | 95 blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get()); |
| 95 | 96 |
| 96 // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't | 97 // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't |
| (...skipping 17 matching lines...) Expand all Loading... |
| 114 void UninitializeDWriteFontProxy() { | 115 void UninitializeDWriteFontProxy() { |
| 115 if (g_font_collection) | 116 if (g_font_collection) |
| 116 g_font_collection->Unregister(); | 117 g_font_collection->Unregister(); |
| 117 } | 118 } |
| 118 | 119 |
| 119 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { | 120 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { |
| 120 g_sender_override = sender; | 121 g_sender_override = sender; |
| 121 } | 122 } |
| 122 | 123 |
| 123 } // namespace content | 124 } // namespace content |
| OLD | NEW |