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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/ppapi_plugin/ppapi_plugin_main.cc
diff --git a/content/ppapi_plugin/ppapi_plugin_main.cc b/content/ppapi_plugin/ppapi_plugin_main.cc
index b20bdd934ec7c8c252494e409ae833b47dc72f46..761ebf31ffd24c8012de51531278721a06f230dd 100644
--- a/content/ppapi_plugin/ppapi_plugin_main.cc
+++ b/content/ppapi_plugin/ppapi_plugin_main.cc
@@ -25,8 +25,18 @@
#include "ui/base/ui_base_switches.h"
#if defined(OS_WIN)
+#include "base/win/win_util.h"
+#include "base/win/windows_version.h"
+#include "content/common/render_font_warmup_win.h"
#include "sandbox/win/src/sandbox.h"
+#include "skia/ext/fontmgr_default_win.h"
+#include "skia/ext/refptr.h"
+#include "third_party/WebKit/public/web/win/WebFontRendering.h"
+#include "third_party/skia/include/ports/SkFontMgr.h"
#include "third_party/skia/include/ports/SkTypeface_win.h"
+#include "ui/gfx/hud_font.h"
+#include "ui/gfx/win/direct_write.h"
+#include "ui/gfx/win/dpi.h"
#endif
#if defined(OS_CHROMEOS)
@@ -57,6 +67,22 @@ void SkiaPreCacheFont(const LOGFONT& logfont) {
ppapi::proxy::PluginGlobals::Get()->PreCacheFontForFlash(
reinterpret_cast<const void*>(&logfont));
}
+
+void WarmupDirectWrite() {
+ // The objects used here are intentionally not freed as we want the Skia
+ // code to use these objects after warmup.
+ SetDefaultSkiaFactory(GetPreSandboxWarmupFontMgr());
+
+ // We need to warm up *some* font for DirectWrite. We also need to pass one
+ // down for the CC HUD code, so use the same one here. Note that we don't use
+ // a monospace as would be nice in an attempt to avoid a small startup time
+ // regression, see http://crbug.com/463613.
+ skia::RefPtr<SkTypeface> hud_typeface = skia::AdoptRef(
+ GetPreSandboxWarmupFontMgr()->legacyCreateTypeface("Times New Roman", 0));
+ DoPreSandboxWarmupForTypeface(hud_typeface.get());
+ gfx::SetHudTypeface(hud_typeface);
+}
+
#endif
} // namespace
@@ -135,7 +161,17 @@ int PpapiPluginMain(const MainFunctionParams& parameters) {
new PpapiThread(parameters.command_line, false)); // Not a broker.
#if defined(OS_WIN)
- SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont);
+ if (IsWin32kLockdownEnabled())
+ gfx::win::MaybeInitializeDirectWrite();
+ bool use_direct_write = gfx::win::IsDirectWriteEnabled();
+ if (use_direct_write) {
+ WarmupDirectWrite();
+ } else {
+ SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont);
+ }
+
+ blink::WebFontRendering::setUseDirectWrite(use_direct_write);
+ blink::WebFontRendering::setDeviceScaleFactor(gfx::GetDPIScale());
#endif
main_message_loop.Run();

Powered by Google App Engine
This is Rietveld 408576698