diff options
author | ananta <ananta@chromium.org> | 2014-10-14 18:14:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-15 01:14:59 +0000 |
commit | acfcfce29176ad1c618359877f481526659b84d4 (patch) | |
tree | 84ade3d4647b76c02b82279bd92ac6057bf6c920 /content/browser/browser_main_runner.cc | |
parent | 34e436590c51c9b4559623b76f268dcb7bd1e32a (diff) | |
download | chromium_src-acfcfce29176ad1c618359877f481526659b84d4.zip chromium_src-acfcfce29176ad1c618359877f481526659b84d4.tar.gz chromium_src-acfcfce29176ad1c618359877f481526659b84d4.tar.bz2 |
Add support for enabling DirectWrite for font rendering in Chrome UI.
This is enabled if Harf Buzz text rendering is enabled and if the enable-directwrite-for-ui switch
is passed in the command line.
To enable DirectWrite we use the SkFontMgr_New_DirectWrite function in skia which sets up skia to use
DirectWrite for font rendering. This is done once during startup.
BUG=389649
Review URL: https://codereview.chromium.org/655613003
Cr-Commit-Position: refs/heads/master@{#299612}
Diffstat (limited to 'content/browser/browser_main_runner.cc')
-rw-r--r-- | content/browser/browser_main_runner.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc index 80869f3..5df5d99 100644 --- a/content/browser/browser_main_runner.cc +++ b/content/browser/browser_main_runner.cc @@ -24,7 +24,12 @@ #include "base/win/windows_version.h" #include "net/cert/sha256_legacy_support_win.h" #include "sandbox/win/src/sidestep/preamble_patcher.h" +#include "skia/ext/fontmgr_default_win.h" +#include "third_party/skia/include/ports/SkFontMgr.h" +#include "third_party/skia/include/ports/SkTypeface_win.h" #include "ui/base/win/scoped_ole_initializer.h" +#include "ui/gfx/switches.h" +#include "ui/gfx/win/direct_write.h" #endif bool g_exited_main_message_loop = false; @@ -110,6 +115,16 @@ void InstallSha256LegacyHooks() { #endif // _WIN64 } +void MaybeEnableDirectWriteFontRendering() { + if (gfx::win::ShouldUseDirectWrite() && + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableDirectWriteForUI) && + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableHarfBuzzRenderText)) { + SetDefaultSkiaFactory(SkFontMgr_New_DirectWrite(NULL)); + } +} + } // namespace #endif // OS_WIN @@ -162,6 +177,8 @@ class BrowserMainRunnerImpl : public BrowserMainRunner { // (Text Services Framework) module can interact with the message pump // on Windows 8 Metro mode. ole_initializer_.reset(new ui::ScopedOleInitializer); + // Enable DirectWrite font rendering if needed. + MaybeEnableDirectWriteFontRendering(); #endif // OS_WIN main_loop_.reset(new BrowserMainLoop(parameters)); |