summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorananta <ananta@chromium.org>2014-10-14 18:14:11 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-15 01:14:59 +0000
commitacfcfce29176ad1c618359877f481526659b84d4 (patch)
tree84ade3d4647b76c02b82279bd92ac6057bf6c920
parent34e436590c51c9b4559623b76f268dcb7bd1e32a (diff)
downloadchromium_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}
-rw-r--r--content/browser/browser_main_runner.cc17
-rw-r--r--ui/gfx/switches.cc3
-rw-r--r--ui/gfx/switches.h1
3 files changed, 21 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));
diff --git a/ui/gfx/switches.cc b/ui/gfx/switches.cc
index 4a0299f..90813d0 100644
--- a/ui/gfx/switches.cc
+++ b/ui/gfx/switches.cc
@@ -23,6 +23,9 @@ const char kForceDeviceScaleFactor[] = "force-device-scale-factor";
#if defined(OS_WIN)
// Disables the DirectWrite font rendering system on windows.
const char kDisableDirectWrite[] = "disable-direct-write";
+
+// Enables DirectWrite font rendering for general UI elements.
+const char kEnableDirectWriteForUI[] = "enable-directwrite-for-ui";
#endif
} // namespace switches
diff --git a/ui/gfx/switches.h b/ui/gfx/switches.h
index 77d7dd5..e85dabf 100644
--- a/ui/gfx/switches.h
+++ b/ui/gfx/switches.h
@@ -18,6 +18,7 @@ GFX_EXPORT extern const char kForceDeviceScaleFactor[];
#if defined(OS_WIN)
GFX_EXPORT extern const char kDisableDirectWrite[];
+GFX_EXPORT extern const char kEnableDirectWriteForUI[];
#endif
} // namespace switches