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

Side by Side Diff: content/ppapi_plugin/ppapi_plugin_main.cc

Issue 1325843002: Added directwrite warmup for PPAPI processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_win32k_enable_policy
Patch Set: Made win32k lockdown check a lazy instance. Created 5 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/debug/debugger.h" 7 #include "base/debug/debugger.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/child/child_process.h" 14 #include "content/child/child_process.h"
15 #include "content/common/content_constants_internal.h" 15 #include "content/common/content_constants_internal.h"
16 #include "content/common/sandbox_linux/sandbox_linux.h" 16 #include "content/common/sandbox_linux/sandbox_linux.h"
17 #include "content/ppapi_plugin/ppapi_thread.h" 17 #include "content/ppapi_plugin/ppapi_thread.h"
18 #include "content/public/common/content_client.h" 18 #include "content/public/common/content_client.h"
19 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
20 #include "content/public/common/main_function_params.h" 20 #include "content/public/common/main_function_params.h"
21 #include "content/public/plugin/content_plugin_client.h" 21 #include "content/public/plugin/content_plugin_client.h"
22 #include "crypto/nss_util.h" 22 #include "crypto/nss_util.h"
23 #include "ppapi/proxy/plugin_globals.h" 23 #include "ppapi/proxy/plugin_globals.h"
24 #include "ppapi/proxy/proxy_module.h" 24 #include "ppapi/proxy/proxy_module.h"
25 #include "ui/base/ui_base_switches.h" 25 #include "ui/base/ui_base_switches.h"
26 26
27 #if defined(OS_WIN) 27 #if defined(OS_WIN)
28 #include "base/win/win_util.h"
29 #include "base/win/windows_version.h"
30 #include "content/common/render_font_warmup_win.h"
28 #include "sandbox/win/src/sandbox.h" 31 #include "sandbox/win/src/sandbox.h"
32 #include "skia/ext/fontmgr_default_win.h"
33 #include "skia/ext/refptr.h"
34 #include "third_party/WebKit/public/web/win/WebFontRendering.h"
35 #include "third_party/skia/include/ports/SkFontMgr.h"
29 #include "third_party/skia/include/ports/SkTypeface_win.h" 36 #include "third_party/skia/include/ports/SkTypeface_win.h"
37 #include "ui/gfx/hud_font.h"
38 #include "ui/gfx/win/direct_write.h"
39 #include "ui/gfx/win/dpi.h"
30 #endif 40 #endif
31 41
32 #if defined(OS_CHROMEOS) 42 #if defined(OS_CHROMEOS)
33 #include "base/files/file_util.h" 43 #include "base/files/file_util.h"
34 #endif 44 #endif
35 45
36 #if defined(OS_LINUX) 46 #if defined(OS_LINUX)
37 #include "content/public/common/sandbox_init.h" 47 #include "content/public/common/sandbox_init.h"
38 #endif 48 #endif
39 49
(...skipping 10 matching lines...) Expand all
50 namespace content { 60 namespace content {
51 61
52 namespace { 62 namespace {
53 63
54 #if defined(OS_WIN) 64 #if defined(OS_WIN)
55 // Windows-only skia sandbox support 65 // Windows-only skia sandbox support
56 void SkiaPreCacheFont(const LOGFONT& logfont) { 66 void SkiaPreCacheFont(const LOGFONT& logfont) {
57 ppapi::proxy::PluginGlobals::Get()->PreCacheFontForFlash( 67 ppapi::proxy::PluginGlobals::Get()->PreCacheFontForFlash(
58 reinterpret_cast<const void*>(&logfont)); 68 reinterpret_cast<const void*>(&logfont));
59 } 69 }
70
71 void WarmupDirectWrite() {
72 // The objects used here are intentionally not freed as we want the Skia
73 // code to use these objects after warmup.
74 SetDefaultSkiaFactory(GetPreSandboxWarmupFontMgr());
75
76 // We need to warm up *some* font for DirectWrite. We also need to pass one
77 // down for the CC HUD code, so use the same one here. Note that we don't use
78 // a monospace as would be nice in an attempt to avoid a small startup time
79 // regression, see http://crbug.com/463613.
80 skia::RefPtr<SkTypeface> hud_typeface = skia::AdoptRef(
81 GetPreSandboxWarmupFontMgr()->legacyCreateTypeface("Times New Roman", 0));
82 DoPreSandboxWarmupForTypeface(hud_typeface.get());
83 gfx::SetHudTypeface(hud_typeface);
84 }
85
60 #endif 86 #endif
61 87
62 } // namespace 88 } // namespace
63 89
64 // Main function for starting the PPAPI plugin process. 90 // Main function for starting the PPAPI plugin process.
65 int PpapiPluginMain(const MainFunctionParams& parameters) { 91 int PpapiPluginMain(const MainFunctionParams& parameters) {
66 const base::CommandLine& command_line = parameters.command_line; 92 const base::CommandLine& command_line = parameters.command_line;
67 93
68 #if defined(OS_WIN) 94 #if defined(OS_WIN)
69 g_target_services = parameters.sandbox_info->target_services; 95 g_target_services = parameters.sandbox_info->target_services;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 154
129 #if defined(OS_LINUX) 155 #if defined(OS_LINUX)
130 LinuxSandbox::InitializeSandbox(); 156 LinuxSandbox::InitializeSandbox();
131 #endif 157 #endif
132 158
133 ChildProcess ppapi_process; 159 ChildProcess ppapi_process;
134 ppapi_process.set_main_thread( 160 ppapi_process.set_main_thread(
135 new PpapiThread(parameters.command_line, false)); // Not a broker. 161 new PpapiThread(parameters.command_line, false)); // Not a broker.
136 162
137 #if defined(OS_WIN) 163 #if defined(OS_WIN)
138 SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont); 164 if (IsWin32kLockdownEnabled())
165 gfx::win::MaybeInitializeDirectWrite();
166 bool use_direct_write = gfx::win::IsDirectWriteEnabled();
167 if (use_direct_write) {
168 WarmupDirectWrite();
169 } else {
170 SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont);
171 }
172
173 blink::WebFontRendering::setUseDirectWrite(use_direct_write);
174 blink::WebFontRendering::setDeviceScaleFactor(gfx::GetDPIScale());
139 #endif 175 #endif
140 176
141 main_message_loop.Run(); 177 main_message_loop.Run();
142 return 0; 178 return 0;
143 } 179 }
144 180
145 } // namespace content 181 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698