Index: content/browser/gpu/gpu_data_manager_impl_private.cc |
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc |
index fd705c8967ac20837a5d2c6b45f039d7c71b3fa2..2f362d6038015282ed8cfc32754e7ad4ce4c4291 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 |