| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 | 64 |
| 65 mswr::ComPtr<IDWriteFontFallback> font_fallback; | 65 mswr::ComPtr<IDWriteFontFallback> font_fallback; |
| 66 mswr::ComPtr<IDWriteFactory2> factory2; | 66 mswr::ComPtr<IDWriteFactory2> factory2; |
| 67 | 67 |
| 68 if (SUCCEEDED(factory.As(&factory2)) && factory2.Get()) { | 68 if (SUCCEEDED(factory.As(&factory2)) && factory2.Get()) { |
| 69 mswr::MakeAndInitialize<FontFallback>( | 69 mswr::MakeAndInitialize<FontFallback>( |
| 70 &font_fallback, g_font_collection.Get(), sender); | 70 &font_fallback, g_font_collection.Get(), sender); |
| 71 } | 71 } |
| 72 | 72 |
| 73 sk_sp<SkFontMgr> skia_font_manager(SkFontMgr_New_DirectWrite( | 73 sk_sp<SkFontMgr> skia_font_manager = SkFontMgr_New_DirectWrite( |
| 74 factory.Get(), g_font_collection.Get(), font_fallback.Get())); | 74 factory.Get(), g_font_collection.Get(), font_fallback.Get()); |
| 75 blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get()); | 75 blink::WebFontRendering::setSkiaFontManager(skia_font_manager); |
| 76 | 76 |
| 77 // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't | 77 SetDefaultSkiaFactory(std::move(skia_font_manager)); |
| 78 // addref. | |
| 79 skia_font_manager->ref(); | |
| 80 SetDefaultSkiaFactory(skia_font_manager.get()); | |
| 81 | 78 |
| 82 // When IDWriteFontFallback is not available (prior to Win8.1) Skia will | 79 // When IDWriteFontFallback is not available (prior to Win8.1) Skia will |
| 83 // still attempt to use DirectWrite to determine fallback fonts (in | 80 // still attempt to use DirectWrite to determine fallback fonts (in |
| 84 // SkFontMgr_DirectWrite::onMatchFamilyStyleCharacter), which will likely | 81 // SkFontMgr_DirectWrite::onMatchFamilyStyleCharacter), which will likely |
| 85 // result in trying to load the system font collection. To avoid that and | 82 // result in trying to load the system font collection. To avoid that and |
| 86 // instead fall back on WebKit's fallback logic, we don't use Skia's font | 83 // instead fall back on WebKit's fallback logic, we don't use Skia's font |
| 87 // fallback if IDWriteFontFallback is not available. | 84 // fallback if IDWriteFontFallback is not available. |
| 88 // This flag can be removed when Win8.0 and earlier are no longer supported. | 85 // This flag can be removed when Win8.0 and earlier are no longer supported. |
| 89 bool fallback_available = font_fallback.Get() != nullptr; | 86 bool fallback_available = font_fallback.Get() != nullptr; |
| 90 DCHECK_EQ(fallback_available, | 87 DCHECK_EQ(fallback_available, |
| 91 base::win::GetVersion() > base::win::VERSION_WIN8); | 88 base::win::GetVersion() > base::win::VERSION_WIN8); |
| 92 blink::WebFontRendering::setUseSkiaFontFallback(fallback_available); | 89 blink::WebFontRendering::setUseSkiaFontFallback(fallback_available); |
| 93 } | 90 } |
| 94 | 91 |
| 95 void UninitializeDWriteFontProxy() { | 92 void UninitializeDWriteFontProxy() { |
| 96 if (g_font_collection) | 93 if (g_font_collection) |
| 97 g_font_collection->Unregister(); | 94 g_font_collection->Unregister(); |
| 98 } | 95 } |
| 99 | 96 |
| 100 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { | 97 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { |
| 101 g_sender_override = sender; | 98 g_sender_override = sender; |
| 102 } | 99 } |
| 103 | 100 |
| 104 } // namespace content | 101 } // namespace content |
| OLD | NEW |