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

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

Issue 2204443002: Use ChildThreadImpl::thread_safe_sender in font proxy if available (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
82 // Flash calls into the font proxy from a different thread we will have a
83 // sender available.
84 if (!sender && ChildThreadImpl::current())
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698