Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1573)

Side by Side Diff: content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc

Issue 1846433005: Implement direct write fallback proxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a missing SUCCEEDED call Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/dwrite_font_proxy/dwrite_font_proxy_win.h" 14 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h"
15 #include "content/child/dwrite_font_proxy/font_fallback_win.h"
15 #include "content/child/font_warmup_win.h" 16 #include "content/child/font_warmup_win.h"
16 #include "skia/ext/fontmgr_default_win.h" 17 #include "skia/ext/fontmgr_default_win.h"
17 #include "third_party/WebKit/public/web/win/WebFontRendering.h" 18 #include "third_party/WebKit/public/web/win/WebFontRendering.h"
18 #include "third_party/skia/include/ports/SkFontMgr.h" 19 #include "third_party/skia/include/ports/SkFontMgr.h"
19 #include "third_party/skia/include/ports/SkTypeface_win.h" 20 #include "third_party/skia/include/ports/SkTypeface_win.h"
20 21
21 namespace mswr = Microsoft::WRL; 22 namespace mswr = Microsoft::WRL;
22 23
23 namespace content { 24 namespace content {
24 25
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 void InitializeDWriteFontProxy() { 65 void InitializeDWriteFontProxy() {
65 mswr::ComPtr<IDWriteFactory> factory; 66 mswr::ComPtr<IDWriteFactory> factory;
66 67
67 CreateDirectWriteFactory(&factory); 68 CreateDirectWriteFactory(&factory);
68 69
69 if (!g_font_collection) { 70 if (!g_font_collection) {
70 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( 71 mswr::MakeAndInitialize<DWriteFontCollectionProxy>(
71 &g_font_collection, factory.Get(), g_sender_override); 72 &g_font_collection, factory.Get(), g_sender_override);
72 } 73 }
73 74
74 sk_sp<SkFontMgr> skia_font_manager( 75 mswr::ComPtr<IDWriteFontFallback> font_fallback;
75 SkFontMgr_New_DirectWrite(factory.Get(), g_font_collection.Get())); 76 mswr::ComPtr<IDWriteFactory2> factory2;
77 if (SUCCEEDED(factory.As(&factory2)) && factory2.Get()) {
78 mswr::MakeAndInitialize<FontFallback>(
79 &font_fallback, g_font_collection.Get(), g_sender_override);
80 }
81
82 sk_sp<SkFontMgr> skia_font_manager(SkFontMgr_New_DirectWrite(
83 factory.Get(), g_font_collection.Get(), font_fallback.Get()));
76 blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get()); 84 blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get());
77 85
78 // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't 86 // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't
79 // addref. 87 // addref.
80 skia_font_manager->ref(); 88 skia_font_manager->ref();
81 SetDefaultSkiaFactory(skia_font_manager.get()); 89 SetDefaultSkiaFactory(skia_font_manager.get());
82 } 90 }
83 91
84 void UninitializeDWriteFontProxy() { 92 void UninitializeDWriteFontProxy() {
85 if (g_font_collection) 93 if (g_font_collection)
86 g_font_collection->Unregister(); 94 g_font_collection->Unregister();
87 } 95 }
88 96
89 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { 97 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) {
90 g_sender_override = sender; 98 g_sender_override = sender;
91 } 99 }
92 100
93 } // namespace content 101 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698