summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/gpu/gpu_data_manager_impl.cc5
-rw-r--r--content/browser/gpu/gpu_data_manager_impl.h1
-rw-r--r--content/browser/gpu/gpu_data_manager_impl_private.cc40
-rw-r--r--content/browser/gpu/gpu_data_manager_impl_private.h12
-rw-r--r--content/browser/gpu/gpu_data_manager_impl_private_unittest.cc20
-rw-r--r--content/browser/gpu/gpu_internals_ui.cc4
6 files changed, 78 insertions, 4 deletions
diff --git a/content/browser/gpu/gpu_data_manager_impl.cc b/content/browser/gpu/gpu_data_manager_impl.cc
index 93d15c7..b53f4a0 100644
--- a/content/browser/gpu/gpu_data_manager_impl.cc
+++ b/content/browser/gpu/gpu_data_manager_impl.cc
@@ -76,6 +76,11 @@ void GpuDataManagerImpl::RegisterSwiftShaderPath(
private_->RegisterSwiftShaderPath(path);
}
+bool GpuDataManagerImpl::ShouldUseWarp() const {
+ base::AutoLock auto_lock(lock_);
+ return private_->ShouldUseWarp();
+}
+
void GpuDataManagerImpl::AddObserver(
GpuDataManagerObserver* observer) {
base::AutoLock auto_lock(lock_);
diff --git a/content/browser/gpu/gpu_data_manager_impl.h b/content/browser/gpu/gpu_data_manager_impl.h
index c812165..e49b6b5 100644
--- a/content/browser/gpu/gpu_data_manager_impl.h
+++ b/content/browser/gpu/gpu_data_manager_impl.h
@@ -71,6 +71,7 @@ class CONTENT_EXPORT GpuDataManagerImpl
virtual void RequestVideoMemoryUsageStatsUpdate() const OVERRIDE;
virtual bool ShouldUseSwiftShader() const OVERRIDE;
virtual void RegisterSwiftShaderPath(const base::FilePath& path) OVERRIDE;
+ virtual bool ShouldUseWarp() const OVERRIDE;
virtual void AddObserver(GpuDataManagerObserver* observer) OVERRIDE;
virtual void RemoveObserver(GpuDataManagerObserver* observer) OVERRIDE;
virtual void UnblockDomainFrom3DAPIs(const GURL& url) OVERRIDE;
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc
index fd705c8..2f362d6 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.cc
+++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
@@ -271,7 +271,7 @@ bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const {
return true;
}
#endif // OS_CHROMEOS
- if (use_swiftshader_) {
+ if (use_swiftshader_ || ShouldUseWarp()) {
// Skia's software rendering is probably more efficient than going through
// software emulation of the GPU, so use that.
if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)
@@ -287,7 +287,7 @@ bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const {
}
size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const {
- if (use_swiftshader_)
+ if (use_swiftshader_ || ShouldUseWarp())
return 1;
return blacklisted_features_.size();
}
@@ -311,7 +311,7 @@ void GpuDataManagerImplPrivate::GetGpuProcessHandles(
bool GpuDataManagerImplPrivate::GpuAccessAllowed(
std::string* reason) const {
- if (use_swiftshader_)
+ if (use_swiftshader_ || ShouldUseWarp())
return true;
if (!gpu_process_accessible_) {
@@ -398,6 +398,11 @@ void GpuDataManagerImplPrivate::RegisterSwiftShaderPath(
EnableSwiftShaderIfNecessary();
}
+bool GpuDataManagerImplPrivate::ShouldUseWarp() const {
+ return use_warp_ ||
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseWarp);
+}
+
void GpuDataManagerImplPrivate::AddObserver(GpuDataManagerObserver* observer) {
GpuDataManagerImpl::UnlockedSession session(owner_);
observer_list_->AddObserver(observer);
@@ -545,7 +550,7 @@ void GpuDataManagerImplPrivate::UpdateGpuInfoHelper() {
void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) {
// No further update of gpu_info if falling back to SwiftShader.
- if (use_swiftshader_)
+ if (use_swiftshader_ || ShouldUseWarp())
return;
gpu::MergeGPUInfo(&gpu_info_, gpu_info);
@@ -645,6 +650,9 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine(
gpu_info_.driver_vendor);
command_line->AppendSwitchASCII(switches::kGpuDriverVersion,
gpu_info_.driver_version);
+
+ if (ShouldUseWarp())
+ command_line->AppendSwitch(switches::kUseWarp);
}
void GpuDataManagerImplPrivate::AppendPluginCommandLine(
@@ -707,6 +715,7 @@ void GpuDataManagerImplPrivate::DisableHardwareAcceleration() {
for (int i = 0; i < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++i)
blacklisted_features_.insert(i);
+ EnableWarpIfNecessary();
EnableSwiftShaderIfNecessary();
NotifyGpuInfoUpdate();
}
@@ -813,6 +822,8 @@ bool GpuDataManagerImplPrivate::UpdateActiveGpu(
}
bool GpuDataManagerImplPrivate::CanUseGpuBrowserCompositor() const {
+ if (ShouldUseWarp())
+ return true;
if (ShouldUseSwiftShader())
return false;
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING))
@@ -859,6 +870,7 @@ GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(
: complete_gpu_info_already_requested_(false),
observer_list_(new GpuDataManagerObserverList),
use_swiftshader_(false),
+ use_warp_(false),
card_blacklisted_(false),
update_histograms_(true),
window_count_(0),
@@ -932,6 +944,7 @@ void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures(
blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_WEBGL);
}
+ EnableWarpIfNecessary();
EnableSwiftShaderIfNecessary();
}
@@ -957,6 +970,9 @@ void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() {
}
void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() {
+ if (ShouldUseWarp())
+ return;
+
if (!GpuAccessAllowed(NULL) ||
blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) {
if (!swiftshader_path_.empty() &&
@@ -966,6 +982,22 @@ void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() {
}
}
+void GpuDataManagerImplPrivate::EnableWarpIfNecessary() {
+#if defined(OS_WIN)
+ if (use_warp_)
+ return;
+ // We should only use WARP if we are unable to use the regular GPU for
+ // compositing, and if we in Metro mode.
+ use_warp_ =
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kViewerConnect) &&
+ !CanUseGpuBrowserCompositor();
+#endif
+}
+
+void GpuDataManagerImplPrivate::ForceWarpModeForTesting() {
+ use_warp_ = true;
+}
+
std::string GpuDataManagerImplPrivate::GetDomainFromURL(
const GURL& url) const {
// For the moment, we just use the host, or its IP address, as the
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.h b/content/browser/gpu/gpu_data_manager_impl_private.h
index 8e5514f..61c1988 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.h
+++ b/content/browser/gpu/gpu_data_manager_impl_private.h
@@ -42,6 +42,7 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
void RequestVideoMemoryUsageStatsUpdate() const;
bool ShouldUseSwiftShader() const;
void RegisterSwiftShaderPath(const base::FilePath& path);
+ bool ShouldUseWarp() const;
void AddObserver(GpuDataManagerObserver* observer);
void RemoveObserver(GpuDataManagerObserver* observer);
void UnblockDomainFrom3DAPIs(const GURL& url);
@@ -127,6 +128,8 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
SwiftShaderRendering2);
FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
+ WarpEnabledOverridesSwiftShader);
+ FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
GpuInfoUpdate);
FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
NoGpuInfoUpdateWithSwiftShader);
@@ -201,6 +204,13 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
// Try to switch to SwiftShader rendering, if possible and necessary.
void EnableSwiftShaderIfNecessary();
+ // Try to switch to WARP rendering if the GPU hardware is not supported or
+ // absent, and if we are trying to run in Windows Metro mode.
+ void EnableWarpIfNecessary();
+
+ // Use only for testing, forces |use_warp_| to true.
+ void ForceWarpModeForTesting();
+
// Helper to extract the domain from a given URL.
std::string GetDomainFromURL(const GURL& url) const;
@@ -231,6 +241,8 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
bool use_swiftshader_;
+ bool use_warp_;
+
base::FilePath swiftshader_path_;
// Current card force-blacklisted due to GPU crashes, or disabled through
diff --git a/content/browser/gpu/gpu_data_manager_impl_private_unittest.cc b/content/browser/gpu/gpu_data_manager_impl_private_unittest.cc
index 41458ed..661e506 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private_unittest.cc
+++ b/content/browser/gpu/gpu_data_manager_impl_private_unittest.cc
@@ -14,6 +14,10 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
+#if defined(OS_WIN)
+#include "base/win/windows_version.h"
+#endif
+
#define LONG_STRING_CONST(...) #__VA_ARGS__
namespace content {
@@ -284,6 +288,22 @@ TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) {
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
}
+TEST_F(GpuDataManagerImplPrivateTest, WarpEnabledOverridesSwiftShader) {
+ // If WARP fallback is enabled on Windows 8 it should not allow SwiftShader
+ // to be enabled.
+#if defined(OS_WIN)
+ if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
+ ScopedGpuDataManagerImplPrivate manager;
+ manager->ForceWarpModeForTesting();
+ const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath"));
+ manager->RegisterSwiftShaderPath(test_path);
+ manager->DisableHardwareAcceleration();
+ EXPECT_TRUE(manager->ShouldUseWarp());
+ EXPECT_FALSE(manager->ShouldUseSwiftShader());
+ }
+#endif
+}
+
TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) {
ScopedGpuDataManagerImpl manager;
diff --git a/content/browser/gpu/gpu_internals_ui.cc b/content/browser/gpu/gpu_internals_ui.cc
index c338e02..7425089 100644
--- a/content/browser/gpu/gpu_internals_ui.cc
+++ b/content/browser/gpu/gpu_internals_ui.cc
@@ -127,6 +127,10 @@ base::DictionaryValue* GpuInfoAsDictionaryValue() {
ui::win::IsAeroGlassEnabled() ? "Aero Glass" : "none";
basic_info->Append(
NewDescriptionValuePair("Desktop compositing", compositor));
+ if (GpuDataManagerImpl::GetInstance()->ShouldUseWarp()) {
+ basic_info->Append(NewDescriptionValuePair("Using WARP",
+ new base::FundamentalValue(true)));
+ }
#endif
basic_info->Append(