Commit 8150ea60 authored by ananta's avatar ananta Committed by Commit bot

Move the ShouldUseDirectWrite function from sandbox_win.cc/.h to ui/gfx/win/dpi.cc/.h.

This is in preparation for adding DirectWrite support for text rendering in the browser UI.

BUG=389649

Review URL: https://codereview.chromium.org/644813004

Cr-Commit-Position: refs/heads/master@{#299208}
parent 0ecd518d
......@@ -12,7 +12,6 @@
#include "base/debug/trace_event.h"
#include "base/files/file_util.h"
#include "base/hash.h"
#include "base/metrics/field_trial.h"
#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/strings/string_util.h"
......@@ -29,7 +28,7 @@
#include "sandbox/win/src/sandbox.h"
#include "sandbox/win/src/sandbox_nt_util.h"
#include "sandbox/win/src/win_utils.h"
#include "ui/gfx/win/dpi.h"
#include "ui/gfx/win/direct_write.h"
static sandbox::BrokerServices* g_broker_services = NULL;
static sandbox::TargetServices* g_target_services = NULL;
......@@ -578,39 +577,6 @@ bool InitTargetServices(sandbox::TargetServices* target_services) {
return sandbox::SBOX_ALL_OK == result;
}
bool ShouldUseDirectWrite() {
// If the flag is currently on, and we're on Win7 or above, we enable
// DirectWrite. Skia does not require the additions to DirectWrite in QFE
// 2670838, but a simple 'better than XP' check is not enough.
if (base::win::GetVersion() < base::win::VERSION_WIN7)
return false;
base::win::OSInfo::VersionNumber os_version =
base::win::OSInfo::GetInstance()->version_number();
if ((os_version.major == 6) && (os_version.minor == 1)) {
// We can't use DirectWrite for pre-release versions of Windows 7.
if (os_version.build < 7600)
return false;
}
// If forced off, don't use it.
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kDisableDirectWrite))
return false;
#if !defined(NACL_WIN64)
// Can't use GDI on HiDPI.
if (gfx::GetDPIScale() > 1.0f)
return true;
#endif
// Otherwise, check the field trial.
const std::string group_name =
base::FieldTrialList::FindFullName("DirectWrite");
return group_name != "Disabled";
}
base::ProcessHandle StartSandboxedProcess(
SandboxedProcessLauncherDelegate* delegate,
base::CommandLine* cmd_line) {
......@@ -682,13 +648,15 @@ base::ProcessHandle StartSandboxedProcess(
return 0;
if (type_str == switches::kRendererProcess) {
if (ShouldUseDirectWrite()) {
#if !defined(NACL_WIN64)
if (gfx::win::ShouldUseDirectWrite()) {
AddDirectory(base::DIR_WINDOWS_FONTS,
NULL,
true,
sandbox::TargetPolicy::FILES_ALLOW_READONLY,
policy);
}
#endif
} else {
// Hack for Google Desktop crash. Trick GD into not injecting its DLL into
// this subprocess. See
......
......@@ -34,9 +34,6 @@ bool InitBrokerServices(sandbox::BrokerServices* broker_services);
bool InitTargetServices(sandbox::TargetServices* target_services);
// Returns whether DirectWrite font rendering should be used.
CONTENT_EXPORT bool ShouldUseDirectWrite();
} // namespace content
#endif // CONTENT_COMMON_SANDBOX_WIN_H_
......@@ -946,9 +946,6 @@ const char kDisableCoreAnimationPlugins[] =
// Device scale factor passed to certain processes like renderers, etc.
const char kDeviceScaleFactor[] = "device-scale-factor";
// Disables the DirectWrite font rendering system on windows.
const char kDisableDirectWrite[] = "disable-direct-write";
// Disable the Legacy Window which corresponds to the size of the WebContents.
const char kDisableLegacyIntermediateWindow[] = "disable-legacy-window";
......
......@@ -281,7 +281,6 @@ extern const char kDisableCoreAnimationPlugins[];
// This switch contains the device scale factor passed to certain processes
// like renderers, etc.
CONTENT_EXPORT extern const char kDeviceScaleFactor[];
CONTENT_EXPORT extern const char kDisableDirectWrite[];
CONTENT_EXPORT extern const char kDisableLegacyIntermediateWindow[];
// This switch will be removed when we enable the win32K lockdown process
// mitigation.
......
......@@ -11,7 +11,6 @@
#include "base/win/scoped_comptr.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
#include "content/common/sandbox_win.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/injection_test_win.h"
#include "content/public/renderer/render_font_warmup_win.h"
......@@ -25,6 +24,7 @@
#include "third_party/icu/source/i18n/unicode/timezone.h"
#include "third_party/skia/include/ports/SkFontMgr.h"
#include "third_party/skia/include/ports/SkTypeface_win.h"
#include "ui/gfx/win/direct_write.h"
#include "ui/gfx/win/dpi.h"
#ifdef ENABLE_VTUNE_JIT_INTERFACE
......@@ -88,7 +88,7 @@ void RendererMainPlatformDelegate::PlatformInitialize() {
// malicious code if the renderer gets compromised.
bool no_sandbox = command_line.HasSwitch(switches::kNoSandbox);
bool use_direct_write = ShouldUseDirectWrite();
bool use_direct_write = gfx::win::ShouldUseDirectWrite();
if (!no_sandbox) {
// ICU DateFormat class (used in base/time_format.cc) needs to get the
// Olson timezone ID by accessing the registry keys under
......
......@@ -8,7 +8,6 @@
#include "base/command_line.h"
#include "base/debug/debugger.h"
#include "components/web_cache/renderer/web_cache_render_process_observer.h"
#include "content/common/sandbox_win.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/renderer/render_view.h"
......@@ -33,6 +32,7 @@
#include "content/public/renderer/render_font_warmup_win.h"
#include "third_party/WebKit/public/web/win/WebFontRendering.h"
#include "third_party/skia/include/ports/SkFontMgr.h"
#include "ui/gfx/win/direct_write.h"
#endif
using blink::WebAudioDevice;
......@@ -75,7 +75,7 @@ LayoutTestContentRendererClient::LayoutTestContentRendererClient() {
base::Unretained(this)));
#if defined(OS_WIN)
if (ShouldUseDirectWrite())
if (gfx::win::ShouldUseDirectWrite())
RegisterSideloadedTypefaces(GetPreSandboxWarmupFontMgr());
#endif
}
......
......@@ -204,6 +204,8 @@ component("gfx") {
"utf16_indexing.cc",
"utf16_indexing.h",
"vsync_provider.h",
"win/direct_write.cc",
"win/direct_write.h",
"win/dpi.cc",
"win/dpi.h",
"win/hwnd_util.cc",
......
......@@ -301,6 +301,8 @@
'utf16_indexing.cc',
'utf16_indexing.h',
'vsync_provider.h',
'win/direct_write.cc',
'win/direct_write.h',
'win/dpi.cc',
'win/dpi.h',
'win/hwnd_util.cc',
......
......@@ -20,4 +20,9 @@ const char kEnableWebkitTextSubpixelPositioning[] =
// Overrides the device scale factor for the browser UI and the contents.
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";
#endif
} // namespace switches
......@@ -5,6 +5,7 @@
#ifndef UI_GFX_SWITCHES_H_
#define UI_GFX_SWITCHES_H_
#include "build/build_config.h"
#include "ui/gfx/gfx_export.h"
namespace switches {
......@@ -15,6 +16,10 @@ GFX_EXPORT extern const char kEnableHarfBuzzRenderText[];
GFX_EXPORT extern const char kEnableWebkitTextSubpixelPositioning[];
GFX_EXPORT extern const char kForceDeviceScaleFactor[];
#if defined(OS_WIN)
GFX_EXPORT extern const char kDisableDirectWrite[];
#endif
} // namespace switches
#endif // UI_GFX_SWITCHES_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/gfx/win/direct_write.h"
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "base/win/windows_version.h"
#include "ui/gfx/switches.h"
#include "ui/gfx/win/dpi.h"
namespace gfx {
namespace win {
bool ShouldUseDirectWrite() {
// If the flag is currently on, and we're on Win7 or above, we enable
// DirectWrite. Skia does not require the additions to DirectWrite in QFE
// 2670838, but a simple 'better than XP' check is not enough.
if (base::win::GetVersion() < base::win::VERSION_WIN7)
return false;
base::win::OSInfo::VersionNumber os_version =
base::win::OSInfo::GetInstance()->version_number();
if ((os_version.major == 6) && (os_version.minor == 1)) {
// We can't use DirectWrite for pre-release versions of Windows 7.
if (os_version.build < 7600)
return false;
}
// If forced off, don't use it.
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kDisableDirectWrite))
return false;
// Can't use GDI on HiDPI.
if (gfx::GetDPIScale() > 1.0f)
return true;
// Otherwise, check the field trial.
const std::string group_name =
base::FieldTrialList::FindFullName("DirectWrite");
return group_name != "Disabled";
}
} // namespace win
} // namespace gfx
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_GFX_WIN_DIRECT_WRITE_H_
#define UI_GFX_WIN_DIRECT_WRITE_H_
#include "ui/gfx/gfx_export.h"
namespace gfx {
namespace win {
// Returns whether DirectWrite font rendering should be used.
GFX_EXPORT bool ShouldUseDirectWrite();
} // namespace win
} // namespace gfx
#endif // UI_GFX_WIN_DIRECT_WRITE_H_
......@@ -5,12 +5,10 @@
#include "ui/gfx/win/dpi.h"
#include <windows.h>
#include "base/command_line.h"
#include "base/win/scoped_hdc.h"
#include "base/win/windows_version.h"
#include "base/win/registry.h"
#include "ui/gfx/display.h"
#include "ui/gfx/switches.h"
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/size_conversions.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment